mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps] Add borders to VariableBoxEmptyController
This commit is contained in:
@@ -28,6 +28,10 @@ void VariableBoxEmptyController::VariableBoxEmptyView::setLayout(Poincare::Layou
|
||||
m_layoutExample.setLayout(layout);
|
||||
}
|
||||
|
||||
void VariableBoxEmptyController::VariableBoxEmptyView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
drawBorderOfRect(ctx, bounds(), Palette::GreyBright);
|
||||
}
|
||||
|
||||
int VariableBoxEmptyController::VariableBoxEmptyView::numberOfSubviews() const {
|
||||
return k_numberOfMessages+1;
|
||||
}
|
||||
@@ -43,19 +47,19 @@ View * VariableBoxEmptyController::VariableBoxEmptyView::subviewAtIndex(int inde
|
||||
}
|
||||
|
||||
void VariableBoxEmptyController::VariableBoxEmptyView::layoutSubviews(bool force) {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
KDCoordinate width = bounds().width() - 2*k_separatorThickness;
|
||||
KDCoordinate height = bounds().height() - 2*k_separatorThickness;
|
||||
KDCoordinate textHeight = k_font->glyphSize().height();
|
||||
KDCoordinate layoutHeight = m_layoutExample.minimalSizeForOptimalDisplay().height();
|
||||
KDCoordinate margin = (height - k_numberOfMessages*textHeight-layoutHeight)/2;
|
||||
m_layoutExample.setFrame(KDRect(0, margin+k_layoutRowIndex*textHeight, width, layoutHeight), force);
|
||||
KDCoordinate currentHeight = 0;
|
||||
m_layoutExample.setFrame(KDRect(k_separatorThickness, k_separatorThickness+margin+k_layoutRowIndex*textHeight, width, layoutHeight), force);
|
||||
KDCoordinate currentHeight = k_separatorThickness;
|
||||
for (uint8_t i = 0; i < k_numberOfMessages; i++) {
|
||||
if (i == k_layoutRowIndex) {
|
||||
currentHeight += layoutHeight;
|
||||
}
|
||||
KDCoordinate h = i == 0 || i == k_numberOfMessages - 1 ? textHeight+margin : textHeight;
|
||||
m_messages[i].setFrame(KDRect(0, currentHeight, width, h), force);
|
||||
m_messages[i].setFrame(KDRect(k_separatorThickness, currentHeight, width, h), force);
|
||||
currentHeight += h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#ifndef APPS_VARIABLE_BOX_EMPTY_CONTROLLER_H
|
||||
#define APPS_VARIABLE_BOX_EMPTY_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include <escher/bordered.h>
|
||||
#include <escher/expression_view.h>
|
||||
#include <escher/message_text_view.h>
|
||||
#include <escher/view_controller.h>
|
||||
#include <poincare/layout.h>
|
||||
|
||||
class VariableBoxEmptyController : public ViewController {
|
||||
public:
|
||||
@@ -18,12 +22,13 @@ public:
|
||||
|
||||
void setType(Type type);
|
||||
private:
|
||||
class VariableBoxEmptyView : public View {
|
||||
class VariableBoxEmptyView : public View, public Bordered {
|
||||
public:
|
||||
static constexpr const KDFont * k_font = KDFont::SmallFont;
|
||||
VariableBoxEmptyView();
|
||||
void setMessages(I18n::Message * message);
|
||||
void setLayout(Poincare::Layout layout);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
constexpr static int k_numberOfMessages = 4;
|
||||
private:
|
||||
int numberOfSubviews() const override;
|
||||
|
||||
Reference in New Issue
Block a user