~aleteoryx/muditaos

3a889401c780bf09c4a23154caf2526ff16c19bc — tomaszkrosnowski 4 years ago e29343b
[EGD-7791] Meditation layout fix

Fixed layout in meditation app, so it now renders as it should.
Also small fix for MP is included (EGD-7848).
M module-apps/application-meditation/data/Style.hpp => module-apps/application-meditation/data/Style.hpp +15 -24
@@ 8,40 8,31 @@
namespace style::meditation
{
    constexpr auto VerticalWidgetGap = 20;
    namespace body
    {
        constexpr auto Width  = style::window_width;
        constexpr auto Height = style::window_height - style::window::default_vertical_pos - style::footer::height - 1;
        constexpr auto X      = 1;
        constexpr auto Y      = style::window::default_vertical_pos;
    } // namespace body

    namespace timer
    {
        constexpr auto Radius = 150;
        constexpr auto X      = body::X + (body::Width / 2) - Radius;
        constexpr auto Y      = body::Y + 20;
        constexpr auto Width  = 2 * Radius;
        constexpr auto Height = Width;
        constexpr auto Radius = 142;
        constexpr auto X      = style::window_width / 2 - Radius;
        constexpr auto Y      = style::window::default_vertical_pos + 18;

        constexpr auto BorderColor = gui::ColorGrey;
        constexpr auto BorderColorOnFocused = gui::ColorFullBlack;
        constexpr auto PenWidth    = 3;
        constexpr auto BorderColor   = gui::ColorFullBlack;
        constexpr auto PenWidth      = 1;
        constexpr auto FocusPenWidth = 3;

        namespace setterValueLabel
        {
            constexpr auto X      = 100;
            constexpr auto Y      = 100;
            constexpr auto Width  = timer::Width - 2 * X;
            constexpr auto Height = timer::Height - 2 * Y;
            constexpr auto Width           = 140;
            constexpr auto Height          = 96;
            constexpr auto TopMargin       = 80;
            constexpr auto BottomLineWidth = 100;
            constexpr auto BottomLinePen   = 2;
        } // namespace setterValueLabel

        namespace setterUnitLabel
        {
            constexpr auto X      = 0;
            constexpr auto Y      = setterValueLabel::Y + setterValueLabel::Height;
            constexpr auto Width  = timer::Width;
            constexpr auto Height = 40;
            constexpr auto Width     = 220;
            constexpr auto Height    = 20;
            constexpr auto TopMargin = 15;
        } // namespace setterUnitLabel

        namespace infoText


@@ 57,7 48,7 @@ namespace style::meditation
    namespace intervalBox
    {
        constexpr auto X      = style::window::default_left_margin;
        constexpr auto Y      = style::meditation::timer::Y + style::meditation::timer::Height + VerticalWidgetGap;
        constexpr auto Y      = style::meditation::timer::Y + 2 * style::meditation::timer::Radius + VerticalWidgetGap;
        constexpr auto Width  = style::window::default_body_width;
        constexpr auto Height = 60;


M module-apps/application-meditation/widgets/TimerProperty.cpp => module-apps/application-meditation/widgets/TimerProperty.cpp +23 -17
@@ 17,49 17,55 @@ TimerProperty::TimerProperty(Item *parent, const uint32_t x, const uint32_t y, c

void TimerProperty::build()
{
    const Point boxCenter(getX() + (getWidth() / 2), getY() + (getHeight() / 2));

    namespace timerStyle = style::meditation::timer;

    const Point boxCenter(getX() + (getWidth() / 2), getY() + (getHeight() / 2));
    Circle::ShapeParams params;
    params.setCenterPoint(boxCenter)
        .setRadius(timerStyle::Radius)
        .setBorderColor(timerStyle::BorderColor)
        .setFocusBorderColor(timerStyle::BorderColorOnFocused)
        .setFocusBorderColor(timerStyle::BorderColor)
        .setPenWidth(timerStyle::PenWidth)
        .setFocusPenWidth(timerStyle::PenWidth);
        .setFocusPenWidth(timerStyle::FocusPenWidth);
    circle = new Circle(this, params);

    namespace timerStyle = style::meditation::timer;
    timeLabel            = new Label(this,
                          timerStyle::setterValueLabel::X,
                          timerStyle::setterValueLabel::Y,
                          timerStyle::setterValueLabel::Width,
                          timerStyle::setterValueLabel::Height);
    centerBody = new VBox(this, 0, 0, 2 * timerStyle::Radius, 2 * timerStyle::Radius);
    centerBody->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top));
    centerBody->setMinimumSize(2 * timerStyle::Radius, 2 * timerStyle::Radius);
    centerBody->setEdges(RectangleEdge::None);
    centerBody->activeItem = false;

    timeLabel = new Label(centerBody);
    timeLabel->setMargins(gui::Margins(0, timerStyle::setterValueLabel::TopMargin, 0, 0));
    timeLabel->setEdges(RectangleEdge::None);
    timeLabel->setMinimumSize(timerStyle::setterValueLabel::Width, timerStyle::setterValueLabel::Height);
    timeLabel->setFont(style::window::font::supersizemelight);
    timeLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
    timeLabel->setPenWidth(timerStyle::PenWidth);
    timeLabel->setText(std::to_string(static_cast<int>(state.getTime().count())));

    timeUnitLabel = new Label(this,
                              timerStyle::setterUnitLabel::X,
                              timerStyle::setterUnitLabel::Y,
                              timerStyle::setterUnitLabel::Width,
                              timerStyle::setterUnitLabel::Height);
    divRect = new Rect(centerBody, 0, 0, timerStyle::setterValueLabel::BottomLineWidth, 1);
    divRect->setPenWidth(timerStyle::setterValueLabel::BottomLinePen);

    timeUnitLabel = new Label(centerBody);
    timeUnitLabel->setMinimumSize(timerStyle::setterUnitLabel::Width, timerStyle::setterUnitLabel::Height);
    timeUnitLabel->setMargins(gui::Margins(0, timerStyle::setterUnitLabel::TopMargin, 0, 0));
    timeUnitLabel->setFont(style::window::font::verysmall);
    timeUnitLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
    timeUnitLabel->setEdges(RectangleEdge::None);
    timeUnitLabel->setText(utils::translate("app_meditation_minutes"));

    centerBody->resizeItems();
}

bool TimerProperty::onFocus(bool isFocused)
{
    circle->setFocus(isFocused);
    if (isFocused) {
        timeLabel->setEdges(RectangleEdge::Bottom);
        divRect->setEdges(RectangleEdge::Top);
    }
    else {
        timeLabel->setEdges(RectangleEdge::None);
        divRect->setEdges(RectangleEdge::None);
    }
    state.onFocus();
    return true;

M module-apps/application-meditation/widgets/TimerProperty.hpp => module-apps/application-meditation/widgets/TimerProperty.hpp +2 -0
@@ 42,7 42,9 @@ namespace gui
        } state;

        Circle *circle       = nullptr;
        VBox *centerBody     = nullptr;
        Label *timeLabel     = nullptr;
        Rect *divRect        = nullptr;
        Label *timeUnitLabel = nullptr;

        void build();

M module-apps/application-meditation/windows/MeditationTimerWindow.cpp => module-apps/application-meditation/windows/MeditationTimerWindow.cpp +2 -2
@@ 47,8 47,8 @@ void MeditationTimerWindow::buildInterface()

    timer = new MeditationTimer(style::meditation::timer::X,
                                style::meditation::timer::Y,
                                style::meditation::timer::Width,
                                style::meditation::timer::Height,
                                2 * style::meditation::timer::Radius,
                                2 * style::meditation::timer::Radius,
                                app,
                                this);


M module-apps/application-meditation/windows/MeditationWindow.cpp => module-apps/application-meditation/windows/MeditationWindow.cpp +2 -2
@@ 42,8 42,8 @@ namespace gui
        timeSetter = new TimerProperty(this,
                                       style::meditation::timer::X,
                                       style::meditation::timer::Y,
                                       style::meditation::timer::Width,
                                       style::meditation::timer::Height);
                                       2 * style::meditation::timer::Radius,
                                       2 * style::meditation::timer::Radius);
        timeSetter->setEdges(RectangleEdge::None);
        setFocusItem(timeSetter);


M module-apps/application-settings/models/apps/SoundsModel.cpp => module-apps/application-settings/models/apps/SoundsModel.cpp +0 -2
@@ 185,8 185,6 @@ void SoundsModel::applyItems(const std::vector<std::filesystem::path> &sounds,
                        utils::translate(style::strings::common::play), gui::nav_bar::Side::Left, false);
                    return true;
                }

                return false;
            };
            break;


M module-apps/apps-common/audio/AbstractSoundsPlayer.hpp => module-apps/apps-common/audio/AbstractSoundsPlayer.hpp +2 -2
@@ 17,9 17,9 @@ class AbstractSoundsPlayer
        Stopped
    };

    using AudioEofCallback = std::function<void()>;
    using AudioStoppedCallback = std::function<void()>;

    virtual bool play(const std::string &path, AudioEofCallback cb = nullptr) = 0;
    virtual bool play(const std::string &path, AudioStoppedCallback cb = nullptr) = 0;
    virtual bool pause()                                                      = 0;
    virtual bool resume()                                                     = 0;
    virtual bool stop()                                                       = 0;

M module-apps/apps-common/audio/SoundsPlayer.cpp => module-apps/apps-common/audio/SoundsPlayer.cpp +6 -6
@@ 7,9 7,9 @@ SoundsPlayer::SoundsPlayer(app::ApplicationCommon *app)
    : audioOperations{std::make_unique<app::AsyncAudioOperations>(app)}
{}

bool SoundsPlayer::play(const std::string &path, AudioEofCallback cb)
bool SoundsPlayer::play(const std::string &path, AudioStoppedCallback cb)
{
    eofCallback = nullptr;
    audioStoppedCallback = nullptr;
    return audioOperations->play(path, [this, path, cb](audio::RetCode retCode, audio::Token token) {
        if (retCode != audio::RetCode::Success || !token.IsValid()) {
            LOG_ERROR("Audio preview callback failed with retcode = %s. Token validity: %d",


@@ 20,7 20,7 @@ bool SoundsPlayer::play(const std::string &path, AudioEofCallback cb)
        currentState = State::Playing;
        currentToken = token;
        currentPath  = path;
        eofCallback  = cb;
        audioStoppedCallback = cb;
    });
}



@@ 62,7 62,7 @@ bool SoundsPlayer::resume()

bool SoundsPlayer::stop()
{
    eofCallback = nullptr;
    audioStoppedCallback = nullptr;

    if (currentToken.IsValid()) {
        return audioOperations->stop(currentToken,


@@ 75,8 75,8 @@ bool SoundsPlayer::stop(audio::Token token)
{
    if (currentToken.IsValid() && currentToken == token) {
        currentState = State::Stopped;
        if (eofCallback != nullptr) {
            eofCallback();
        if (audioStoppedCallback != nullptr) {
            audioStoppedCallback();
        }
        return true;
    }

M module-apps/apps-common/audio/SoundsPlayer.hpp => module-apps/apps-common/audio/SoundsPlayer.hpp +2 -2
@@ 11,7 11,7 @@ class SoundsPlayer : public AbstractSoundsPlayer
    explicit SoundsPlayer(app::ApplicationCommon *app);
    virtual ~SoundsPlayer() = default;

    bool play(const std::string &path, AudioEofCallback cb = nullptr) override;
    bool play(const std::string &path, AudioStoppedCallback cb = nullptr) override;
    bool pause() override;
    bool resume() override;
    bool stop() override;


@@ 25,5 25,5 @@ class SoundsPlayer : public AbstractSoundsPlayer
    audio::Token currentToken;
    std::string currentPath;

    AudioEofCallback eofCallback{nullptr};
    AudioStoppedCallback audioStoppedCallback{nullptr};
};