mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/stats] Give bigger frame the box view that display axis
This commit is contained in:
@@ -31,12 +31,23 @@ int MultipleBoxesView::seriesOfSubviewAtIndex(int index) {
|
||||
return static_cast<BoxView *>(subviewAtIndex(index))->series();
|
||||
}
|
||||
|
||||
void MultipleBoxesView::layoutSubviews() {
|
||||
MultipleDataView::layoutSubviews();
|
||||
int numberOfDataSubviews = numberOfSubviews() - 1;
|
||||
void MultipleBoxesView::layoutDataSubviews() {
|
||||
int numberOfDataSubviews = m_store->numberOfNonEmptySeries();
|
||||
assert(numberOfDataSubviews > 0);
|
||||
for (int i = 0; i < numberOfDataSubviews; i++) {
|
||||
static_cast<BoxView *>(subviewAtIndex(i))->setDisplayAxis(i == numberOfDataSubviews - 1);
|
||||
KDCoordinate bannerHeight = bannerFrame().height();
|
||||
KDCoordinate axisHeight = 30;
|
||||
KDCoordinate subviewHeight = (bounds().height() - bannerHeight - axisHeight)/numberOfDataSubviews;
|
||||
int displayedSubviewIndex = 0;
|
||||
for (int i = 0; i < Store::k_numberOfSeries; i++) {
|
||||
if (!m_store->seriesIsEmpty(i)) {
|
||||
BoxView * boxView = dataViewAtIndex(i);
|
||||
bool displaysAxis = displayedSubviewIndex == numberOfDataSubviews - 1;
|
||||
boxView->setDisplayAxis(displaysAxis);
|
||||
KDCoordinate currentSubviewHeight = subviewHeight + (displaysAxis ? axisHeight : 0);
|
||||
KDRect frame = KDRect(0, displayedSubviewIndex*subviewHeight, bounds().width(), currentSubviewHeight);
|
||||
boxView->setFrame(frame);
|
||||
displayedSubviewIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
int seriesOfSubviewAtIndex(int index) override;
|
||||
const BoxBannerView * bannerView() const override { return &m_bannerView; }
|
||||
BoxView * dataViewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
void layoutDataSubviews() override;
|
||||
private:
|
||||
BoxView m_boxView1;
|
||||
BoxView m_boxView2;
|
||||
|
||||
@@ -36,24 +36,12 @@ void MultipleDataView::deselectDataView(int index) {
|
||||
changeDataViewSelection(index, false);
|
||||
}
|
||||
|
||||
void MultipleDataView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
if (!m_displayBanner) {
|
||||
ctx->fillRect(bannerFrame(), KDColorWhite);
|
||||
}
|
||||
}
|
||||
|
||||
int MultipleDataView::numberOfSubviews() const {
|
||||
int result = m_store->numberOfNonEmptySeries();
|
||||
assert(result <= Store::k_numberOfSeries);
|
||||
return result + 1; // +1 for the banner view
|
||||
}
|
||||
|
||||
KDRect MultipleDataView::bannerFrame() const {
|
||||
KDCoordinate bannerHeight = bannerView()->minimalSizeForOptimalDisplay().height();
|
||||
KDRect frame = KDRect(0, bounds().height() - bannerHeight, bounds().width(), bannerHeight);
|
||||
return frame;
|
||||
}
|
||||
|
||||
View * MultipleDataView::subviewAtIndex(int index) {
|
||||
if (index == numberOfSubviews() -1) {
|
||||
return editableBannerView();
|
||||
@@ -74,6 +62,11 @@ View * MultipleDataView::subviewAtIndex(int index) {
|
||||
}
|
||||
|
||||
void MultipleDataView::layoutSubviews() {
|
||||
layoutDataSubviews();
|
||||
layoutBanner();
|
||||
}
|
||||
|
||||
void MultipleDataView::layoutDataSubviews() {
|
||||
int numberDataSubviews = m_store->numberOfNonEmptySeries();
|
||||
assert(numberDataSubviews > 0);
|
||||
KDCoordinate bannerHeight = bannerFrame().height();
|
||||
@@ -87,6 +80,20 @@ void MultipleDataView::layoutSubviews() {
|
||||
displayedSubviewIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleDataView::changeDataViewSelection(int index, bool select) {
|
||||
dataViewAtIndex(index)->selectMainView(select);
|
||||
}
|
||||
|
||||
KDRect MultipleDataView::bannerFrame() const {
|
||||
KDCoordinate bannerHeight = bannerView()->minimalSizeForOptimalDisplay().height();
|
||||
KDRect frame = KDRect(0, bounds().height() - bannerHeight, bounds().width(), bannerHeight);
|
||||
return frame;
|
||||
}
|
||||
|
||||
void MultipleDataView::layoutBanner() {
|
||||
KDCoordinate bannerHeight = bannerFrame().height();
|
||||
if (m_displayBanner) {
|
||||
editableBannerView()->setFrame(bannerFrame());
|
||||
} else {
|
||||
@@ -95,8 +102,10 @@ void MultipleDataView::layoutSubviews() {
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleDataView::changeDataViewSelection(int index, bool select) {
|
||||
dataViewAtIndex(index)->selectMainView(select);
|
||||
void MultipleDataView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
if (!m_displayBanner) {
|
||||
ctx->fillRect(bannerFrame(), KDColorWhite);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Statistics {
|
||||
class MultipleDataView : public View {
|
||||
public:
|
||||
MultipleDataView(Store * store) :
|
||||
m_displayBanner(false),
|
||||
m_store(store)
|
||||
m_store(store),
|
||||
m_displayBanner(false)
|
||||
{}
|
||||
// Data views
|
||||
void selectDataView(int index);
|
||||
@@ -33,13 +33,15 @@ public:
|
||||
protected:
|
||||
virtual const Shared::BannerView * bannerView() const = 0;
|
||||
void layoutSubviews() override;
|
||||
virtual void layoutDataSubviews();
|
||||
View * subviewAtIndex(int index) override;
|
||||
virtual void changeDataViewSelection(int index, bool select);
|
||||
private:
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
KDRect bannerFrame() const;
|
||||
bool m_displayBanner;
|
||||
Store * m_store;
|
||||
private:
|
||||
void layoutBanner();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
bool m_displayBanner;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user