diff --git a/src/app/ui/layout_selector.cpp b/src/app/ui/layout_selector.cpp index dd8cc647d..8681f9975 100644 --- a/src/app/ui/layout_selector.cpp +++ b/src/app/ui/layout_selector.cpp @@ -317,8 +317,9 @@ void LayoutSelector::LayoutComboBox::onCloseListBox() } } -LayoutSelector::LayoutSelector(TooltipManager* tooltipManager) +LayoutSelector::LayoutSelector(TooltipManager* tooltipManager, Widget* notifications) : m_button(SkinTheme::instance()->parts.iconLayout()) + , m_notifications(notifications) { setActiveLayoutId(Preferences::instance().general.workspaceLayout()); @@ -332,6 +333,7 @@ LayoutSelector::LayoutSelector(TooltipManager* tooltipManager) addChild(&m_bottom); m_center.addChild(&m_comboBox); m_center.addChild(&m_button); + m_center.addChild(m_notifications); setupTooltips(tooltipManager); initTheme(); @@ -339,6 +341,8 @@ LayoutSelector::LayoutSelector(TooltipManager* tooltipManager) LayoutSelector::~LayoutSelector() { + m_center.removeChild(m_notifications); + Preferences::instance().general.workspaceLayout(m_activeLayoutId); if (!is_app_state_closing()) diff --git a/src/app/ui/layout_selector.h b/src/app/ui/layout_selector.h index 8aa952e38..88089b74e 100644 --- a/src/app/ui/layout_selector.h +++ b/src/app/ui/layout_selector.h @@ -44,7 +44,7 @@ class LayoutSelector : public ui::VBox, }; public: - LayoutSelector(ui::TooltipManager* tooltipManager); + LayoutSelector(ui::TooltipManager* tooltipManager, ui::Widget* notifications); ~LayoutSelector(); LayoutPtr activeLayout() const; @@ -88,6 +88,7 @@ private: ui::HBox m_top, m_center, m_bottom; LayoutComboBox m_comboBox; IconButton m_button; + Widget* m_notifications = nullptr; gfx::Size m_startSize; gfx::Size m_endSize; Layouts m_layouts; diff --git a/src/app/ui/main_window.cpp b/src/app/ui/main_window.cpp index 323eb77a4..ae10f2000 100644 --- a/src/app/ui/main_window.cpp +++ b/src/app/ui/main_window.cpp @@ -117,7 +117,8 @@ MainWindow::MainWindow() void MainWindow::initialize() { m_menuBar = std::make_unique(); - m_layoutSelector = std::make_unique(m_tooltipManager); + m_notifications = std::make_unique(); + m_layoutSelector = std::make_unique(m_tooltipManager, m_notifications.get()); // Register commands to load menus+shortcuts for these commands Editor::registerCommands(); @@ -128,7 +129,6 @@ void MainWindow::initialize() // Setup the main menubar m_menuBar->setMenu(AppMenus::instance()->getRootMenu()); - m_notifications = std::make_unique(); m_statusBar = std::make_unique(m_tooltipManager); m_toolBar = std::make_unique(); m_tabsBar = std::make_unique(this); @@ -173,8 +173,7 @@ void MainWindow::initialize() m_customizableDockPlaceholder = std::make_unique(); m_customizableDockPlaceholder->addChild(m_customizableDock); - m_dock->top()->right()->dock(ui::RIGHT, m_notifications.get()); - m_dock->top()->right()->dock(ui::CENTER, m_layoutSelector.get()); + m_dock->top()->dock(ui::RIGHT, m_layoutSelector.get()); m_dock->top()->center()->dock(ui::BOTTOM, m_tabsBar.get()); m_dock->top()->center()->dock(ui::CENTER, m_menuBar.get()); diff --git a/src/app/ui/main_window.h b/src/app/ui/main_window.h index 71805481f..e7229ddfb 100644 --- a/src/app/ui/main_window.h +++ b/src/app/ui/main_window.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2024 Igara Studio S.A. +// Copyright (C) 2018-2025 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -144,6 +144,7 @@ private: Dock* m_customizableDock; std::unique_ptr m_customizableDockPlaceholder; std::unique_ptr m_menuBar; + std::unique_ptr m_notifications; std::unique_ptr m_layoutSelector; std::unique_ptr m_statusBar; std::unique_ptr m_colorBar; @@ -155,7 +156,6 @@ private: std::unique_ptr m_workspace; std::unique_ptr m_previewEditor; std::unique_ptr m_homeView; - std::unique_ptr m_notifications; std::unique_ptr m_scalePanic; std::unique_ptr m_browserView; #ifdef ENABLE_SCRIPTING diff --git a/src/app/ui/notifications.cpp b/src/app/ui/notifications.cpp index ad997af6a..0ace8b7de 100644 --- a/src/app/ui/notifications.cpp +++ b/src/app/ui/notifications.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020-2023 Igara Studio S.A. +// Copyright (C) 2020-2025 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -20,6 +20,7 @@ namespace app { +using namespace app::skin; using namespace ui; class NotificationItem : public MenuItem { @@ -39,10 +40,7 @@ private: INotificationDelegate* m_delegate; }; -Notifications::Notifications() - : Button("") - , m_flagStyle(skin::SkinTheme::get(this)->styles.flag()) - , m_red(false) +Notifications::Notifications() : Button(""), m_red(false) { } @@ -52,13 +50,22 @@ void Notifications::addLink(INotificationDelegate* del) m_red = true; } +void Notifications::onInitTheme(InitThemeEvent& ev) +{ + Button::onInitTheme(ev); + m_popup.initTheme(); +} + void Notifications::onSizeHint(SizeHintEvent& ev) { - ev.setSizeHint(gfx::Size(16, 10) * guiscale()); // TODO hard-coded flag size + auto* theme = SkinTheme::get(this); + auto hint = theme->calcSizeHint(this, theme->styles.flag()); + ev.setSizeHint(hint); } void Notifications::onPaint(PaintEvent& ev) { + auto* theme = SkinTheme::get(this); Graphics* g = ev.graphics(); PaintWidgetPartInfo info; @@ -69,7 +76,7 @@ void Notifications::onPaint(PaintEvent& ev) if (isSelected()) info.styleFlags |= ui::Style::Layer::kSelected; - theme()->paintWidgetPart(g, m_flagStyle, clientBounds(), info); + theme->paintWidgetPart(g, theme->styles.flag(), clientBounds(), info); } void Notifications::onClick() diff --git a/src/app/ui/notifications.h b/src/app/ui/notifications.h index d39e27bda..c56517808 100644 --- a/src/app/ui/notifications.h +++ b/src/app/ui/notifications.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020-2023 Igara Studio S.A. +// Copyright (C) 2020-2025 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -32,12 +32,12 @@ public: int dockableAt() const override { return ui::TOP | ui::BOTTOM | ui::LEFT | ui::RIGHT; } protected: + void onInitTheme(ui::InitThemeEvent& ev) override; void onSizeHint(ui::SizeHintEvent& ev) override; void onPaint(ui::PaintEvent& ev) override; void onClick() override; private: - ui::Style* m_flagStyle; bool m_red; ui::Menu m_popup; };