mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Rename methods in curve view with banner
Change-Id: I676ea90c241de1ade692fa04ee9c1daa89f3480f
This commit is contained in:
@@ -16,7 +16,7 @@ bool CurveViewWithBanner::isMainViewSelected() {
|
||||
void CurveViewWithBanner::selectMainView(bool mainViewSelected) {
|
||||
if (m_mainViewSelected != mainViewSelected) {
|
||||
m_mainViewSelected = mainViewSelected;
|
||||
reloadMainView();
|
||||
reloadSelection();
|
||||
layoutSubviews();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class CurveViewWithBanner : public CurveView {
|
||||
public:
|
||||
CurveViewWithBanner(CurveViewWindow * curveViewWindow = nullptr, float topMarginFactor = 0.0f,
|
||||
float rightMarginFactor = 0.0f, float bottomMarginFactor = 0.0f, float leftMarginFactor = 0.0f);
|
||||
virtual void reloadMainView() = 0;
|
||||
virtual void reloadSelection() = 0;
|
||||
bool isMainViewSelected();
|
||||
void selectMainView(bool mainViewSelected);
|
||||
protected:
|
||||
|
||||
@@ -33,7 +33,7 @@ bool BoxController::handleEvent(Ion::Events::Event event) {
|
||||
|
||||
void BoxController::didBecomeFirstResponder() {
|
||||
m_view.selectMainView(true);
|
||||
m_view.reload(-1);
|
||||
m_view.reload();
|
||||
}
|
||||
|
||||
bool BoxController::isEmpty() {
|
||||
|
||||
@@ -13,22 +13,19 @@ BoxView::BoxView(Data * data) :
|
||||
{
|
||||
}
|
||||
|
||||
void BoxView::reloadMainView() {
|
||||
reload(m_selectedQuantile);
|
||||
void BoxView::reloadSelection() {
|
||||
float calculations[5] = {m_data->minValue(), m_data->firstQuartile(), m_data->median(), m_data->thirdQuartile(), m_data->maxValue()};
|
||||
float pixelUpperBound = floatToPixel(Axis::Vertical, 0.2f)+1;
|
||||
float pixelLowerBound = floatToPixel(Axis::Vertical, 0.8)-1;
|
||||
float selectedValueInPixels = floatToPixel(Axis::Horizontal, calculations[m_selectedQuantile]);
|
||||
KDRect dirtyZone(KDRect(selectedValueInPixels-1, pixelLowerBound, 2, pixelUpperBound - pixelLowerBound));
|
||||
markRectAsDirty(dirtyZone);
|
||||
m_bannerView.reload();
|
||||
}
|
||||
|
||||
void BoxView::reload(int selectedQuantile) {
|
||||
if (selectedQuantile < 0) {
|
||||
markRectAsDirty(bounds());
|
||||
computeLabels(Axis::Horizontal);
|
||||
} else {
|
||||
float calculations[5] = {m_data->minValue(), m_data->firstQuartile(), m_data->median(), m_data->thirdQuartile(), m_data->maxValue()};
|
||||
float pixelUpperBound = floatToPixel(Axis::Vertical, 0.2f)+1;
|
||||
float pixelLowerBound = floatToPixel(Axis::Vertical, 0.8)-1;
|
||||
float selectedValueInPixels = floatToPixel(Axis::Horizontal, calculations[selectedQuantile]);
|
||||
KDRect dirtyZone(KDRect(selectedValueInPixels-1, pixelLowerBound, 2, pixelUpperBound - pixelLowerBound));
|
||||
markRectAsDirty(dirtyZone);
|
||||
}
|
||||
void BoxView::reload() {
|
||||
markRectAsDirty(bounds());
|
||||
computeLabels(Axis::Horizontal);
|
||||
m_bannerView.reload();
|
||||
}
|
||||
|
||||
@@ -41,9 +38,9 @@ bool BoxView::selectQuantile(int selectedQuantile) {
|
||||
return false;
|
||||
}
|
||||
if (m_selectedQuantile != selectedQuantile) {
|
||||
reload(m_selectedQuantile);
|
||||
reloadSelection();
|
||||
m_selectedQuantile = selectedQuantile;
|
||||
reload(m_selectedQuantile);
|
||||
reloadSelection();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Statistics {
|
||||
class BoxView : public CurveViewWithBanner {
|
||||
public:
|
||||
BoxView(Data * m_data);
|
||||
void reloadMainView() override;
|
||||
void reload(int selectedQuantile);
|
||||
void reloadSelection() override;
|
||||
void reload();
|
||||
int selectedQuantile();
|
||||
bool selectQuantile(int selectedQuantile);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
|
||||
@@ -40,7 +40,7 @@ bool HistogramController::handleEvent(Ion::Events::Event event) {
|
||||
if (!m_view.isMainViewSelected()) {
|
||||
headerViewController()->setSelectedButton(-1);
|
||||
m_view.selectMainView(true);
|
||||
m_view.reload(m_data->selectedBar());
|
||||
m_view.reloadSelection();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -57,11 +57,11 @@ bool HistogramController::handleEvent(Ion::Events::Event event) {
|
||||
}
|
||||
if (m_view.isMainViewSelected() && (event == Ion::Events::Left || event == Ion::Events::Right)) {
|
||||
int direction = event == Ion::Events::Left ? -1 : 1;
|
||||
m_view.reload(m_data->selectedBar());
|
||||
m_view.reloadSelection();
|
||||
if (m_data->selectNextBarToward(direction)) {
|
||||
m_view.reload(NAN);
|
||||
m_view.reload();
|
||||
} else {
|
||||
m_view.reload(m_data->selectedBar());
|
||||
m_view.reloadSelection();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ bool HistogramController::handleEvent(Ion::Events::Event event) {
|
||||
void HistogramController::didBecomeFirstResponder() {
|
||||
headerViewController()->setSelectedButton(-1);
|
||||
m_view.selectMainView(true);
|
||||
m_view.reload(NAN);
|
||||
m_view.reload();
|
||||
}
|
||||
|
||||
int HistogramController::numberOfButtons() const {
|
||||
|
||||
@@ -11,23 +11,20 @@ HistogramView::HistogramView(Data * data) :
|
||||
{
|
||||
}
|
||||
|
||||
void HistogramView::reloadMainView() {
|
||||
reload(m_data->selectedBar());
|
||||
void HistogramView::reloadSelection() {
|
||||
float pixelLowerBound = floatToPixel(Axis::Horizontal, m_data->selectedBar() - m_data->barWidth())-1;
|
||||
float pixelUpperBound = floatToPixel(Axis::Horizontal, m_data->selectedBar() + m_data->barWidth())+1;
|
||||
float selectedValueInPixels = floatToPixel(Axis::Vertical, (float)m_data->heightForBarAtValue(m_data->selectedBar())/(float)m_data->totalSize())-1;
|
||||
float horizontalAxisInPixels = floatToPixel(Axis::Vertical, 0.0f)+1;
|
||||
KDRect dirtyZone(KDRect(pixelLowerBound, selectedValueInPixels, pixelUpperBound-pixelLowerBound,
|
||||
horizontalAxisInPixels - selectedValueInPixels));
|
||||
markRectAsDirty(dirtyZone);
|
||||
m_bannerView.reload();
|
||||
}
|
||||
|
||||
void HistogramView::reload(float dirtyZoneCenter) {
|
||||
if (isnan(dirtyZoneCenter)) {
|
||||
markRectAsDirty(bounds());
|
||||
computeLabels(Axis::Horizontal);
|
||||
} else {
|
||||
float pixelLowerBound = floatToPixel(Axis::Horizontal, dirtyZoneCenter - m_data->barWidth())-1;
|
||||
float pixelUpperBound = floatToPixel(Axis::Horizontal, dirtyZoneCenter + m_data->barWidth())+1;
|
||||
float selectedValueInPixels = floatToPixel(Axis::Vertical, (float)m_data->heightForBarAtValue(dirtyZoneCenter)/(float)m_data->totalSize())-1;
|
||||
float horizontalAxisInPixels = floatToPixel(Axis::Vertical, 0.0f)+1;
|
||||
KDRect dirtyZone(KDRect(pixelLowerBound, selectedValueInPixels, pixelUpperBound-pixelLowerBound,
|
||||
horizontalAxisInPixels - selectedValueInPixels));
|
||||
markRectAsDirty(dirtyZone);
|
||||
}
|
||||
void HistogramView::reload() {
|
||||
markRectAsDirty(bounds());
|
||||
computeLabels(Axis::Horizontal);
|
||||
m_bannerView.reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Statistics {
|
||||
class HistogramView : public CurveViewWithBanner {
|
||||
public:
|
||||
HistogramView(Data * m_data);
|
||||
void reloadMainView() override;
|
||||
void reload(float dirtyZoneCenter);
|
||||
void reloadSelection() override;
|
||||
void reload();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_bannerHeight = 30;
|
||||
|
||||
Reference in New Issue
Block a user