mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] Create a specific table view for calculation which
aligns to the bottom Change-Id: I4fe9763b1d9ae2ae3e898046221b780c51515830
This commit is contained in:
@@ -2,6 +2,7 @@ app_objs += $(addprefix apps/calculation/,\
|
||||
app.o\
|
||||
calculation.o\
|
||||
calculation_store.o\
|
||||
selectable_table_view.o\
|
||||
history_view_cell.o\
|
||||
history_controller.o\
|
||||
edit_expression_controller.o\
|
||||
|
||||
26
apps/calculation/selectable_table_view.cpp
Normal file
26
apps/calculation/selectable_table_view.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "selectable_table_view.h"
|
||||
|
||||
namespace Calculation {
|
||||
|
||||
CalculationSelectableTableView::CalculationSelectableTableView(Responder * parentResponder, TableViewDataSource * dataSource,
|
||||
SelectableTableViewDelegate * delegate) :
|
||||
::SelectableTableView(parentResponder, dataSource, 0, 0, 0, 0, delegate)
|
||||
{
|
||||
}
|
||||
|
||||
void CalculationSelectableTableView::scrollToCell(int i, int j) {
|
||||
::SelectableTableView::scrollToCell(i, j);
|
||||
if (m_contentView.bounds().height() < bounds().height()) {
|
||||
m_topMargin = bounds().height() - m_contentView.bounds().height();
|
||||
} else {
|
||||
m_topMargin = 0;
|
||||
}
|
||||
ScrollView::layoutSubviews();
|
||||
if (m_contentView.bounds().height() - contentOffset().y() < bounds().height()) {
|
||||
KDCoordinate contentOffsetX = contentOffset().x();
|
||||
KDCoordinate contentOffsetY = dataSource()->cumulatedHeightFromIndex(dataSource()->numberOfRows()) - maxContentHeightDisplayableWithoutScrolling();
|
||||
setContentOffset(KDPoint(contentOffsetX, contentOffsetY));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
17
apps/calculation/selectable_table_view.h
Normal file
17
apps/calculation/selectable_table_view.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef CALCULATION_SELECTABLE_TABLE_VIEW_H
|
||||
#define CALCULATION_SELECTABLE_TABLE_VIEW_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
namespace Calculation {
|
||||
|
||||
class CalculationSelectableTableView : public ::SelectableTableView {
|
||||
public:
|
||||
CalculationSelectableTableView(Responder * parentResponder, TableViewDataSource * dataSource,
|
||||
SelectableTableViewDelegate * delegate = nullptr);
|
||||
void scrollToCell(int i, int j) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,7 @@ protected:
|
||||
KDCoordinate maxContentHeightDisplayableWithoutScrolling();
|
||||
void layoutSubviews() override;
|
||||
void updateScrollIndicator();
|
||||
KDCoordinate m_topMargin;
|
||||
#if ESCHER_VIEW_LOGGING
|
||||
virtual const char * className() const override;
|
||||
virtual void logAttributes(std::ostream &os) const override;
|
||||
@@ -34,7 +35,6 @@ private:
|
||||
ScrollViewIndicator m_horizontalScrollIndicator;
|
||||
bool hasVerticalIndicator() const;
|
||||
bool hasHorizontalIndicator() const;
|
||||
KDCoordinate m_topMargin;
|
||||
KDCoordinate m_rightMargin;
|
||||
KDCoordinate m_bottomMargin;
|
||||
KDCoordinate m_leftMargin;
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
TableView(TableViewDataSource * dataSource, KDCoordinate topMargin = 0,
|
||||
KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0);
|
||||
|
||||
void scrollToCell(int i, int j);
|
||||
virtual void scrollToCell(int i, int j);
|
||||
TableViewCell * cellAtLocation(int i, int j);
|
||||
void reloadData();
|
||||
KDSize size() const;
|
||||
@@ -19,7 +19,6 @@ protected:
|
||||
const char * className() const override;
|
||||
#endif
|
||||
TableViewDataSource * dataSource();
|
||||
private:
|
||||
class ContentView : public View {
|
||||
public:
|
||||
ContentView(TableView * tableView, TableViewDataSource * dataSource);
|
||||
@@ -65,10 +64,9 @@ private:
|
||||
TableView * m_tableView;
|
||||
TableViewDataSource * m_dataSource;
|
||||
};
|
||||
|
||||
void layoutSubviews() override;
|
||||
|
||||
ContentView m_contentView;
|
||||
private:
|
||||
void layoutSubviews() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,11 +10,11 @@ constexpr KDCoordinate ScrollView::k_indicatorThickness;
|
||||
ScrollView::ScrollView(View * contentView, KDCoordinate topMargin, KDCoordinate rightMargin,
|
||||
KDCoordinate bottomMargin, KDCoordinate leftMargin, bool showIndicators) :
|
||||
View(),
|
||||
m_topMargin(topMargin),
|
||||
m_offset(KDPointZero),
|
||||
m_contentView(contentView),
|
||||
m_verticalScrollIndicator(ScrollViewIndicator(ScrollViewIndicator::Direction::Vertical)),
|
||||
m_horizontalScrollIndicator(ScrollViewIndicator(ScrollViewIndicator::Direction::Horizontal)),
|
||||
m_topMargin(topMargin),
|
||||
m_rightMargin(rightMargin),
|
||||
m_bottomMargin(bottomMargin),
|
||||
m_leftMargin(leftMargin),
|
||||
|
||||
Reference in New Issue
Block a user