mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/home] Display app name and icon
Change-Id: Ia09827dd1fa027cee80145c0d2dab5a29cd51d11
This commit is contained in:
@@ -11,3 +11,5 @@ app_objs += $(addprefix apps/graph/,\
|
||||
list/list_controller.o\
|
||||
list/parameter_controller.o\
|
||||
)
|
||||
|
||||
inline_images += apps/graph/graph_icon.png
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "graph_app.h"
|
||||
#include "graph_icon.h"
|
||||
|
||||
GraphApp::GraphApp() :
|
||||
App(),
|
||||
App("Graph", ImageStore::GraphIcon),
|
||||
m_functionStore(Graph::FunctionStore()),
|
||||
m_listController(ListController(nullptr, &m_functionStore)),
|
||||
m_listStackViewController(StackViewController(&m_tabViewController, &m_listController)),
|
||||
|
||||
BIN
apps/graph/graph_icon.png
Normal file
BIN
apps/graph/graph_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 459 B |
@@ -4,26 +4,47 @@
|
||||
namespace Home {
|
||||
|
||||
AppCell::AppCell() :
|
||||
ChildlessView(),
|
||||
View(),
|
||||
m_visible(true),
|
||||
m_active(false)
|
||||
{
|
||||
}
|
||||
|
||||
int AppCell::numberOfSubviews() const {
|
||||
return m_visible ? 2 : 0;
|
||||
}
|
||||
|
||||
View * AppCell::subviewAtIndex(int index) {
|
||||
View * views[] = {&m_iconView, &m_nameView};
|
||||
return views[index];
|
||||
}
|
||||
|
||||
void AppCell::layoutSubviews() {
|
||||
m_iconView.setFrame(KDRect(0,0,k_iconSize,k_iconSize));
|
||||
if (bounds().height() > k_iconSize) {
|
||||
m_nameView.setFrame(KDRect(0, k_iconSize, bounds().width(), bounds().height()-k_iconSize));
|
||||
}
|
||||
}
|
||||
|
||||
void AppCell::setApp(::App * app) {
|
||||
m_iconView.setImage(app->icon());
|
||||
m_nameView.setText(app->name());
|
||||
}
|
||||
|
||||
void AppCell::setVisible(bool visible) {
|
||||
if (m_visible != visible) {
|
||||
m_visible = visible;
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
}
|
||||
|
||||
void AppCell::setActive(bool active) {
|
||||
if (m_active != active) {
|
||||
m_active = active;
|
||||
m_nameView.setBackgroundColor(m_active ? KDColorRed : KDColorWhite);
|
||||
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
}
|
||||
|
||||
void AppCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDColor c = m_active ? KDColorRed : KDColorBlack;
|
||||
ctx->fillRect(KDRect(0,0, 20, 20), c);
|
||||
/*
|
||||
KDColor * pixels = (KDColor *)apps_picview_image_raw;
|
||||
assert(apps_picview_image_raw_len == bounds().width() * bounds().height() * sizeof(KDColor));
|
||||
ctx->fillRectWithPixels(bounds(), pixels, nullptr);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,12 +5,22 @@
|
||||
|
||||
namespace Home {
|
||||
|
||||
class AppCell : public ChildlessView {
|
||||
class AppCell : public View {
|
||||
public:
|
||||
AppCell();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
|
||||
void setVisible(bool visible);
|
||||
void setActive(bool active);
|
||||
void setApp(::App * app);
|
||||
private:
|
||||
static constexpr KDCoordinate k_iconSize = 32;
|
||||
ImageView m_iconView;
|
||||
TextView m_nameView;
|
||||
bool m_visible;
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
|
||||
@@ -77,6 +77,18 @@ int Controller::reusableCellCount() {
|
||||
return k_maxNumberOfCells;
|
||||
}
|
||||
|
||||
void Controller::willDisplayCellAtLocation(View * cell, int i, int j) {
|
||||
AppCell * appCell = (AppCell *)cell;
|
||||
int appIndex = (j*k_numberOfColumns+i)+1;
|
||||
if (appIndex >= m_container->numberOfApps()) {
|
||||
appCell->setVisible(false);
|
||||
} else {
|
||||
appCell->setVisible(true);
|
||||
::App * app = m_container->appAtIndex((j*k_numberOfColumns+i)+1);
|
||||
appCell->setApp(app);
|
||||
}
|
||||
}
|
||||
|
||||
int Controller::numberOfIcons() {
|
||||
assert(m_container->numberOfApps() > 0);
|
||||
return m_container->numberOfApps() - 1;
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
virtual KDCoordinate cellWidth() override;
|
||||
virtual View * reusableCell(int index) override;
|
||||
virtual int reusableCellCount() override;
|
||||
void willDisplayCellAtLocation(View * cell, int i, int j) override;
|
||||
private:
|
||||
int numberOfIcons();
|
||||
void setActiveIndex(int index);
|
||||
|
||||
@@ -3,3 +3,5 @@ app_objs += $(addprefix apps/probability/,\
|
||||
law/law_controller.o\
|
||||
parameters/parameters_controller.o\
|
||||
)
|
||||
|
||||
inline_images += apps/probability/probability_icon.png
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "app.h"
|
||||
#include "probability_icon.h"
|
||||
|
||||
Probability::App::App() :
|
||||
::App(),
|
||||
::App("Probability", ImageStore::ProbabilityIcon),
|
||||
m_lawController(LawController(nullptr)),
|
||||
m_parametersController(ParametersController(nullptr)),
|
||||
m_stackViewController(this, &m_lawController, true)
|
||||
|
||||
BIN
apps/probability/probability_icon.png
Normal file
BIN
apps/probability/probability_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 440 B |
Reference in New Issue
Block a user