Numworks Epsilon  1.4.1
Graphing Calculator Operating System
app_cell.cpp
Go to the documentation of this file.
1 #include "app_cell.h"
2 #include <assert.h>
3 
4 namespace Home {
5 
8  m_nameView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, KDColorWhite),
9  m_visible(true)
10 {
11 }
12 
13 
14 void AppCell::drawRect(KDContext * ctx, KDRect rect) const {
15  KDSize nameSize = m_nameView.minimalSizeForOptimalDisplay();
16  ctx->fillRect(KDRect(0, bounds().height()-nameSize.height() - 2*k_nameHeightMargin, bounds().width(), nameSize.height()+2*k_nameHeightMargin), KDColorWhite);
17 }
18 
20  return m_visible ? 2 : 0;
21 }
22 
24  View * views[] = {&m_iconView, &m_nameView};
25  return views[index];
26 }
27 
29  m_iconView.setFrame(KDRect((bounds().width()-k_iconWidth)/2, k_iconMargin, k_iconWidth,k_iconHeight));
30  KDSize nameSize = m_nameView.minimalSizeForOptimalDisplay();
31  m_nameView.setFrame(KDRect((bounds().width()-nameSize.width())/2-k_nameWidthMargin, bounds().height()-nameSize.height() - 2*k_nameHeightMargin, nameSize.width()+2*k_nameWidthMargin, nameSize.height()+2*k_nameHeightMargin));
32 }
33 
35  m_iconView.setImage(descriptor->icon());
36  m_nameView.setMessage(descriptor->name());
38 }
39 
40 void AppCell::setVisible(bool visible) {
41  if (m_visible != visible) {
42  m_visible = visible;
44  }
45 }
46 
51 }
52 
53 }
static constexpr KDColor YellowDark
Definition: palette.h:8
Definition: i18n.h:6
void setFrame(KDRect frame)
Definition: view.cpp:125
int numberOfSubviews() const override
Definition: app_cell.cpp:19
void drawRect(KDContext *ctx, KDRect rect) const override
Definition: app_cell.cpp:14
constexpr KDCoordinate width() const
Definition: size.h:10
void markRectAsDirty(KDRect rect)
Definition: view.cpp:39
View * subviewAtIndex(int index) override
Definition: app_cell.cpp:23
Definition: text.h:8
Definition: size.h:6
constexpr KDColor KDColorWhite
Definition: color.h:42
void reloadCell() override
Definition: app_cell.cpp:47
I18n::Message name() override
Definition: app.cpp:11
Definition: app.cpp:9
void setMessage(I18n::Message message)
KDSize minimalSizeForOptimalDisplay() const override
constexpr KDColor KDColorBlack
Definition: color.h:41
void layoutSubviews() override
Definition: app_cell.cpp:28
bool isHighlighted() const
void setImage(const Image *image)
Definition: image_view.cpp:21
virtual const Image * icon()
Definition: app.cpp:15
Definition: rect.h:26
void fillRect(KDRect rect, KDColor color)
Definition: context_rect.cpp:8
void setVisible(bool visible)
Definition: app_cell.cpp:40
Definition: view.h:23
KDCoordinate width() const
Definition: rect.h:39
void setTextColor(KDColor textColor)
Definition: text_view.cpp:19
void setAppDescriptor(::App::Descriptor *appDescriptor)
Definition: app_cell.cpp:34
virtual void reloadCell()
void setBackgroundColor(KDColor backgroundColor)
Definition: text_view.cpp:14
KDCoordinate height() const
Definition: rect.h:40
KDRect bounds() const
Definition: view.cpp:157
#define true
Definition: stdbool.h:8
constexpr KDCoordinate height() const
Definition: size.h:11