mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/home] Access to SelectableTableViewDataSource directly from App
This commit is contained in:
committed by
EmilieNumworks
parent
0702212cfe
commit
bcf2fda882
@@ -19,11 +19,18 @@ public:
|
||||
App * unpack(Container * container) override;
|
||||
Descriptor * descriptor() override;
|
||||
};
|
||||
Snapshot * snapshot() const {
|
||||
return static_cast<Snapshot *>(::App::snapshot());
|
||||
}
|
||||
private:
|
||||
App(Snapshot * snapshot);
|
||||
Controller m_controller;
|
||||
};
|
||||
|
||||
inline App * app() {
|
||||
return static_cast<App *>(::app());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "controller.h"
|
||||
#include "app.h"
|
||||
#include "../apps_container.h"
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -49,15 +50,14 @@ void Controller::ContentView::layoutSubviews() {
|
||||
|
||||
Controller::Controller(Responder * parentResponder, SelectableTableViewDataSource * selectionDataSource) :
|
||||
ViewController(parentResponder),
|
||||
m_view(this, selectionDataSource),
|
||||
m_selectionDataSource(selectionDataSource)
|
||||
m_view(this, selectionDataSource)
|
||||
{
|
||||
}
|
||||
|
||||
bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
AppsContainer * container = AppsContainer::sharedAppsContainer();
|
||||
bool switched = container->switchTo(container->appSnapshotAtIndex(m_selectionDataSource->selectedRow()*k_numberOfColumns+m_selectionDataSource->selectedColumn()+1));
|
||||
bool switched = container->switchTo(container->appSnapshotAtIndex(selectionDataSource()->selectedRow()*k_numberOfColumns+selectionDataSource()->selectedColumn()+1));
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
return true;
|
||||
@@ -67,11 +67,11 @@ bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
return m_view.selectableTableView()->selectCellAtLocation(0,0);
|
||||
}
|
||||
|
||||
if (event == Ion::Events::Right && m_selectionDataSource->selectedRow() < numberOfRows()) {
|
||||
return m_view.selectableTableView()->selectCellAtLocation(0, m_selectionDataSource->selectedRow()+1);
|
||||
if (event == Ion::Events::Right && selectionDataSource()->selectedRow() < numberOfRows()) {
|
||||
return m_view.selectableTableView()->selectCellAtLocation(0, selectionDataSource()->selectedRow()+1);
|
||||
}
|
||||
if (event == Ion::Events::Left && m_selectionDataSource->selectedRow() > 0) {
|
||||
return m_view.selectableTableView()->selectCellAtLocation(numberOfColumns()-1, m_selectionDataSource->selectedRow()-1);
|
||||
if (event == Ion::Events::Left && selectionDataSource()->selectedRow() > 0) {
|
||||
return m_view.selectableTableView()->selectCellAtLocation(numberOfColumns()-1, selectionDataSource()->selectedRow()-1);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -158,4 +158,8 @@ void Controller::tableViewDidChangeSelection(SelectableTableView * t, int previo
|
||||
}
|
||||
}
|
||||
|
||||
SelectableTableViewDataSource * Controller::selectionDataSource() const {
|
||||
return app()->snapshot();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) override;
|
||||
private:
|
||||
int numberOfIcons();
|
||||
SelectableTableViewDataSource * selectionDataSource() const;
|
||||
class ContentView : public View {
|
||||
public:
|
||||
ContentView(Controller * controller, SelectableTableViewDataSource * selectionDataSource);
|
||||
@@ -47,7 +48,6 @@ private:
|
||||
static constexpr int k_cellWidth = 104;
|
||||
ContentView m_view;
|
||||
AppCell m_cells[k_maxNumberOfCells];
|
||||
SelectableTableViewDataSource * m_selectionDataSource;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user