M module-apps/windows/AppWindow.cpp => module-apps/windows/AppWindow.cpp +4 -2
@@ 50,8 50,10 @@ namespace gui
title->setEllipsis(Ellipsis::Right);
title->visible = false;
- auto config = configureTopBar(application->getTopBarConfiguration());
- topBar = new gui::top_bar::TopBar(this, 0, 0, 480, 50);
+ auto config = configureTopBar(application->getTopBarConfiguration());
+ namespace status_bar = style::header::status_bar;
+ topBar = new gui::top_bar::TopBar(
+ this, (style::window_width - status_bar::width) / 2, 0, status_bar::width, status_bar::height);
topBar->configure(std::move(config));
}
M module-gui/gui/widgets/Style.hpp => module-gui/gui/widgets/Style.hpp +6 -3
@@ 23,10 23,13 @@ namespace style
namespace header
{
inline constexpr auto height = 105U;
+ namespace status_bar
+ {
+ inline constexpr auto height = 46U;
+ inline constexpr auto width = 440U;
+ }; // namespace status_bar
namespace font
{
- inline constexpr auto time = "gt_pressura_regular_24";
- inline constexpr auto modes = "gt_pressura_regular_20";
inline constexpr auto title = "gt_pressura_bold_32";
}; // namespace font
}; // namespace header
@@ 92,7 95,7 @@ namespace style
inline constexpr auto h = 54U;
inline constexpr auto w = window_width;
} // namespace bottomBar
- }; // namespace window
+ }; // namespace window
namespace settings
{
M module-gui/gui/widgets/TopBar.cpp => module-gui/gui/widgets/TopBar.cpp +44 -28
@@ 5,9 5,10 @@
#include <iomanip>
#include "Label.hpp"
#include "Image.hpp"
+#include "BoxLayout.hpp"
#include "TopBar.hpp"
#include <time/time_conversion.hpp>
-#include "Style.hpp"
+#include "TopBar/Style.hpp"
#include "TopBar/BatteryBar.hpp"
#include "TopBar/BatteryText.hpp"
#include "TopBar/SignalStrengthBar.hpp"
@@ 21,22 22,13 @@
namespace gui::top_bar
{
+ using namespace style::header::status_bar;
+
constexpr auto batteryWidgetAsText = true;
using BatteryType = std::conditional<batteryWidgetAsText, BatteryText, BatteryBar>::type;
constexpr auto signalWidgetAsText = true;
using SignalType = std::conditional<signalWidgetAsText, SignalStrengthText, SignalStrengthBar>::type;
- namespace networkTechnology
- {
- constexpr uint32_t x = 100;
- constexpr uint32_t y = 21;
- constexpr uint32_t w = 130;
- constexpr uint32_t h = 20;
- } // namespace networkTechnology
-
- static constexpr uint32_t signalOffset = 20;
- static constexpr uint32_t batteryOffset = 413;
-
void Configuration::enable(Indicator indicator)
{
set(indicator, true);
@@ 79,14 71,12 @@ namespace gui::top_bar
return indicatorStatuses;
}
- TopBar::TopBar(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h) : Rect{parent, x, y, w, h}
+ TopBar::TopBar(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h) : HBox{parent, x, y, w, h}
{
prepareWidget();
- setFillColor(ColorFullWhite);
- setBorderColor(ColorNoColor);
- setFilled(true);
- setSize(480, 50);
+ setEdges(RectangleEdge::None);
+ setAlignment(Alignment(Alignment::Horizontal::Center));
updateDrawArea();
preBuildDrawListHook = [this](std::list<Command> &) { updateTime(); };
@@ 94,17 84,38 @@ namespace gui::top_bar
void TopBar::prepareWidget()
{
- battery = new BatteryType(this, batteryOffset, 15, 60, 24);
- signal = new SignalType(this, signalOffset, 17, 70, 24);
- const auto design_sim_offset = 376; // this offset is not final, but it is pixel Purefect
- sim = new SIM(this, design_sim_offset, 12);
-
- lock = new Lock(this, 240 - 11, 17);
-
- time = new Time(this, 0, 0, 480, this->drawArea.h);
-
- networkAccessTechnology = new NetworkAccessTechnology(
- this, networkTechnology::x, networkTechnology::y, networkTechnology::w, networkTechnology::h);
+ // left
+ leftBox = new HBox(this, 0, 0, 0, 0);
+ leftBox->setMinimumSize(boxes::left::minX, this->drawArea.h);
+ leftBox->setMaximumSize(boxes::left::maxX, this->drawArea.h);
+ leftBox->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Bottom));
+ leftBox->setEdges(RectangleEdge::None);
+ signal = new SignalType(leftBox, 0, 0, 0, 0);
+ signal->setMargins(gui::Margins(margins::between, 0, 0, margins::iconBottom));
+ networkAccessTechnology = new NetworkAccessTechnology(leftBox, 0, 0, 0, 0);
+ networkAccessTechnology->setMaximumSize(nat::maxX, this->drawArea.h);
+ networkAccessTechnology->setMargins(gui::Margins(margins::between, 0, 0, margins::textBottom));
+
+ // center
+ centralBox = new HBox(this, 0, 0, 0, 0);
+ centralBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Bottom));
+ centralBox->setEdges(RectangleEdge::None);
+ lock = new Lock(centralBox, 0, 0);
+ lock->setMargins(Margins(0, 0, 0, margins::iconBottom));
+ time = new Time(centralBox, 0, 0, 0, 0);
+ time->setMaximumSize(time::maxX, this->drawArea.h);
+
+ // right
+ rightBox = new HBox(this, 0, 0, 0, 0);
+ rightBox->setMinimumSize(boxes::right::minX, this->drawArea.h);
+ rightBox->setMaximumSize(boxes::right::maxX, this->drawArea.h);
+ rightBox->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Bottom));
+ rightBox->setEdges(RectangleEdge::None);
+ rightBox->setReverseOrder(true);
+ battery = new BatteryType(rightBox, 0, 0, 0, 0);
+ battery->setMargins(gui::Margins(0, 0, margins::between, margins::iconBottom));
+ sim = new SIM(rightBox, 0, 0);
+ sim->setMargins(gui::Margins(0, 0, margins::between, margins::iconBottom));
updateSignalStrength();
updateNetworkAccessTechnology();
@@ 131,6 142,8 @@ namespace gui::top_bar
setIndicatorStatus(indicator, enabled);
}
configuration = std::move(config);
+
+ resizeItems();
}
void TopBar::setIndicatorStatus(Indicator indicator, bool enabled)
@@ 222,8 235,10 @@ namespace gui::top_bar
{
time->update();
if (enabled) {
+ centralBox->setMinimumSize(boxes::center::maxX, this->drawArea.h);
time->show();
lock->hide();
+ centralBox->resizeItems();
return;
}
time->hide();
@@ 232,6 247,7 @@ namespace gui::top_bar
void TopBar::showLock(bool enabled)
{
if (enabled) {
+ centralBox->setMinimumSize(boxes::center::minX, this->drawArea.h);
lock->show();
time->hide();
return;
M module-gui/gui/widgets/TopBar.hpp => module-gui/gui/widgets/TopBar.hpp +5 -2
@@ 3,7 3,7 @@
#pragma once
-#include <Rect.hpp>
+#include <BoxLayout.hpp>
#include <vector>
#include <map>
@@ 71,7 71,7 @@ namespace gui::top_bar
};
/// Header of most of design Windows
- class TopBar : public Rect
+ class TopBar : public HBox
{
protected:
Time *time = nullptr;
@@ 80,6 80,9 @@ namespace gui::top_bar
Lock *lock = nullptr;
SIM *sim = nullptr;
BatteryBase *battery = nullptr;
+ HBox *leftBox = nullptr;
+ HBox *centralBox = nullptr;
+ HBox *rightBox = nullptr;
Configuration configuration;
void prepareWidget();
M module-gui/gui/widgets/TopBar/BatteryBar.cpp => module-gui/gui/widgets/TopBar/BatteryBar.cpp +2 -0
@@ 31,6 31,8 @@ namespace gui::top_bar
: BatteryBase(parent, x, y, w, h)
{
img = new Image(this, battery1);
+
+ setMinimumSize(img->getWidth(), style::header::status_bar::height);
}
void BatteryBar::showBatteryLevel(std::uint32_t percentage)
M module-gui/gui/widgets/TopBar/BatteryBase.cpp => module-gui/gui/widgets/TopBar/BatteryBase.cpp +2 -1
@@ 9,7 9,8 @@ namespace gui::top_bar
BatteryBase::BatteryBase(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
: StatusBarWidgetBase(parent, x, y, w, h)
{
- setBorderColor(gui::ColorNoColor);
+ setEdges(RectangleEdge::None);
+ setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Bottom));
}
void BatteryBase::update(const Store::Battery &batteryContext)
M module-gui/gui/widgets/TopBar/BatteryBase.hpp => module-gui/gui/widgets/TopBar/BatteryBase.hpp +1 -1
@@ 9,7 9,7 @@
namespace gui::top_bar
{
- class BatteryBase : public StatusBarWidgetBase<HBox>
+ class BatteryBase : public StatusBarWidgetBase<gui::HBox>
{
virtual void showBatteryLevel(std::uint32_t percentage) = 0;
virtual void showBatteryChargingDone() = 0;
M module-gui/gui/widgets/TopBar/BatteryText.cpp => module-gui/gui/widgets/TopBar/BatteryText.cpp +6 -4
@@ 4,7 4,7 @@
#include "BatteryText.hpp"
#include "Label.hpp"
#include <Utils.hpp>
-#include <Style.hpp>
+#include "Style.hpp"
namespace gui::top_bar
{
@@ 14,9 14,11 @@ namespace gui::top_bar
label = new Label(this, 0, 0, 0, 0);
label->setFilled(false);
label->setBorderColor(gui::ColorNoColor);
- label->setFont(style::header::font::modes);
- label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
- label->setMaximumSize(this->getWidth(), this->getHeight());
+ label->setFont(style::header::status_bar::battery::font);
+ label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Right, gui::Alignment::Vertical::Bottom));
+
+ setMinimumSize(style::header::status_bar::battery::maxX, style::header::status_bar::height);
+ label->setMaximumSize(style::header::status_bar::battery::maxX, style::header::status_bar::height);
}
void BatteryText::showBatteryLevel(std::uint32_t percentage)
M module-gui/gui/widgets/TopBar/NetworkAccessTechnology.cpp => module-gui/gui/widgets/TopBar/NetworkAccessTechnology.cpp +5 -4
@@ 3,20 3,21 @@
#include "NetworkAccessTechnology.hpp"
#include "Item.hpp"
+#include "Style.hpp"
namespace gui::top_bar
{
NetworkAccessTechnology::NetworkAccessTechnology(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
: StatusBarWidgetBase(parent, x, y, w, h)
{
- setFilled(false);
- setBorderColor(gui::ColorNoColor);
- setFont(style::header::font::modes);
- setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
+ setEdges(RectangleEdge::None);
+ setFont(style::header::status_bar::nat::font);
+ setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
}
void NetworkAccessTechnology::update(const Store::Network::AccessTechnology accessTechnology)
{
+ setMaximumSize(this->getWidth(), this->getHeight());
_accessTechnology = accessTechnology;
constexpr auto text2g = "2G";
constexpr auto text3g = "3G";
M module-gui/gui/widgets/TopBar/SignalStrengthBar.cpp => module-gui/gui/widgets/TopBar/SignalStrengthBar.cpp +1 -2
@@ 30,8 30,7 @@ namespace gui::top_bar
: SignalStrengthBase(parent, x, y, w, h)
{
img = new Image(this, signalMap.at(Store::RssiBar::zero));
- constexpr auto signalBarMarginX = 10u;
- img->setMargins(gui::Margins(signalBarMarginX, 0, 0, 0));
+ setMinimumSize(img->getWidth(), style::header::status_bar::height);
}
void SignalStrengthBar::update()
M module-gui/gui/widgets/TopBar/SignalStrengthBase.cpp => module-gui/gui/widgets/TopBar/SignalStrengthBase.cpp +2 -1
@@ 8,7 8,8 @@ namespace gui::top_bar
SignalStrengthBase::SignalStrengthBase(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
: StatusBarWidgetBase(parent, x, y, w, h)
{
- setBorderColor(gui::ColorNoColor);
+ setEdges(RectangleEdge::None);
+ setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Bottom));
}
void SignalStrengthBase::update(const Store::SignalStrength &data)
M module-gui/gui/widgets/TopBar/SignalStrengthText.cpp => module-gui/gui/widgets/TopBar/SignalStrengthText.cpp +6 -4
@@ 5,7 5,7 @@
#include "Label.hpp"
#include "common_data/EventStore.hpp"
#include <Utils.hpp>
-#include <Style.hpp>
+#include "Style.hpp"
namespace gui::top_bar
{
@@ 15,9 15,11 @@ namespace gui::top_bar
label = new Label(this, 0, 0, 0, 0);
label->setFilled(false);
label->setBorderColor(gui::ColorNoColor);
- label->setFont(style::header::font::modes);
- label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
- label->setMaximumSize(this->getWidth(), this->getHeight());
+ label->setFont(style::header::status_bar::signal::font);
+ label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
+
+ setMinimumSize(style::header::status_bar::signal::maxX, style::header::status_bar::height);
+ label->setMaximumSize(style::header::status_bar::signal::maxX, style::header::status_bar::height);
}
void SignalStrengthText::update()
A module-gui/gui/widgets/TopBar/Style.hpp => module-gui/gui/widgets/TopBar/Style.hpp +61 -0
@@ 0,0 1,61 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <Style.hpp>
+
+namespace style::header::status_bar
+{
+ namespace font
+ {
+
+ inline constexpr auto title = "gt_pressura_bold_32";
+ }; // namespace font
+
+ namespace margins
+ {
+ inline constexpr auto iconBottom = 4u;
+ inline constexpr auto textBottom = 5u;
+ inline constexpr auto between = 10u;
+ }; // namespace margins
+ namespace time
+ {
+ inline constexpr auto font = "gt_pressura_regular_24";
+ inline constexpr auto maxX = 100u;
+ }; // namespace time
+ namespace nat
+ {
+ inline constexpr auto maxX = 35u;
+ inline constexpr auto font = "gt_pressura_regular_20";
+ }; // namespace nat
+ namespace signal
+ {
+ inline constexpr auto font = "gt_pressura_regular_20";
+ inline constexpr auto maxX = 80u;
+ }; // namespace signal
+ namespace battery
+ {
+ inline constexpr auto font = "gt_pressura_regular_20";
+ inline constexpr auto maxX = 70U;
+ }; // namespace battery
+ namespace boxes
+ {
+ namespace left
+ {
+ inline constexpr auto minX = 165u;
+ inline constexpr auto maxX = 205u;
+ }; // namespace left
+ namespace right
+ {
+ inline constexpr auto minX = 165u;
+ inline constexpr auto maxX = 205u;
+ }; // namespace right
+ namespace center
+ {
+ inline constexpr auto maxX = time::maxX;
+ inline constexpr auto minX = 30;
+ }; // namespace center
+ }; // namespace boxes
+
+}; // namespace style::header::status_bar
M module-gui/gui/widgets/TopBar/Time.cpp => module-gui/gui/widgets/TopBar/Time.cpp +2 -2
@@ 4,7 4,7 @@
#include "Time.hpp"
#include "time/time_conversion.hpp"
#include <Utils.hpp>
-#include <Style.hpp>
+#include "Style.hpp"
namespace gui::top_bar
{
@@ 13,7 13,7 @@ namespace gui::top_bar
{
setFilled(false);
setBorderColor(gui::ColorNoColor);
- setFont(style::header::font::time);
+ setFont(style::header::status_bar::time::font);
setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
using namespace utils::time;
setFormat(Locale::format(Locale::TimeFormat::FormatTime12H));