mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[Feature] Contributors Controller in the Omega App (WIP)
This commit is contained in:
@@ -5,6 +5,8 @@ app_src += $(addprefix apps/omega/,\
|
||||
app.cpp \
|
||||
omega_controller.cpp \
|
||||
omega_view.cpp \
|
||||
contributors_controller.cpp \
|
||||
contributors_view.cpp \
|
||||
)
|
||||
|
||||
app_images += apps/omega/omega_icon.png
|
||||
|
||||
110
apps/omega/contributors_controller.cpp
Normal file
110
apps/omega/contributors_controller.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#include "contributors_controller.h"
|
||||
#include <assert.h>
|
||||
#include "apps/i18n.h"
|
||||
|
||||
// using namespace Shared;
|
||||
|
||||
namespace Omega {
|
||||
|
||||
// constexpr SettingsMessageTree s_contributorsChildren[17] = {
|
||||
// SettingsMessageTree(I18n::Message::Developers),
|
||||
// SettingsMessageTree(I18n::Message::QuentinGuidee),
|
||||
// SettingsMessageTree(I18n::Message::DannySimmons),
|
||||
// SettingsMessageTree(I18n::Message::JoachimLeFournis),
|
||||
// SettingsMessageTree(I18n::Message::JeanBaptisteBoric),
|
||||
// SettingsMessageTree(I18n::Message::MaximeFriess),
|
||||
// SettingsMessageTree(I18n::Message::David),
|
||||
// SettingsMessageTree(I18n::Message::DamienNicolet),
|
||||
// SettingsMessageTree(I18n::Message::EvannDreumont),
|
||||
// SettingsMessageTree(I18n::Message::SzaboLevente),
|
||||
// SettingsMessageTree(I18n::Message::VenceslasDuet),
|
||||
// SettingsMessageTree(I18n::Message::CharlotteThomas),
|
||||
// SettingsMessageTree(I18n::Message::BetaTesters),
|
||||
// SettingsMessageTree(I18n::Message::CyprienMejat),
|
||||
// SettingsMessageTree(I18n::Message::TimeoArnouts),
|
||||
// SettingsMessageTree(I18n::Message::LouisC),
|
||||
// SettingsMessageTree(I18n::Message::LelahelHideux)
|
||||
// };
|
||||
|
||||
ContributorsController::ContributorsController(Responder * parentResponder) :
|
||||
ViewController(parentResponder),
|
||||
SelectableTableViewDataSource(),
|
||||
m_contributorsView(&m_selectableTableView),
|
||||
m_contributorCell(),
|
||||
m_selectableTableView(this)
|
||||
{
|
||||
}
|
||||
|
||||
View * ContributorsController::view() {
|
||||
return &m_contributorsView;
|
||||
}
|
||||
|
||||
const char * ContributorsController::title() {
|
||||
return "Contributors";
|
||||
}
|
||||
|
||||
void ContributorsController::didBecomeFirstResponder() {
|
||||
if (selectedRow() < 0) {
|
||||
selectCellAtLocation(0, 0);
|
||||
}
|
||||
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||
}
|
||||
|
||||
void ContributorsController::viewWillAppear() {
|
||||
ViewController::viewWillAppear();
|
||||
m_selectableTableView.reloadData();
|
||||
}
|
||||
|
||||
bool ContributorsController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::Left) {
|
||||
stackController()->pop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int ContributorsController::numberOfRows() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
KDCoordinate ContributorsController::rowHeight(int j) {
|
||||
return Metric::ParameterCellHeight;
|
||||
}
|
||||
|
||||
KDCoordinate ContributorsController::cumulatedHeightFromIndex(int j) {
|
||||
return rowHeight(0) * j;
|
||||
}
|
||||
|
||||
int ContributorsController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
KDCoordinate height = rowHeight(0);
|
||||
if (height == 0) {
|
||||
return 0;
|
||||
}
|
||||
return (offsetY - 1) / height;
|
||||
}
|
||||
|
||||
HighlightCell * ContributorsController::reusableCell(int index, int type) {
|
||||
assert(index >= 0 && index <= k_numberOfCells);
|
||||
return &m_contributorCell;
|
||||
}
|
||||
|
||||
int ContributorsController::reusableCellCount(int type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ContributorsController::typeAtLocation(int i, int j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ContributorsController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
MessageTableCell * myCell = (MessageTableCell *)cell;
|
||||
//I18n::Message titles[1] = {I18n::Message::OmegaContributors};
|
||||
//myCell->setMessage(titles[index]);
|
||||
myCell->setMessage(I18n::Message::QuentinGuidee);
|
||||
}
|
||||
|
||||
StackViewController * ContributorsController::stackController() const {
|
||||
return (StackViewController *)parentResponder();
|
||||
}
|
||||
|
||||
}
|
||||
38
apps/omega/contributors_controller.h
Normal file
38
apps/omega/contributors_controller.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef APPS_OMEGA_CONTRIBUTORS_CONTROLLER_H
|
||||
#define APPS_OMEGA_CONTRIBUTORS_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "contributors_view.h"
|
||||
// #include <apps/shared/settings_message_tree.h>
|
||||
|
||||
namespace Omega {
|
||||
|
||||
class ContributorsController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource, public SelectableTableViewDelegate {
|
||||
public:
|
||||
ContributorsController(Responder * parentResponder);
|
||||
const char * title() override;
|
||||
View * view() override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void didBecomeFirstResponder() override;
|
||||
void viewWillAppear() override;
|
||||
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override;
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override;
|
||||
virtual int numberOfRows() const override;
|
||||
virtual KDCoordinate rowHeight(int j) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
private:
|
||||
StackViewController * stackController() const;
|
||||
virtual int initialSelectedRow() const { return 0; }
|
||||
constexpr static int k_numberOfCells = 1;
|
||||
ContributorsView m_contributorsView;
|
||||
MessageTableCell m_contributorCell;
|
||||
SelectableTableView m_selectableTableView;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
33
apps/omega/contributors_view.cpp
Normal file
33
apps/omega/contributors_view.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "contributors_view.h"
|
||||
#include "apps/i18n.h"
|
||||
|
||||
namespace Omega {
|
||||
|
||||
ContributorsView::ContributorsView(SelectableTableView * selectableTableView) :
|
||||
View(),
|
||||
m_selectableTableView(selectableTableView)
|
||||
{
|
||||
}
|
||||
|
||||
void ContributorsView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(KDRect(0, 0, bounds().width(), bounds().height()), Palette::BackgroundApps);
|
||||
}
|
||||
|
||||
void ContributorsView::reload() {
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
int ContributorsView::numberOfSubviews() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
View * ContributorsView::subviewAtIndex(int index) {
|
||||
assert(index == 0 || index == 1);
|
||||
return m_selectableTableView;
|
||||
}
|
||||
|
||||
void ContributorsView::layoutSubviews(bool force) {
|
||||
m_selectableTableView->setFrame(KDRect(0, 0, bounds().width(), bounds().height()), force);
|
||||
}
|
||||
|
||||
}
|
||||
22
apps/omega/contributors_view.h
Normal file
22
apps/omega/contributors_view.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef APPS_OMEGA_CONTRIBUTORS_VIEW_H
|
||||
#define APPS_OMEGA_CONTRIBUTORS_VIEW_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
namespace Omega {
|
||||
|
||||
class ContributorsView : public View {
|
||||
public:
|
||||
ContributorsView(SelectableTableView * selectableTableView);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void reload();
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
private:
|
||||
void layoutSubviews(bool force = false) override;
|
||||
SelectableTableView * m_selectableTableView;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,7 +10,8 @@ OmegaController::OmegaController(Responder * parentResponder) :
|
||||
m_omegaView(&m_selectableTableView),
|
||||
m_selectableTableView(this),
|
||||
m_contributorsCell(),
|
||||
m_versionCell()
|
||||
m_versionCell(),
|
||||
m_contributorsController(this)
|
||||
{
|
||||
m_contributorsCell.setMessageFont(KDFont::LargeFont);
|
||||
m_versionCell.setMessageFont(KDFont::LargeFont);
|
||||
@@ -31,8 +32,8 @@ void OmegaController::didBecomeFirstResponder() {
|
||||
|
||||
bool OmegaController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||
StackViewController * stack = (StackViewController *)parentResponder();
|
||||
// stack->push(&m_contributorsController, Palette::BannerFirstText, Palette::BannerFirstBackground, Palette::BannerFirstBorder);
|
||||
//StackViewController * stack = (StackViewController *)parentResponder();
|
||||
stackController()->push(&m_contributorsController, Palette::BannerFirstText, Palette::BannerFirstBackground, Palette::BannerFirstBorder);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -71,4 +72,8 @@ void OmegaController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
myCell->setMessage(titles[index]);
|
||||
}
|
||||
|
||||
StackViewController * OmegaController::stackController() const {
|
||||
return (StackViewController *)parentResponder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <escher.h>
|
||||
#include "omega_view.h"
|
||||
#include "contributors_controller.h"
|
||||
|
||||
namespace Omega {
|
||||
|
||||
@@ -20,11 +21,13 @@ public:
|
||||
int typeAtLocation(int i, int j) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
private:
|
||||
StackViewController * stackController() const;
|
||||
constexpr static int k_numberOfCells = 2;
|
||||
OmegaView m_omegaView;
|
||||
SelectableTableView m_selectableTableView;
|
||||
MessageTableCellWithChevron m_contributorsCell;
|
||||
MessageTableCellWithBuffer m_versionCell;
|
||||
ContributorsController m_contributorsController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ include build/platform.$(PLATFORM).mak
|
||||
EPSILON_VERSION ?= 13.1.0
|
||||
OMEGA_VERSION ?= 1.20.0
|
||||
# USERNAME ?= N/A
|
||||
EPSILON_APPS ?= calculation rpn graph code statistics probability solver atom sequence regression settings external omega
|
||||
# EPSILON_APPS ?= calculation rpn graph code statistics probability solver atom sequence regression settings external omega
|
||||
EPSILON_APPS ?= omega
|
||||
EPSILON_I18N ?= en fr es de pt hu
|
||||
# EPSILON_I18N ?= en fr es de pt hu
|
||||
EPSILON_GETOPT ?= 0
|
||||
|
||||
Reference in New Issue
Block a user