mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/shared] Improve validate button rendering in float parameter
controllers Change-Id: I58ccc4da68c83509fe734038781b971d2a8f74c6
This commit is contained in:
@@ -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\
|
||||
|
||||
27
apps/shared/button_with_separator.cpp
Normal file
27
apps/shared/button_with_separator.cpp
Normal file
@@ -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));
|
||||
}
|
||||
16
apps/shared/button_with_separator.h
Normal file
16
apps/shared/button_with_separator.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef SHARED_BUTTON_WITH_SEPARATOR_H
|
||||
#define SHARED_BUTTON_WITH_SEPARATOR_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <escher.h>
|
||||
#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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user