Files
Upsilon/apps/title_bar_view.cpp
Émilie Feral ad95a693da [escher] In palette, change name: YellowOne/Two -> YellowDark/Light
Change-Id: I0eba4914f7b4f9f78d7797d47fb893bd66ece454
2017-01-27 12:03:38 +01:00

41 lines
1007 B
C++

#include "title_bar_view.h"
extern "C" {
#include <assert.h>
}
TitleBarView::TitleBarView() :
View(),
m_titleView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorWhite, Palette::YellowDark)
{
}
void TitleBarView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::YellowDark);
}
void TitleBarView::setTitle(const char * title) {
m_titleView.setText(title);
}
void TitleBarView::setChargeState(Ion::Battery::Charge chargeState) {
m_batteryView.setChargeState(chargeState);
}
int TitleBarView::numberOfSubviews() const {
return 2;
}
View * TitleBarView::subviewAtIndex(int index) {
if (index == 0) {
return &m_titleView;
}
return &m_batteryView;
}
void TitleBarView::layoutSubviews() {
m_titleView.setFrame(bounds());
KDSize batterySize = m_batteryView.minimalSizeForOptimalDisplay();
m_batteryView.setFrame(KDRect(bounds().width() - batterySize.width() - k_batteryLeftMargin, (bounds().height()- batterySize.height())/2, batterySize));
}