mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Create a class curve view with banner
Change-Id: I49108e9231f97aeed53351e2596b6550568c6314
This commit is contained in:
@@ -9,6 +9,7 @@ app_objs += $(addprefix apps/,\
|
||||
apps_container.o\
|
||||
constant.o\
|
||||
curve_view.o\
|
||||
curve_view_with_banner.o\
|
||||
curve_view_window.o\
|
||||
editable_cell_table_view_controller.o\
|
||||
expression_text_field_delegate.o\
|
||||
|
||||
39
apps/curve_view_with_banner.cpp
Normal file
39
apps/curve_view_with_banner.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "curve_view_with_banner.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
CurveViewWithBanner::CurveViewWithBanner(CurveViewWindow * curveViewWindow, float topMarginFactor,
|
||||
float rightMarginFactor, float bottomMarginFactor, float leftMarginFactor) :
|
||||
CurveView(curveViewWindow, topMarginFactor, rightMarginFactor, bottomMarginFactor, leftMarginFactor),
|
||||
m_mainViewSelected(true)
|
||||
{
|
||||
}
|
||||
|
||||
bool CurveViewWithBanner::isMainViewSelected() {
|
||||
return m_mainViewSelected;
|
||||
}
|
||||
|
||||
void CurveViewWithBanner::selectMainView(bool mainViewSelected) {
|
||||
if (m_mainViewSelected != mainViewSelected) {
|
||||
m_mainViewSelected = mainViewSelected;
|
||||
reloadMainView();
|
||||
layoutSubviews();
|
||||
}
|
||||
}
|
||||
|
||||
int CurveViewWithBanner::numberOfSubviews() const {
|
||||
return 1;
|
||||
};
|
||||
|
||||
View * CurveViewWithBanner::subviewAtIndex(int index) {
|
||||
assert(index == 0);
|
||||
return bannerView();
|
||||
}
|
||||
|
||||
void CurveViewWithBanner::layoutSubviews() {
|
||||
KDRect bannerFrame(KDRect(0, bounds().height()- k_bannerHeight, bounds().width(), k_bannerHeight));
|
||||
if (!m_mainViewSelected) {
|
||||
bannerFrame = KDRectZero;
|
||||
}
|
||||
bannerView()->setFrame(bannerFrame);
|
||||
}
|
||||
24
apps/curve_view_with_banner.h
Normal file
24
apps/curve_view_with_banner.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef APPS_CURVE_VIEW_WITH_BANNER_H
|
||||
#define APPS_CURVE_VIEW_WITH_BANNER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "curve_view.h"
|
||||
|
||||
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;
|
||||
bool isMainViewSelected();
|
||||
void selectMainView(bool mainViewSelected);
|
||||
protected:
|
||||
void layoutSubviews() override;
|
||||
bool m_mainViewSelected;
|
||||
private:
|
||||
constexpr static KDCoordinate k_bannerHeight = 30;
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
virtual View * bannerView() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user