M module-apps/application-call/data/CallAppStyle.hpp => module-apps/application-call/data/CallAppStyle.hpp +6 -16
@@ 54,11 54,11 @@ namespace callAppStyle
// ENTER NUMBER WINDOW
namespace enterNumberWindow
{
- namespace newContactIcon
+ namespace iconsBox
{
- inline constexpr auto x = 190U - icon::x_margin;
inline constexpr auto y = 411U;
- } // namespace newContactIcon
+ inline constexpr auto h = 100U;
+ } // namespace iconsBox
} // namespace enterNumberWindow
// CALL WINDOW
@@ 83,20 83,10 @@ namespace callAppStyle
inline constexpr auto w = 240U;
inline constexpr auto h = 20U;
} // namespace durationLabel
- namespace speakerIcon
+ namespace iconsBox
{
- inline constexpr auto x = 260U - icon::x_margin;
inline constexpr auto y = 411U;
- } // namespace speakerIcon
- namespace microphoneIcon
- {
- inline constexpr auto x = 120U - icon::x_margin;
- inline constexpr auto y = 411U;
- } // namespace microphoneIcon
- namespace sendMessageIcon
- {
- inline constexpr auto x = 190U - icon::x_margin;
- inline constexpr auto y = 411U;
- } // namespace sendMessageIcon
+ inline constexpr auto h = 100U;
+ } // namespace iconsBox
} // namespace callWindow
} // namespace callAppStyle
M module-apps/application-call/widgets/StateIcon.hpp => module-apps/application-call/widgets/StateIcon.hpp +17 -39
@@ 8,6 8,7 @@
#include <Label.hpp>
#include <log/log.hpp>
#include <Style.hpp>
+#include <ImageBoxWithText.hpp>
#include <map>
@@ 17,19 18,7 @@ namespace gui
{
constexpr uint32_t w = 100;
constexpr uint32_t h = 100;
-
- namespace label
- {
- constexpr uint32_t x = 0;
- constexpr uint32_t y = 58;
- constexpr uint32_t w = icon::w;
- constexpr uint32_t h = 22;
- } // namespace label
- namespace img
- {
- constexpr uint32_t x = 34;
- constexpr uint32_t y = 15;
- } // namespace img
+ constexpr uint32_t defaultSideMargin = 20;
} // namespace icon
/// @brief Icon widget with custom predefined images and strings
@@ 40,29 29,19 @@ namespace gui
/// icon::h where w = icon::w + 2 * w_margin. It is necessary as it is possible that text will exceed Icon visible
/// area
- template <class T> class StateIcon : public Rect
+ template <class T> class StateIcon : public ImageBoxWithText
{
public:
using IconMap = std::map<T, std::pair<const std::string, const std::string>>;
StateIcon() = delete;
- StateIcon(
- Item *parent, const uint32_t &x, const uint32_t &y, const uint32_t &w_margin, T state, const IconMap &data)
- : Rect(parent, x, y, icon::w + 2 * w_margin, icon::h), data(data)
+ StateIcon(Item *parent, T state, const IconMap &data)
+ : ImageBoxWithText(parent,
+ new gui::Image(data.at(state).first, ImageTypeSpecifier::W_M),
+ utils::translate(data.at(state).second)),
+ state(state), data(data)
{
- setEdges(RectangleEdge::None);
- setPenFocusWidth(style::window::default_border_no_focus_w);
- setPenWidth(style::window::default_border_no_focus_w);
- boundingRect = new Rect(this, w_margin, 0, icon::w, icon::h);
- boundingRect->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
- boundingRect->setPenFocusWidth(style::window::default_border_focus_w);
- boundingRect->setPenWidth(style::window::default_border_no_focus_w);
-
- img = new gui::Image(boundingRect, icon::img::x, icon::img::y, 0, 0);
- label = new gui::Label(this, icon::label::x, icon::label::y, icon::label::w + 2 * w_margin, icon::label::h);
- label->setEdges(RectangleEdge::None);
- label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
- label->setFont(style::window::font::verysmall);
-
+ setSize(icon::w, icon::h);
+ setMargins({icon::defaultSideMargin, 0, icon::defaultSideMargin, 0});
set(state);
}
@@ 75,10 54,13 @@ namespace gui
virtual void set(const T &state)
{
this->state = state;
- img->set(data.at(state).first, ImageTypeSpecifier::W_M);
- label->setText(utils::translate(data.at(state).second));
- using namespace style::window;
- label->setFont(data.find(state) != data.begin() ? font::verysmallbold : font::verysmall);
+ image->set(data.at(state).first, ImageTypeSpecifier::W_M);
+
+ text->setFont(data.find(state) != data.begin() ? imageBoxWithText::fontBold : imageBoxWithText::font);
+ text->setText(utils::translate(data.at(state).second));
+ text->setMinimumWidthToFitText(utils::translate(data.at(state).second));
+ text->setMinimumHeightToFitText();
+ text->informContentChanged();
}
T get() const
@@ 103,15 85,11 @@ namespace gui
bool onFocus(bool state) override
{
Item::onFocus(state);
- setFocusItem(state ? boundingRect : nullptr);
return true;
}
protected:
- Image *img = nullptr;
- Label *label = nullptr;
- Rect *boundingRect = nullptr;
T state;
const IconMap data; // internal map with predefined sets of images and strings to be displayed
};
M module-apps/application-call/widgets/StateIcons.cpp => module-apps/application-call/widgets/StateIcons.cpp +5 -9
@@ 19,7 19,7 @@ namespace gui
constexpr auto speakerImg = "call_speaker";
constexpr auto speakerOnImg = "call_speaker_on";
constexpr auto speakerStr = "app_call_speaker";
- constexpr auto speakerOnStr = "app_call_speaker_on";
+ constexpr auto speakerOnStr = "app_call_speaker";
const StateIcon<AddContactIconState>::IconMap contactIconMap = {
{AddContactIconState::ADD_CONTACT, {crossImg, addContactStr}}};
@@ 32,20 32,16 @@ namespace gui
{SpeakerIconState::SPEAKERON, {speakerOnImg, speakerOnStr}}};
} // namespace
- AddContactIcon::AddContactIcon(Item *parent, std::uint32_t x, std::uint32_t y)
- : StateIcon(parent, x, y, callAppStyle::icon::x_margin, AddContactIconState::ADD_CONTACT, contactIconMap)
+ AddContactIcon::AddContactIcon(Item *parent) : StateIcon(parent, AddContactIconState::ADD_CONTACT, contactIconMap)
{}
- SendSmsIcon::SendSmsIcon(Item *parent, std::uint32_t x, std::uint32_t y)
- : StateIcon(parent, x, y, callAppStyle::icon::x_margin, SendSmsIconState::SEND_SMS, smsIconMap)
+ SendSmsIcon::SendSmsIcon(Item *parent) : StateIcon(parent, SendSmsIconState::SEND_SMS, smsIconMap)
{}
- MicrophoneIcon::MicrophoneIcon(Item *parent, std::uint32_t x, std::uint32_t y)
- : StateIcon(parent, x, y, callAppStyle::icon::x_margin, MicrophoneIconState::MUTE, microphoneIconMap)
+ MicrophoneIcon::MicrophoneIcon(Item *parent) : StateIcon(parent, MicrophoneIconState::MUTE, microphoneIconMap)
{}
- SpeakerIcon::SpeakerIcon(Item *parent, std::uint32_t x, std::uint32_t y)
- : StateIcon(parent, x, y, callAppStyle::icon::x_margin, SpeakerIconState::SPEAKER, speakerIconMap)
+ SpeakerIcon::SpeakerIcon(Item *parent) : StateIcon(parent, SpeakerIconState::SPEAKER, speakerIconMap)
{}
} // namespace gui
M module-apps/application-call/widgets/StateIcons.hpp => module-apps/application-call/widgets/StateIcons.hpp +4 -4
@@ 18,7 18,7 @@ namespace gui
{
public:
AddContactIcon() = delete;
- AddContactIcon(Item *parent, std::uint32_t x, std::uint32_t y);
+ AddContactIcon(Item *parent);
};
enum class SendSmsIconState
@@ 29,7 29,7 @@ namespace gui
{
public:
SendSmsIcon() = delete;
- SendSmsIcon(Item *parent, std::uint32_t x, std::uint32_t y);
+ SendSmsIcon(Item *parent);
};
enum class MicrophoneIconState
@@ 42,7 42,7 @@ namespace gui
{
public:
MicrophoneIcon() = delete;
- MicrophoneIcon(Item *parent, std::uint32_t x, std::uint32_t y);
+ MicrophoneIcon(Item *parent);
};
enum class SpeakerIconState
@@ 55,6 55,6 @@ namespace gui
{
public:
SpeakerIcon() = delete;
- SpeakerIcon(Item *parent, std::uint32_t x, std::uint32_t y);
+ SpeakerIcon(Item *parent);
};
} // namespace gui
M module-apps/application-call/windows/CallWindow.cpp => module-apps/application-call/windows/CallWindow.cpp +21 -32
@@ 76,15 76,25 @@ namespace gui
numberLabel->setFont(style::window::font::largelight);
numberLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
- speakerIcon = new SpeakerIcon(this, speakerIcon::x, speakerIcon::y);
- speakerIcon->focusChangedCallback = [=](gui::Item &item) {
- LOG_DEBUG("speakerIcon get/lost focus");
- navBar->setText(nav_bar::Side::Center, utils::translate(style::strings::common::Switch), item.focus);
+ iconsBox = new HBox(
+ this, style::window::default_left_margin, iconsBox::y, style::window::default_body_width, iconsBox::h);
+ iconsBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top));
+ iconsBox->setEdges(RectangleEdge::None);
+
+ microphoneIcon = new MicrophoneIcon(iconsBox);
+ microphoneIcon->activatedCallback = [=](gui::Item &item) {
+ microphoneIcon->setNext();
+ LOG_INFO("Mic activated %d", static_cast<int>(microphoneIcon->get()));
+
+ microphoneIcon->get() == MicrophoneIconState::MUTED ? interface->sendAudioEvent(AudioEvent::Mute)
+ : interface->sendAudioEvent(AudioEvent::Unmute);
+
return true;
};
+
+ speakerIcon = new SpeakerIcon(iconsBox);
speakerIcon->activatedCallback = [=](gui::Item &item) {
speakerIcon->setNext();
- application->refreshWindow(RefreshModes::GUI_REFRESH_FAST);
LOG_INFO("Speaker activated %d", static_cast<int>(speakerIcon->get()));
switch (speakerIcon->get()) {
@@ 104,29 114,7 @@ namespace gui
return true;
};
- microphoneIcon = new MicrophoneIcon(this, microphoneIcon::x, microphoneIcon::y);
- microphoneIcon->focusChangedCallback = [=](gui::Item &item) {
- LOG_DEBUG("microphoneIcon get/lost focus");
- navBar->setText(nav_bar::Side::Center, utils::translate(style::strings::common::Switch), item.focus);
- return true;
- };
- microphoneIcon->activatedCallback = [=](gui::Item &item) {
- microphoneIcon->setNext();
- application->refreshWindow(RefreshModes::GUI_REFRESH_FAST);
- LOG_INFO("Mic activated %d", static_cast<int>(microphoneIcon->get()));
-
- microphoneIcon->get() == MicrophoneIconState::MUTED ? interface->sendAudioEvent(AudioEvent::Mute)
- : interface->sendAudioEvent(AudioEvent::Unmute);
-
- return true;
- };
-
- sendSmsIcon = new gui::SendSmsIcon(this, sendMessageIcon::x, sendMessageIcon::y);
- sendSmsIcon->focusChangedCallback = [=](gui::Item &item) {
- LOG_DEBUG("Send message get/lost focus");
- navBar->setText(gui::nav_bar::Side::Center, utils::translate(style::strings::common::send), item.focus);
- return true;
- };
+ sendSmsIcon = new gui::SendSmsIcon(iconsBox);
sendSmsIcon->activatedCallback = [=](gui::Item &item) {
LOG_INFO("Send message template and reject the call");
constexpr auto preventAutoLock = true;
@@ 180,6 168,7 @@ namespace gui
}
else {
navBar->setActive(gui::nav_bar::Side::Center, true);
+ navBar->setText(gui::nav_bar::Side::Center, utils::translate(style::strings::common::send), true);
sendSmsIcon->setVisible(true);
setFocusItem(sendSmsIcon);
}
@@ 208,20 197,19 @@ namespace gui
navBar->setActive(gui::nav_bar::Side::Left, false);
navBar->setActive(gui::nav_bar::Side::Center, false);
navBar->setText(gui::nav_bar::Side::Right, utils::translate(strings::endcall), true);
+ navBar->setText(gui::nav_bar::Side::Center, utils::translate(style::strings::common::Switch), true);
durationLabel->setVisible(true);
sendSmsIcon->setVisible(false);
speakerIcon->setVisible(true);
microphoneIcon->setVisible(true);
- auto focusItem = getFocusItem();
- if (focusItem != microphoneIcon || focusItem != speakerIcon) {
- setFocusItem(microphoneIcon);
- }
+ setFocusItem(microphoneIcon);
} break;
case State::OUTGOING_CALL: {
interface->startAudioRouting();
navBar->setActive(gui::nav_bar::Side::Left, false);
navBar->setActive(gui::nav_bar::Side::Center, false);
navBar->setText(gui::nav_bar::Side::Right, utils::translate(strings::endcall), true);
+ navBar->setText(gui::nav_bar::Side::Center, utils::translate(style::strings::common::Switch), true);
durationLabel->setText(utils::translate(strings::calling));
durationLabel->setVisible(true);
sendSmsIcon->setVisible(false);
@@ 244,6 232,7 @@ namespace gui
setFocusItem(nullptr);
break;
};
+ iconsBox->resizeItems();
}
auto CallWindow::getState() const noexcept -> State
M module-apps/application-call/windows/CallWindow.hpp => module-apps/application-call/windows/CallWindow.hpp +1 -0
@@ 44,6 44,7 @@ namespace gui
// used to inform user about call state of call and display duration of call
gui::Label *durationLabel = nullptr;
+ gui::HBox *iconsBox = nullptr;
gui::SendSmsIcon *sendSmsIcon = nullptr;
gui::MicrophoneIcon *microphoneIcon = nullptr;
gui::SpeakerIcon *speakerIcon = nullptr;
M module-apps/application-call/windows/EnterNumberWindow.cpp => module-apps/application-call/windows/EnterNumberWindow.cpp +8 -1
@@ 35,9 35,16 @@ namespace gui
navBar->setText(nav_bar::Side::Center, utils::translate("common_add"));
navBar->setText(nav_bar::Side::Right, utils::translate("app_call_clear"));
- newContactIcon = new gui::AddContactIcon(this, newContactIcon::x, newContactIcon::y);
+ auto iconsBox = new HBox(
+ this, style::window::default_left_margin, iconsBox::y, style::window::default_body_width, iconsBox::h);
+ iconsBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top));
+ iconsBox->setEdges(RectangleEdge::None);
+
+ newContactIcon = new gui::AddContactIcon(iconsBox);
newContactIcon->activatedCallback = [=](gui::Item &item) { return addNewContact(); };
setFocusItem(newContactIcon);
+
+ iconsBox->resizeItems();
}
status_bar::Configuration EnterNumberWindow::configureStatusBar(status_bar::Configuration appConfiguration)
M module-gui/gui/widgets/ImageBoxWithText.cpp => module-gui/gui/widgets/ImageBoxWithText.cpp +4 -2
@@ 37,16 37,18 @@ void ImageBoxWithText::setText(const UTF8 &description)
{
text = new TextFixedSize(this);
text->drawUnderline(false);
- text->setMargins(Margins(0, imageBoxWithText::text_margin, 0, imageBoxWithText::text_margin));
+ text->setMargins(Margins(0, imageBoxWithText::text_margin_top, 0, imageBoxWithText::text_margin_bottom));
text->setFont(imageBoxWithText::font);
text->setText(description);
text->setMinimumWidthToFitText(description);
text->setMinimumHeightToFitText();
+ text->setAlignment(Alignment::Horizontal::Center);
+ text->activeItem = false;
}
void ImageBoxWithText::setMinimumSizeToFitImage()
{
auto minW = std::max(image->getWidth(), text->widgetMinimumArea.w);
- auto minH = image->getHeight() + imageBoxWithText::text_margin + text->widgetMinimumArea.h;
+ auto minH = image->getHeight() + imageBoxWithText::text_margin_top + text->widgetMinimumArea.h;
setMinimumSize(minW, minH);
}
M module-gui/gui/widgets/ImageBoxWithText.hpp => module-gui/gui/widgets/ImageBoxWithText.hpp +3 -1
@@ 12,8 12,10 @@ namespace gui
namespace imageBoxWithText
{
inline constexpr auto wh = 100;
- inline constexpr auto text_margin = 5;
+ inline constexpr auto text_margin_top = 11;
+ inline constexpr auto text_margin_bottom = 5;
inline constexpr auto font = style::window::font::verysmall;
+ inline constexpr auto fontBold = style::window::font::verysmallbold;
} // namespace imageBoxWithText
class ImageBoxWithText : public ImageBox