From 222aa7f3acb1bbc6b118c50b7ecfdb2bada232cf Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Thu, 13 Jun 2024 17:56:51 -0400 Subject: [PATCH] WinUI - TitleBar Subtitle Support --- .../Controls/TitleBar.idl | 2 ++ .../Controls/TitleBar.xaml | 5 ++++- .../Controls/TitleBar.xaml.cpp | 21 +++++++++++++++++++ .../Controls/TitleBar.xaml.h | 16 ++++++++++++++ .../MainWindow.xaml.cpp | 2 +- resources/po/de.po | 6 +++--- resources/po/it.po | 6 +++--- resources/po/pl.po | 6 +++--- resources/po/ru.po | 6 +++--- resources/po/spotlight.pot | 6 +++--- resources/po/ta.po | 6 +++--- resources/po/uk.po | 6 +++--- 12 files changed, 65 insertions(+), 23 deletions(-) diff --git a/org.nickvision.spotlight.winui/Controls/TitleBar.idl b/org.nickvision.spotlight.winui/Controls/TitleBar.idl index 3a459fb..2f7f483 100644 --- a/org.nickvision.spotlight.winui/Controls/TitleBar.idl +++ b/org.nickvision.spotlight.winui/Controls/TitleBar.idl @@ -5,9 +5,11 @@ namespace Nickvision.Spotlight.WinUI.Controls { TitleBar(); static Microsoft.UI.Xaml.DependencyProperty TitleProperty{ get; }; + static Microsoft.UI.Xaml.DependencyProperty SubtitleProperty{ get; }; static Microsoft.UI.Xaml.DependencyProperty TitleForegroundProperty{ get; }; static Microsoft.UI.Xaml.DependencyProperty SearchVisibilityProperty{ get; }; String Title; + String Subtitle; Microsoft.UI.Xaml.Media.Brush TitleForeground; Microsoft.UI.Xaml.Visibility SearchVisibility; Microsoft.UI.Windowing.AppWindow AppWindow; diff --git a/org.nickvision.spotlight.winui/Controls/TitleBar.xaml b/org.nickvision.spotlight.winui/Controls/TitleBar.xaml index 046f27c..a0a3d75 100644 --- a/org.nickvision.spotlight.winui/Controls/TitleBar.xaml +++ b/org.nickvision.spotlight.winui/Controls/TitleBar.xaml @@ -12,6 +12,7 @@ + @@ -22,6 +23,8 @@ - + + + \ No newline at end of file diff --git a/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp b/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp index cf3a366..fe7e6ac 100644 --- a/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp +++ b/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp @@ -17,6 +17,7 @@ using namespace winrt::Windows::Graphics; namespace winrt::Nickvision::Spotlight::WinUI::Controls::implementation { DependencyProperty TitleBar::m_titleProperty = DependencyProperty::Register(L"Title", winrt::xaml_typename(), winrt::xaml_typename(), PropertyMetadata{ winrt::box_value(L""), PropertyChangedCallback{ &TitleBar::OnPropertyChanged } }); + DependencyProperty TitleBar::m_subtitleProperty = DependencyProperty::Register(L"Subtitle", winrt::xaml_typename(), winrt::xaml_typename(), PropertyMetadata{ winrt::box_value(L""), PropertyChangedCallback{ &TitleBar::OnPropertyChanged } }); DependencyProperty TitleBar::m_titleForegroundProperty = DependencyProperty::Register(L"TitleForeground", winrt::xaml_typename(), winrt::xaml_typename(), PropertyMetadata{ winrt::box_value(Microsoft::UI::Xaml::Media::Brush(nullptr)), PropertyChangedCallback{ &TitleBar::OnPropertyChanged } }); DependencyProperty TitleBar::m_searchVisibilityProperty = DependencyProperty::Register(L"SearchVisibility", winrt::xaml_typename(), winrt::xaml_typename(), PropertyMetadata{ winrt::box_value(Visibility::Collapsed), PropertyChangedCallback{ &TitleBar::OnPropertyChanged } }); @@ -42,6 +43,17 @@ namespace winrt::Nickvision::Spotlight::WinUI::Controls::implementation } } + winrt::hstring TitleBar::Subtitle() const + { + return winrt::unbox_value(GetValue(m_subtitleProperty)); + } + + void TitleBar::Subtitle(const winrt::hstring& subtitle) + { + SetValue(m_subtitleProperty, winrt::box_value(subtitle)); + m_propertyChangedEvent(*this, PropertyChangedEventArgs{ L"Subtitle" }); + } + Microsoft::UI::Xaml::Media::Brush TitleBar::TitleForeground() const { return winrt::unbox_value(GetValue(m_titleForegroundProperty)); @@ -172,6 +184,11 @@ namespace winrt::Nickvision::Spotlight::WinUI::Controls::implementation return m_titleProperty; } + const DependencyProperty& TitleBar::SubtitleProperty() + { + return m_subtitleProperty; + } + const DependencyProperty& TitleBar::TitleForegroundProperty() { return m_titleForegroundProperty; @@ -191,6 +208,10 @@ namespace winrt::Nickvision::Spotlight::WinUI::Controls::implementation { ptr->m_propertyChangedEvent(*ptr, PropertyChangedEventArgs{ L"Title" }); } + else if(args.Property() == m_subtitleProperty) + { + ptr->m_propertyChangedEvent(*ptr, PropertyChangedEventArgs{ L"Subtitle" }); + } else if(args.Property() == m_titleForegroundProperty) { ptr->m_propertyChangedEvent(*ptr, PropertyChangedEventArgs{ L"TitleForeground" }); diff --git a/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.h b/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.h index 2609909..f8aac1e 100644 --- a/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.h +++ b/org.nickvision.spotlight.winui/Controls/TitleBar.xaml.h @@ -26,6 +26,16 @@ namespace winrt::Nickvision::Spotlight::WinUI::Controls::implementation * @param title The new title */ void Title(const winrt::hstring& title); + /** + * @brief Gets the subtitle for the titlebar. + * @return The titlebar subtitle + */ + winrt::hstring Subtitle() const; + /** + * @brief Sets the subtitle for the titlebar. + * @param title The new subtitle + */ + void Subtitle(const winrt::hstring& subtitle); /** * @brief Gets the foreground brush for the titlebar. * @return The titlebar foreground brush @@ -117,6 +127,11 @@ namespace winrt::Nickvision::Spotlight::WinUI::Controls::implementation * @return The title dependency property */ static const Microsoft::UI::Xaml::DependencyProperty& TitleProperty(); + /** + * @brief Gets the titlebar's subtitle dependency property. + * @return The subtitle dependency property + */ + static const Microsoft::UI::Xaml::DependencyProperty& SubtitleProperty(); /** * @brief Gets the titlebar's foreground dependency property. * @return The foreground dependency property @@ -136,6 +151,7 @@ namespace winrt::Nickvision::Spotlight::WinUI::Controls::implementation private: static Microsoft::UI::Xaml::DependencyProperty m_titleProperty; + static Microsoft::UI::Xaml::DependencyProperty m_subtitleProperty; static Microsoft::UI::Xaml::DependencyProperty m_titleForegroundProperty; static Microsoft::UI::Xaml::DependencyProperty m_searchVisibilityProperty; }; diff --git a/org.nickvision.spotlight.winui/MainWindow.xaml.cpp b/org.nickvision.spotlight.winui/MainWindow.xaml.cpp index aae1b8a..f1d3875 100644 --- a/org.nickvision.spotlight.winui/MainWindow.xaml.cpp +++ b/org.nickvision.spotlight.winui/MainWindow.xaml.cpp @@ -90,7 +90,7 @@ namespace winrt::Nickvision::Spotlight::WinUI::implementation m_controller->imagesSynced() += [&](const EventArgs& args) { OnImagesSynced(args); }; //Localize Strings TitleBar().Title(winrt::to_hstring(m_controller->getAppInfo().getShortName())); - NavView().PaneTitle(m_controller->isDevVersion() ? winrt::to_hstring(_("PREVIEW")) : L""); + TitleBar().Subtitle(m_controller->isDevVersion() ? winrt::to_hstring(_("Preview")) : L""); LblAppName().Text(winrt::to_hstring(m_controller->getAppInfo().getShortName())); LblAppDescription().Text(winrt::to_hstring(m_controller->getAppInfo().getDescription())); LblAppVersion().Text(winrt::to_hstring(m_controller->getAppInfo().getVersion().str())); diff --git a/resources/po/de.po b/resources/po/de.po index 2b809dd..f3611c5 100644 --- a/resources/po/de.po +++ b/resources/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-06-11 23:06-0400\n" +"POT-Creation-Date: 2024-06-13 17:51-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -76,7 +76,7 @@ msgstr "" msgid "Unable to export images" msgstr "" -#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:120 +#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:132 msgid "Search" msgstr "" @@ -170,7 +170,7 @@ msgid "Export All (Ctrl+Shift+S)" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:93 -msgid "PREVIEW" +msgid "Preview" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:192 diff --git a/resources/po/it.po b/resources/po/it.po index 9eae550..39d0211 100644 --- a/resources/po/it.po +++ b/resources/po/it.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-06-11 23:06-0400\n" +"POT-Creation-Date: 2024-06-13 17:51-0400\n" "PO-Revision-Date: 2024-06-04 18:22+0000\n" "Last-Translator: Nick Logozzo \n" "Language-Team: Italian \n" "Language-Team: LANGUAGE \n" @@ -77,7 +77,7 @@ msgstr "" msgid "Unable to export images" msgstr "" -#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:120 +#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:132 msgid "Search" msgstr "" @@ -171,7 +171,7 @@ msgid "Export All (Ctrl+Shift+S)" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:93 -msgid "PREVIEW" +msgid "Preview" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:192 diff --git a/resources/po/ta.po b/resources/po/ta.po index f360d3c..49c256b 100644 --- a/resources/po/ta.po +++ b/resources/po/ta.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-06-11 23:06-0400\n" +"POT-Creation-Date: 2024-06-13 17:51-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -76,7 +76,7 @@ msgstr "" msgid "Unable to export images" msgstr "" -#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:120 +#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:132 msgid "Search" msgstr "" @@ -170,7 +170,7 @@ msgid "Export All (Ctrl+Shift+S)" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:93 -msgid "PREVIEW" +msgid "Preview" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:192 diff --git a/resources/po/uk.po b/resources/po/uk.po index 6611810..69cb182 100644 --- a/resources/po/uk.po +++ b/resources/po/uk.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-06-11 23:06-0400\n" +"POT-Creation-Date: 2024-06-13 17:51-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -76,7 +76,7 @@ msgstr "" msgid "Unable to export images" msgstr "" -#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:120 +#: org.nickvision.spotlight.winui/Controls/TitleBar.xaml.cpp:132 msgid "Search" msgstr "" @@ -170,7 +170,7 @@ msgid "Export All (Ctrl+Shift+S)" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:93 -msgid "PREVIEW" +msgid "Preview" msgstr "" #: org.nickvision.spotlight.winui/MainWindow.xaml.cpp:192