mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 11:39:58 +02:00
[code] Larger console button in MenuController.
Change-Id: Ia8a495d4de95a4a9d6fee698975b2c7e831c4c43
This commit is contained in:
@@ -37,7 +37,7 @@ ScriptStore * App::Snapshot::scriptStore() {
|
||||
|
||||
App::App(Container * container, Snapshot * snapshot) :
|
||||
::App(container, snapshot, &m_codeStackViewController, I18n::Message::Warning),
|
||||
m_listFooter(&m_codeStackViewController, &m_menuController, &m_menuController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGrey),
|
||||
m_listFooter(&m_codeStackViewController, &m_menuController, &m_menuController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGrey, ButtonRowController::Size::Large),
|
||||
m_menuController(&m_listFooter, snapshot->scriptStore(), &m_listFooter),
|
||||
m_codeStackViewController(&m_modalViewController, &m_listFooter),
|
||||
m_toolboxActionForTextArea([](void * sender, const char * text) {
|
||||
|
||||
@@ -17,11 +17,13 @@ protected:
|
||||
MessageTextView m_messageTextView;
|
||||
private:
|
||||
constexpr static KDCoordinate k_verticalMargin = 5;
|
||||
constexpr static KDCoordinate k_horizontalMargin = 10;
|
||||
constexpr static KDCoordinate k_horizontalMarginSmall = 10;
|
||||
constexpr static KDCoordinate k_horizontalMarginLarge = 20;
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
Invocation m_invocation;
|
||||
KDText::FontSize m_size;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,11 @@ public:
|
||||
PlainWhite,
|
||||
EmbossedGrey
|
||||
};
|
||||
ButtonRowController(Responder * parentResponder, ViewController * mainViewController, ButtonRowDelegate * delegate, Position position = Position::Top, Style = Style::PlainWhite);
|
||||
enum class Size {
|
||||
Small,
|
||||
Large
|
||||
};
|
||||
ButtonRowController(Responder * parentResponder, ViewController * mainViewController, ButtonRowDelegate * delegate, Position position = Position::Top, Style = Style::PlainWhite, Size size = Size::Small);
|
||||
View * view() override { return &m_contentView; }
|
||||
const char * title() override;
|
||||
void didBecomeFirstResponder() override;
|
||||
@@ -34,7 +38,7 @@ public:
|
||||
private:
|
||||
class ContentView : public View {
|
||||
public:
|
||||
ContentView(ViewController * mainViewController, ButtonRowDelegate * delegate, Position position, Style style);
|
||||
ContentView(ViewController * mainViewController, ButtonRowDelegate * delegate, Position position, Style style, Size size);
|
||||
int numberOfButtons() const;
|
||||
Button * buttonAtIndex(int index) const;
|
||||
int numberOfSubviews() const override;
|
||||
@@ -47,8 +51,10 @@ private:
|
||||
ButtonRowDelegate * buttonRowDelegate() const { return m_delegate; }
|
||||
private:
|
||||
constexpr static KDCoordinate k_plainStyleHeight = 20;
|
||||
constexpr static KDCoordinate k_embossedStyleHeight = 36;
|
||||
constexpr static KDCoordinate k_embossedStyleHeightMargin = 6;
|
||||
constexpr static KDCoordinate k_embossedStyleHeightSmall = 36;
|
||||
constexpr static KDCoordinate k_embossedStyleHeightLarge = 52;
|
||||
constexpr static KDCoordinate k_embossedStyleHeightMarginSmall = 6;
|
||||
constexpr static KDCoordinate k_embossedStyleHeightMarginLarge = 8;
|
||||
constexpr static KDColor k_separatorHeaderColor = KDColor::RGB24(0xDEE0E2);
|
||||
constexpr static KDColor k_selectedBackgroundColor = KDColor::RGB24(0x426DA7);
|
||||
ViewController * m_mainViewController;
|
||||
@@ -56,6 +62,7 @@ private:
|
||||
ButtonRowDelegate * m_delegate;
|
||||
Position m_position;
|
||||
Style m_style;
|
||||
Size m_size;
|
||||
};
|
||||
ContentView m_contentView;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,8 @@ Button::Button(Responder * parentResponder, I18n::Message textBody, Invocation i
|
||||
HighlightCell(),
|
||||
Responder(parentResponder),
|
||||
m_messageTextView(size, textBody, 0.5f, 0.5f, textColor),
|
||||
m_invocation(invocation)
|
||||
m_invocation(invocation),
|
||||
m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,5 +41,5 @@ void Button::setHighlighted(bool highlight) {
|
||||
|
||||
KDSize Button::minimalSizeForOptimalDisplay() const {
|
||||
KDSize textSize = m_messageTextView.minimalSizeForOptimalDisplay();
|
||||
return KDSize(textSize.width() + k_horizontalMargin, textSize.height() + k_verticalMargin);
|
||||
return KDSize(textSize.width() + (m_size == KDText::FontSize::Small ? k_horizontalMarginSmall : k_horizontalMarginLarge), textSize.height() + k_verticalMargin);
|
||||
}
|
||||
|
||||
@@ -8,13 +8,14 @@ ButtonRowDelegate::ButtonRowDelegate(ButtonRowController * header, ButtonRowCont
|
||||
{
|
||||
}
|
||||
|
||||
ButtonRowController::ContentView::ContentView(ViewController * mainViewController, ButtonRowDelegate * delegate, Position position, Style style) :
|
||||
ButtonRowController::ContentView::ContentView(ViewController * mainViewController, ButtonRowDelegate * delegate, Position position, Style style, Size size) :
|
||||
View(),
|
||||
m_mainViewController(mainViewController),
|
||||
m_selectedButton(-1),
|
||||
m_delegate(delegate),
|
||||
m_position(position),
|
||||
m_style(style)
|
||||
m_style(style),
|
||||
m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -51,7 +52,12 @@ void ButtonRowController::ContentView::layoutSubviews() {
|
||||
m_mainViewController->view()->setFrame(mainViewFrame);
|
||||
return;
|
||||
}
|
||||
KDCoordinate rowHeight = m_style == Style::PlainWhite ? k_plainStyleHeight : k_embossedStyleHeight;
|
||||
KDCoordinate rowHeight;
|
||||
if (m_style == Style::PlainWhite) {
|
||||
rowHeight = k_plainStyleHeight;
|
||||
} else {
|
||||
rowHeight = m_size == Size::Small ? k_embossedStyleHeightSmall : k_embossedStyleHeightLarge;
|
||||
}
|
||||
KDCoordinate frameOrigin = m_position == Position::Top ? rowHeight+1 : 0;
|
||||
KDRect mainViewFrame(0, frameOrigin, bounds().width(), bounds().height() - rowHeight - 1);
|
||||
m_mainViewController->view()->setFrame(mainViewFrame);
|
||||
@@ -68,8 +74,8 @@ void ButtonRowController::ContentView::layoutSubviews() {
|
||||
totalButtonWidth += button->minimalSizeForOptimalDisplay().width();
|
||||
}
|
||||
widthMargin = std::round((float)((bounds().width() - totalButtonWidth)/(nbOfButtons+1)));
|
||||
buttonHeightMargin = k_embossedStyleHeightMargin;
|
||||
buttonHeight = rowHeight- 2*k_embossedStyleHeightMargin;
|
||||
buttonHeightMargin = m_size == Size::Small ? k_embossedStyleHeightMarginSmall : k_embossedStyleHeightMarginLarge;
|
||||
buttonHeight = rowHeight- 2*buttonHeightMargin;
|
||||
}
|
||||
KDCoordinate yOrigin = m_position == Position::Top ? buttonHeightMargin : bounds().height()-rowHeight+buttonHeightMargin;
|
||||
int currentXOrigin = widthMargin;
|
||||
@@ -95,19 +101,21 @@ void ButtonRowController::ContentView::drawRect(KDContext * ctx, KDRect rect) co
|
||||
ctx->fillRect(KDRect(0, k_plainStyleHeight, bounds().width(), 1), Palette::GreyWhite);
|
||||
} else {
|
||||
ctx->fillRect(KDRect(0, bounds().height() - k_plainStyleHeight, bounds().width(), k_plainStyleHeight), KDColorWhite);
|
||||
ctx->fillRect(KDRect(0, bounds().height() - k_plainStyleHeight-1, bounds().width(), 1), Palette::GreyWhite);
|
||||
ctx->fillRect(KDRect(0, bounds().height() - k_plainStyleHeight-1, bounds().width(), 1), Palette::GreyWhite);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int buttonHeight = m_size == Size::Small ? k_embossedStyleHeightSmall : k_embossedStyleHeightLarge;
|
||||
int buttonMargin = m_size == Size::Small ? k_embossedStyleHeightMarginSmall : k_embossedStyleHeightMarginLarge;
|
||||
if (m_position == Position::Top) {
|
||||
ctx->fillRect(KDRect(0, 0, bounds().width(), k_embossedStyleHeight), Palette::GreyWhite);
|
||||
ctx->fillRect(KDRect(0, k_embossedStyleHeight, bounds().width(), 1), Palette::GreyMiddle);
|
||||
ctx->fillRect(KDRect(0, 0, bounds().width(), buttonHeight), Palette::GreyWhite);
|
||||
ctx->fillRect(KDRect(0, buttonHeight, bounds().width(), 1), Palette::GreyMiddle);
|
||||
} else {
|
||||
ctx->fillRect(KDRect(0, bounds().height() - k_embossedStyleHeight, bounds().width(), k_embossedStyleHeight), Palette::GreyWhite);
|
||||
ctx->fillRect(KDRect(0, bounds().height() - k_embossedStyleHeight-1, bounds().width(), 1), Palette::GreyMiddle);
|
||||
ctx->fillRect(KDRect(0, bounds().height() - buttonHeight, bounds().width(), buttonHeight), Palette::GreyWhite);
|
||||
ctx->fillRect(KDRect(0, bounds().height() - buttonHeight-1, bounds().width(), 1), Palette::GreyMiddle);
|
||||
}
|
||||
KDCoordinate y0 = m_position == Position::Top ? k_embossedStyleHeightMargin-1 : bounds().height()-k_embossedStyleHeight+k_embossedStyleHeightMargin-1;
|
||||
KDCoordinate y1 = m_position == Position::Top ? k_embossedStyleHeight-k_embossedStyleHeightMargin-2 : bounds().height()-k_embossedStyleHeightMargin;
|
||||
KDCoordinate y0 = m_position == Position::Top ? buttonMargin-1 : bounds().height()-buttonHeight+buttonMargin-1;
|
||||
KDCoordinate y1 = m_position == Position::Top ? buttonHeight-buttonMargin-2 : bounds().height()-buttonMargin;
|
||||
KDCoordinate totalButtonWidth = 0;
|
||||
for (int i = 0; i < numberOfButtons(); i++) {
|
||||
Button * button = buttonAtIndex(i);
|
||||
@@ -147,9 +155,9 @@ bool ButtonRowController::ContentView::setSelectedButton(int selectedButton, App
|
||||
return false;
|
||||
}
|
||||
|
||||
ButtonRowController::ButtonRowController(Responder * parentResponder, ViewController * mainViewController, ButtonRowDelegate * delegate, Position position, Style style) :
|
||||
ButtonRowController::ButtonRowController(Responder * parentResponder, ViewController * mainViewController, ButtonRowDelegate * delegate, Position position, Style style, Size size) :
|
||||
ViewController(parentResponder),
|
||||
m_contentView(mainViewController, delegate, position, style)
|
||||
m_contentView(mainViewController, delegate, position, style, size)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user