From f0c9db7041f05a635fa4115d43d7fdeff746e608 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 17 Jun 2020 12:40:11 -0300 Subject: [PATCH] Don't show the notification flag on Advanced Mode --- src/app/ui/main_window.cpp | 3 ++- src/app/ui/notifications.cpp | 9 +++++---- src/app/ui/notifications.h | 4 +++- src/ui/widget.h | 5 +++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/ui/main_window.cpp b/src/app/ui/main_window.cpp index a79dac62b..d2c264b04 100644 --- a/src/app/ui/main_window.cpp +++ b/src/app/ui/main_window.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2019 Igara Studio S.A. +// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -533,6 +533,7 @@ void MainWindow::configureWorkspaceLayout() } m_menuBar->setVisible(normal); + m_notifications->setVisible(normal && m_notifications->hasNotifications()); m_tabsBar->setVisible(normal); colorBarPlaceholder()->setVisible(normal && isDoc); m_toolBar->setVisible(normal && isDoc); diff --git a/src/app/ui/notifications.cpp b/src/app/ui/notifications.cpp index 23b59d765..95eb3263d 100644 --- a/src/app/ui/notifications.cpp +++ b/src/app/ui/notifications.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -41,14 +42,14 @@ private: Notifications::Notifications() : Button("") , m_flagStyle(skin::SkinTheme::instance()->styles.flag()) - , m_withNotifications(false) + , m_red(false) { } void Notifications::addLink(INotificationDelegate* del) { m_popup.addChild(new NotificationItem(del)); - m_withNotifications = true; + m_red = true; } void Notifications::onSizeHint(SizeHintEvent& ev) @@ -62,7 +63,7 @@ void Notifications::onPaint(PaintEvent& ev) PaintWidgetPartInfo info; if (hasMouseOver()) info.styleFlags |= ui::Style::Layer::kMouse; - if (m_withNotifications) info.styleFlags |= ui::Style::Layer::kFocus; + if (m_red) info.styleFlags |= ui::Style::Layer::kFocus; if (isSelected()) info.styleFlags |= ui::Style::Layer::kSelected; theme()->paintWidgetPart( @@ -71,7 +72,7 @@ void Notifications::onPaint(PaintEvent& ev) void Notifications::onClick(ui::Event& ev) { - m_withNotifications = false; + m_red = false; invalidate(); gfx::Rect bounds = this->bounds(); diff --git a/src/app/ui/notifications.h b/src/app/ui/notifications.h index b70ca45d0..31e8ffef9 100644 --- a/src/app/ui/notifications.h +++ b/src/app/ui/notifications.h @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -23,6 +24,7 @@ namespace app { Notifications(); void addLink(INotificationDelegate* del); + bool hasNotifications() const { return m_popup.hasChildren(); } protected: void onSizeHint(ui::SizeHintEvent& ev) override; @@ -31,7 +33,7 @@ namespace app { private: ui::Style* m_flagStyle; - bool m_withNotifications; + bool m_red; ui::Menu m_popup; }; diff --git a/src/ui/widget.h b/src/ui/widget.h index a421c9365..3b04a3c69 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -167,16 +167,17 @@ namespace ui { // Returns a list of children. const WidgetsList& children() const { return m_children; } + bool hasChildren() const { return !m_children.empty(); } Widget* at(int index) { return m_children[index]; } int getChildIndex(Widget* child); // Returns the first/last child or nullptr if it doesn't exist. Widget* firstChild() { - return (!m_children.empty() ? m_children.front(): nullptr); + return (hasChildren() ? m_children.front(): nullptr); } Widget* lastChild() { - return (!m_children.empty() ? m_children.back(): nullptr); + return (hasChildren() ? m_children.back(): nullptr); } // Returns the next or previous siblings.