[Feature] Contributors Controller in the Omega App (WIP)

This commit is contained in:
Quentin
2020-04-07 13:08:31 +02:00
parent 1c00373348
commit d6d235f273
8 changed files with 218 additions and 4 deletions

View File

@@ -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

View 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();
}
}

View 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

View 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);
}
}

View 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

View File

@@ -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();
}
}

View File

@@ -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;
};
}

View File

@@ -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