mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/home] Make the snapshot selectable table view data source
Change-Id: If10a7d856a99be3f52d83a37cb91dcfd239b7294
This commit is contained in:
@@ -27,7 +27,7 @@ App::Descriptor * App::Snapshot::descriptor() {
|
||||
|
||||
App::App(Container * container, Snapshot * snapshot) :
|
||||
::App(container, snapshot, &m_controller, I18n::Message::Warning),
|
||||
m_controller(&m_modalViewController, (AppsContainer *)container)
|
||||
m_controller(&m_modalViewController, (AppsContainer *)container, snapshot)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
I18n::Message name() override;
|
||||
I18n::Message upperName() override;
|
||||
};
|
||||
class Snapshot : public ::App::Snapshot {
|
||||
class Snapshot : public ::App::Snapshot, public SelectableTableViewDataSource {
|
||||
public:
|
||||
App * unpack(Container * container) override;
|
||||
Descriptor * descriptor() override;
|
||||
|
||||
@@ -6,8 +6,8 @@ extern "C" {
|
||||
|
||||
namespace Home {
|
||||
|
||||
Controller::ContentView::ContentView(Controller * controller) :
|
||||
m_selectableTableView(controller, controller, 0, 0, 0, k_sideMargin, 0, k_sideMargin, controller, controller, true, false,
|
||||
Controller::ContentView::ContentView(Controller * controller, SelectableTableViewDataSource * selectionDataSource) :
|
||||
m_selectableTableView(controller, controller, 0, 0, 0, k_sideMargin, 0, k_sideMargin, selectionDataSource, controller, true, false,
|
||||
KDColorBlack, k_indicatorThickness, Palette::GreyDark, Palette::GreyMiddle, k_indicatorMargin)
|
||||
{
|
||||
}
|
||||
@@ -38,26 +38,27 @@ void Controller::ContentView::layoutSubviews() {
|
||||
m_selectableTableView.setFrame(bounds());
|
||||
}
|
||||
|
||||
Controller::Controller(Responder * parentResponder, ::AppsContainer * container) :
|
||||
Controller::Controller(Responder * parentResponder, ::AppsContainer * container, SelectableTableViewDataSource * selectionDataSource) :
|
||||
ViewController(parentResponder),
|
||||
m_container(container),
|
||||
m_view(ContentView(this))
|
||||
m_view(ContentView(this, selectionDataSource)),
|
||||
m_selectionDataSource(selectionDataSource)
|
||||
{
|
||||
}
|
||||
|
||||
bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
m_container->switchTo(m_container->appSnapshotAtIndex(selectedRow()*k_numberOfColumns+selectedColumn()+1));
|
||||
m_container->switchTo(m_container->appSnapshotAtIndex(m_selectionDataSource->selectedRow()*k_numberOfColumns+m_selectionDataSource->selectedColumn()+1));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Controller::didBecomeFirstResponder() {
|
||||
if (selectedRow() == -1) {
|
||||
selectCellAtLocation(0, 0);
|
||||
if (m_selectionDataSource->selectedRow() == -1) {
|
||||
m_selectionDataSource->selectCellAtLocation(0, 0);
|
||||
} else {
|
||||
selectCellAtLocation(selectedColumn(), selectedRow());
|
||||
m_selectionDataSource->selectCellAtLocation(m_selectionDataSource->selectedColumn(), m_selectionDataSource->selectedRow());
|
||||
}
|
||||
app()->setFirstResponder(m_view.selectableTableView());
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ class AppsContainer;
|
||||
|
||||
namespace Home {
|
||||
|
||||
class Controller : public ViewController, public SimpleTableViewDataSource, public SelectableTableViewDataSource, public SelectableTableViewDelegate {
|
||||
class Controller : public ViewController, public SimpleTableViewDataSource, public SelectableTableViewDelegate {
|
||||
public:
|
||||
Controller(Responder * parentResponder, ::AppsContainer * container);
|
||||
Controller(Responder * parentResponder, ::AppsContainer * container, SelectableTableViewDataSource * selectionDataSource);
|
||||
|
||||
View * view() override;
|
||||
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
int numberOfIcons();
|
||||
class ContentView : public View {
|
||||
public:
|
||||
ContentView(Controller * controller);
|
||||
ContentView(Controller * controller, SelectableTableViewDataSource * selectionDataSource);
|
||||
SelectableTableView * selectableTableView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void reloadBottomRightCorner(SimpleTableViewDataSource * dataSource);
|
||||
@@ -51,6 +51,7 @@ 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