mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps] Improve title bar view layout
Change-Id: I67e714cc94fd100270cf5488602de1fd5cfce27e
This commit is contained in:
@@ -16,6 +16,12 @@ TitleBarView::TitleBarView() :
|
||||
m_examModeIconView.setImage(ImageStore::ExamIcon);
|
||||
}
|
||||
|
||||
void TitleBarView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* As we cheated to layout the title view, we have to fill a very thin
|
||||
* rectangle at the top with the background color. */
|
||||
ctx->fillRect(KDRect(0, 0, bounds().width(), 2), Palette::YellowDark);
|
||||
}
|
||||
|
||||
void TitleBarView::setTitle(I18n::Message title) {
|
||||
m_titleView.setMessage(title);
|
||||
}
|
||||
@@ -46,8 +52,13 @@ View * TitleBarView::subviewAtIndex(int index) {
|
||||
}
|
||||
|
||||
void TitleBarView::layoutSubviews() {
|
||||
m_titleView.setFrame(bounds());
|
||||
m_preferenceView.setFrame(KDRect(0, 0, m_preferenceView.minimalSizeForOptimalDisplay()));
|
||||
/* We here cheat to layout the main title. The application title is written
|
||||
* with upper cases. But, as upper letters are on the same baseline as lower
|
||||
* letters, they seem to be slightly above when they are perferctly centered
|
||||
* (because their glyph never cross the baseline). To avoid this effect, we
|
||||
* translate the frame of the title downwards.*/
|
||||
m_titleView.setFrame(KDRect(0, 2, bounds().width(), bounds().height()-2));
|
||||
m_preferenceView.setFrame(KDRect(k_preferenceMargin, 0, m_preferenceView.minimalSizeForOptimalDisplay().width(), bounds().height()));
|
||||
KDSize batterySize = m_batteryView.minimalSizeForOptimalDisplay();
|
||||
m_batteryView.setFrame(KDRect(bounds().width() - batterySize.width() - k_batteryLeftMargin, (bounds().height()- batterySize.height())/2, batterySize));
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
class TitleBarView : public View {
|
||||
public:
|
||||
TitleBarView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void setTitle(I18n::Message title);
|
||||
bool setChargeState(Ion::Battery::Charge chargeState);
|
||||
bool setIsCharging(bool isCharging);
|
||||
void refreshPreferences();
|
||||
private:
|
||||
constexpr static KDCoordinate k_batteryLeftMargin = 5;
|
||||
constexpr static KDCoordinate k_preferenceMargin = 3;
|
||||
constexpr static KDCoordinate k_examIconWidth = 18;
|
||||
constexpr static KDCoordinate k_examIconHeight = 9;
|
||||
constexpr static KDCoordinate k_examIconMargin = 93;
|
||||
|
||||
Reference in New Issue
Block a user