diff --git a/apps/regression/calculation_controller.h b/apps/regression/calculation_controller.h index bbec0ca66..5d85a2ca6 100644 --- a/apps/regression/calculation_controller.h +++ b/apps/regression/calculation_controller.h @@ -13,7 +13,7 @@ namespace Regression { -class CalculationController : public Shared::TabTableController, public TableViewDataSource, public SelectableTableViewDelegate, public ButtonRowDelegate, public AlternateEmptyViewDelegate { +class CalculationController : public Shared::TabTableController, public TableViewDataSource, public SelectableTableViewDelegate, public ButtonRowDelegate, public AlternateEmptyViewDefaultDelegate { public: CalculationController(Responder * parentResponder, ButtonRowController * header, Store * store); @@ -28,7 +28,7 @@ public: // SelectableTableViewDelegate void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override; - // AlternateEmptyViewDelegate + // AlternateEmptyViewDefaultDelegate bool isEmpty() const override; I18n::Message emptyMessage() override; Responder * defaultController() override; diff --git a/apps/shared/interactive_curve_view_controller.h b/apps/shared/interactive_curve_view_controller.h index 07dce8057..2a1c6c316 100644 --- a/apps/shared/interactive_curve_view_controller.h +++ b/apps/shared/interactive_curve_view_controller.h @@ -9,7 +9,7 @@ namespace Shared { -class InteractiveCurveViewController : public SimpleInteractiveCurveViewController, public InteractiveCurveViewRangeDelegate, public ButtonRowDelegate, public AlternateEmptyViewDelegate { +class InteractiveCurveViewController : public SimpleInteractiveCurveViewController, public InteractiveCurveViewRangeDelegate, public ButtonRowDelegate, public AlternateEmptyViewDefaultDelegate { public: InteractiveCurveViewController(Responder * parentResponder, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * rangeVersion); diff --git a/apps/shared/values_controller.h b/apps/shared/values_controller.h index 0c32ecb25..43c6bc162 100644 --- a/apps/shared/values_controller.h +++ b/apps/shared/values_controller.h @@ -13,7 +13,7 @@ namespace Shared { -class ValuesController : public EditableCellTableViewController, public ButtonRowDelegate, public AlternateEmptyViewDelegate { +class ValuesController : public EditableCellTableViewController, public ButtonRowDelegate, public AlternateEmptyViewDefaultDelegate { public: ValuesController(Responder * parentResponder, ButtonRowController * header, I18n::Message parameterTitle, IntervalParameterController * intervalParameterController, Interval * interval); const char * title() override; diff --git a/apps/solver/solutions_controller.h b/apps/solver/solutions_controller.h index 5e4cc418e..a136bb675 100644 --- a/apps/solver/solutions_controller.h +++ b/apps/solver/solutions_controller.h @@ -8,14 +8,14 @@ namespace Solver { -class SolutionsController : public ViewController, public AlternateEmptyViewDelegate, public SelectableTableViewDataSource, public TableViewDataSource { +class SolutionsController : public ViewController, public AlternateEmptyViewDefaultDelegate, public SelectableTableViewDataSource, public TableViewDataSource { public: SolutionsController(Responder * parentResponder, EquationStore * equationStore); /* ViewController */ const char * title() override; View * view() override; void viewWillAppear() override; - /* AlternateEmptyViewDelegate */ + /* AlternateEmptyViewDefaultDelegate */ bool isEmpty() const override; virtual I18n::Message emptyMessage() override; virtual Responder * defaultController() override; diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index 12368dc79..cd1108d99 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -34,7 +34,7 @@ CalculationController::CalculationController(Responder * parentResponder, Button m_hideableCell.setHide(true); } -// AlternateEmptyViewDelegate +// AlternateEmptyViewDefaultDelegate bool CalculationController::isEmpty() const { return m_store->isEmpty(); diff --git a/apps/statistics/calculation_controller.h b/apps/statistics/calculation_controller.h index 4fa9edb82..8a717b3a0 100644 --- a/apps/statistics/calculation_controller.h +++ b/apps/statistics/calculation_controller.h @@ -12,12 +12,12 @@ namespace Statistics { -class CalculationController : public Shared::TabTableController, public ButtonRowDelegate, public TableViewDataSource, public AlternateEmptyViewDelegate { +class CalculationController : public Shared::TabTableController, public ButtonRowDelegate, public TableViewDataSource, public AlternateEmptyViewDefaultDelegate { public: CalculationController(Responder * parentResponder, ButtonRowController * header, Store * store); - // AlternateEmptyViewDelegate + // AlternateEmptyViewDefaultDelegate bool isEmpty() const override; I18n::Message emptyMessage() override; Responder * defaultController() override; diff --git a/apps/statistics/multiple_data_view_controller.h b/apps/statistics/multiple_data_view_controller.h index 23fd3eaaa..b1dc432cd 100644 --- a/apps/statistics/multiple_data_view_controller.h +++ b/apps/statistics/multiple_data_view_controller.h @@ -7,13 +7,13 @@ namespace Statistics { -class MultipleDataViewController : public ViewController, public AlternateEmptyViewDelegate { +class MultipleDataViewController : public ViewController, public AlternateEmptyViewDefaultDelegate { public: MultipleDataViewController(Responder * parentResponder, Store * store, int * m_selectedBarIndex, int * selectedSeriesIndex); virtual MultipleDataView * multipleDataView() = 0; int selectedSeriesIndex() const { return *m_selectedSeriesIndex; } - // AlternateEmptyViewDelegate + // AlternateEmptyViewDefaultDelegate bool isEmpty() const override; I18n::Message emptyMessage() override; Responder * defaultController() override; diff --git a/escher/include/escher/alternate_empty_view_controller.h b/escher/include/escher/alternate_empty_view_controller.h index 0a3f2da1d..62bb098b5 100644 --- a/escher/include/escher/alternate_empty_view_controller.h +++ b/escher/include/escher/alternate_empty_view_controller.h @@ -3,7 +3,6 @@ #include #include -#include #include class AlternateEmptyViewController : public ViewController { @@ -25,7 +24,6 @@ private: private: int numberOfSubviews() const override; View * subviewAtIndex(int index) override; - MessageTextView m_message; ViewController * m_mainViewController; AlternateEmptyViewDelegate * m_delegate; }; diff --git a/escher/include/escher/alternate_empty_view_delegate.h b/escher/include/escher/alternate_empty_view_delegate.h index 19a7a1ca9..676a4cb9d 100644 --- a/escher/include/escher/alternate_empty_view_delegate.h +++ b/escher/include/escher/alternate_empty_view_delegate.h @@ -2,6 +2,8 @@ #define ESCHER_ALTERNATE_EMPTY_VIEW_DELEGATE_H #include +#include +#include #include class AlternateEmptyViewController; @@ -9,8 +11,20 @@ class AlternateEmptyViewController; class AlternateEmptyViewDelegate { public: virtual bool isEmpty() const = 0; - virtual I18n::Message emptyMessage() = 0; + virtual View * emptyView() = 0; virtual Responder * defaultController() = 0; }; +class AlternateEmptyViewDefaultDelegate : public AlternateEmptyViewDelegate { +public: + AlternateEmptyViewDefaultDelegate() : m_message(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen) {} + virtual I18n::Message emptyMessage() = 0; + View * emptyView() override { + m_message.setMessage(emptyMessage()); + return &m_message; + } +private: + MessageTextView m_message; +}; + #endif diff --git a/escher/src/alternate_empty_view_controller.cpp b/escher/src/alternate_empty_view_controller.cpp index 4aaf3ff1b..5c23c1af9 100644 --- a/escher/src/alternate_empty_view_controller.cpp +++ b/escher/src/alternate_empty_view_controller.cpp @@ -1,12 +1,10 @@ #include #include -#include #include /* ContentView */ AlternateEmptyViewController::ContentView::ContentView(ViewController * mainViewController, AlternateEmptyViewDelegate * delegate) : - m_message(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), m_mainViewController(mainViewController), m_delegate(delegate) { @@ -19,15 +17,14 @@ int AlternateEmptyViewController::ContentView::numberOfSubviews() const { View * AlternateEmptyViewController::ContentView::subviewAtIndex(int index) { assert(index == 0); if (m_delegate->isEmpty()) { - m_message.setMessage(m_delegate->emptyMessage()); - return &m_message; + return m_delegate->emptyView(); } return m_mainViewController->view(); } void AlternateEmptyViewController::ContentView::layoutSubviews() { if (alternateEmptyViewDelegate()->isEmpty()) { - m_message.setFrame(bounds()); + m_delegate->emptyView()->setFrame(bounds()); } else { m_mainViewController->view()->setFrame(bounds()); }