diff --git a/apps/shared/Makefile b/apps/shared/Makefile index 34ad1cc5b..06d43bb88 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -1,5 +1,6 @@ app_objs += $(addprefix apps/shared/,\ banner_view.o\ + button_with_separator.o\ cursor_view.o\ curve_view.o\ curve_view_cursor.o\ diff --git a/apps/shared/button_with_separator.cpp b/apps/shared/button_with_separator.cpp new file mode 100644 index 000000000..c26682f41 --- /dev/null +++ b/apps/shared/button_with_separator.cpp @@ -0,0 +1,27 @@ +#include "button_with_separator.h" + +ButtonWithSeparator::ButtonWithSeparator(Responder * parentResponder, const char * textBody, Invocation invocation) : + Button(parentResponder, textBody, invocation, KDText::FontSize::Large, KDColorBlack) +{ +} + +void ButtonWithSeparator::drawRect(KDContext * ctx, KDRect rect) const { + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + + ctx->fillRect(KDRect(0, 0, width, k_margin), Palette::WallScreen); + // Draw rectangle around cell + ctx->fillRect(KDRect(0, k_margin, width, k_lineThickness), Palette::GreyBright); + ctx->fillRect(KDRect(0, k_margin+k_lineThickness, k_lineThickness, height-k_margin), Palette::GreyBright); + ctx->fillRect(KDRect(width-k_lineThickness, k_lineThickness+k_margin, k_lineThickness, height-k_margin), Palette::GreyBright); + ctx->fillRect(KDRect(0, height-3*k_lineThickness, width, k_lineThickness), Palette::GreyWhite); + ctx->fillRect(KDRect(0, height-2*k_lineThickness, width, k_lineThickness), Palette::GreyBright); + ctx->fillRect(KDRect(k_lineThickness, height-k_lineThickness, width-2*k_lineThickness, k_lineThickness), Palette::GreyMiddle); +} + + +void ButtonWithSeparator::layoutSubviews() { + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + m_pointerTextView.setFrame(KDRect(k_lineThickness, k_margin + k_lineThickness, width-2*k_lineThickness, height - 4*k_lineThickness-k_margin)); +} diff --git a/apps/shared/button_with_separator.h b/apps/shared/button_with_separator.h new file mode 100644 index 000000000..8f1e07d02 --- /dev/null +++ b/apps/shared/button_with_separator.h @@ -0,0 +1,16 @@ +#ifndef SHARED_BUTTON_WITH_SEPARATOR_H +#define SHARED_BUTTON_WITH_SEPARATOR_H + +#include + +class ButtonWithSeparator : public Button { +public: + ButtonWithSeparator(Responder * parentResponder, const char * textBody, Invocation invocation); + void drawRect(KDContext * ctx, KDRect rect) const override; +private: + constexpr static KDCoordinate k_margin = 5; + constexpr static KDCoordinate k_lineThickness = 1; + void layoutSubviews() override; +}; + +#endif diff --git a/apps/shared/float_parameter_controller.cpp b/apps/shared/float_parameter_controller.cpp index 68bcec3ac..69afc8315 100644 --- a/apps/shared/float_parameter_controller.cpp +++ b/apps/shared/float_parameter_controller.cpp @@ -12,10 +12,10 @@ FloatParameterController::FloatParameterController(Responder * parentResponder, ViewController(parentResponder), m_selectableTableView(SelectableTableView(this, this, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin, this)), - m_okButton(Button(&m_selectableTableView, okButtonText, Invocation([](void * context, void * sender) { + m_okButton(ButtonWithSeparator(&m_selectableTableView, okButtonText, Invocation([](void * context, void * sender) { FloatParameterController * parameterController = (FloatParameterController *) context; parameterController->buttonAction(); - }, this), KDText::FontSize::Large)) + }, this))) { } @@ -72,6 +72,9 @@ KDCoordinate FloatParameterController::rowHeight(int j) { } KDCoordinate FloatParameterController::cumulatedHeightFromIndex(int j) { + if (j == numberOfRows()) { + return j*Metric::ParameterCellHeight+k_buttonMargin; + } return Metric::ParameterCellHeight*j; } diff --git a/apps/shared/float_parameter_controller.h b/apps/shared/float_parameter_controller.h index 81dceaee0..e75ab6dd9 100644 --- a/apps/shared/float_parameter_controller.h +++ b/apps/shared/float_parameter_controller.h @@ -3,6 +3,7 @@ #include #include "text_field_delegate.h" +#include "button_with_separator.h" namespace Shared { @@ -32,7 +33,7 @@ protected: StackViewController * stackController(); SelectableTableView m_selectableTableView; private: - constexpr static int k_buttonMargin = 5; + constexpr static int k_buttonMargin = 6; virtual void buttonAction(); virtual int reusableParameterCellCount(int type) = 0; virtual HighlightCell * reusableParameterCell(int index, int type) = 0; @@ -40,7 +41,7 @@ private: virtual float previousParameterAtIndex(int index) = 0; virtual float parameterAtIndex(int index) = 0; virtual void setParameterAtIndex(int parameterIndex, float f) = 0; - Button m_okButton; + ButtonWithSeparator m_okButton; }; } diff --git a/escher/include/escher/button.h b/escher/include/escher/button.h index 6352a288f..656fe5ac1 100644 --- a/escher/include/escher/button.h +++ b/escher/include/escher/button.h @@ -12,13 +12,14 @@ public: bool handleEvent(Ion::Events::Event event) override; void setHighlighted(bool highlight) override; KDSize minimalSizeForOptimalDisplay() const override; +protected: + PointerTextView m_pointerTextView; private: constexpr static KDCoordinate k_verticalMargin = 5; constexpr static KDCoordinate k_horizontalMargin = 10; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; - PointerTextView m_pointerTextView; Invocation m_invocation; };