include/sfx2/sidebar/Theme.hxx | 9 +---- sfx2/inc/bitmaps.hlst | 1 sfx2/source/sidebar/SidebarController.cxx | 47 +++++++++++++++++++++++------- sfx2/source/sidebar/Theme.cxx | 39 +----------------------- 4 files changed, 42 insertions(+), 54 deletions(-)
New commits: commit 2c8ffa41ec8e1ab2af95d5e033a445c17d29cf5a Author: Caolán McNamara <[email protected]> AuthorDate: Tue Feb 16 13:56:04 2021 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Feb 16 17:13:01 2021 +0100 weld sidebar "too-narrow" CloseIndicator Change-Id: Ifda6f56ba51d46bd35065c2230f39e837b037096 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110991 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/include/sfx2/sidebar/Theme.hxx b/include/sfx2/sidebar/Theme.hxx index c59d71233b00..ebacb4322c62 100644 --- a/include/sfx2/sidebar/Theme.hxx +++ b/include/sfx2/sidebar/Theme.hxx @@ -51,11 +51,9 @@ public: enum ThemeItem { Begin_, - Pre_Image_ = Begin_, + Pre_Color_ = Begin_, - AnyItem_ = Pre_Image_, - - Image_CloseIndicator, + AnyItem_ = Pre_Color_, Image_Color_, @@ -92,7 +90,6 @@ public: End_=Post_Bool_ }; - static Image GetImage (const ThemeItem eItem); static Color GetColor (const ThemeItem eItem); static sal_Int32 GetInteger (const ThemeItem eItem); static bool GetBoolean (const ThemeItem eItem); @@ -140,7 +137,6 @@ public: private: static Theme& GetCurrentTheme(); - std::vector<Image> maImages; std::vector<Color> maColors; std::vector<sal_Int32> maIntegers; std::vector<bool> maBooleans; @@ -163,7 +159,6 @@ private: enum PropertyType { - PT_Image, PT_Color, PT_Integer, PT_Boolean, diff --git a/sfx2/inc/bitmaps.hlst b/sfx2/inc/bitmaps.hlst index 7e97d1219996..de8d6555d19d 100644 --- a/sfx2/inc/bitmaps.hlst +++ b/sfx2/inc/bitmaps.hlst @@ -88,6 +88,7 @@ #define SFX_BMP_CLOSE_DOC "sfx2/res/closedoc.png" +#define SIDEBAR_CLOSE_INDICATOR "cmd/lc_decrementlevel.png" #endif diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index b46de16deb08..fdd52a44f783 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -36,7 +36,6 @@ #include <framework/ContextChangeEventMultiplexerTunnel.hxx> #include <vcl/floatwin.hxx> -#include <vcl/fixed.hxx> #include <vcl/uitest/logger.hxx> #include <vcl/uitest/eventdescription.hxx> #include <vcl/svapp.hxx> @@ -61,6 +60,7 @@ #include <com/sun/star/util/URL.hpp> #include <com/sun/star/rendering/XSpriteCanvas.hpp> +#include <bitmaps.hlst> using namespace css; using namespace css::uno; @@ -240,6 +240,40 @@ void SidebarController::disposeDecks() mpResourceManager->disposeDecks(); } +namespace +{ + class CloseIndicator final : public InterimItemWindow + { + public: + CloseIndicator(vcl::Window* pParent) + : InterimItemWindow(pParent, "svt/ui/fixedimagecontrol.ui", "FixedImageControl") + , m_xWidget(m_xBuilder->weld_image("image")) + { + InitControlBase(m_xWidget.get()); + + m_xWidget->set_from_icon_name(SIDEBAR_CLOSE_INDICATOR); + + SetSizePixel(get_preferred_size()); + + SetBackground(Theme::GetColor(Theme::Color_DeckBackground)); + } + + virtual ~CloseIndicator() override + { + disposeOnce(); + } + + virtual void dispose() override + { + m_xWidget.reset(); + InterimItemWindow::dispose(); + } + + private: + std::unique_ptr<weld::Image> m_xWidget; + }; +} + void SAL_CALL SidebarController::disposing() { SolarMutexGuard aSolarMutexGuard; @@ -1438,15 +1472,8 @@ void SidebarController::UpdateCloseIndicator (const bool bCloseAfterDrag) if (bCloseAfterDrag) { // Make sure that the indicator exists. - if ( ! mpCloseIndicator) - { - mpCloseIndicator.reset(VclPtr<FixedImage>::Create(mpParentWindow)); - FixedImage* pFixedImage = static_cast<FixedImage*>(mpCloseIndicator.get()); - const Image aImage (Theme::GetImage(Theme::Image_CloseIndicator)); - pFixedImage->SetImage(aImage); - pFixedImage->SetSizePixel(aImage.GetSizePixel()); - pFixedImage->SetBackground(Theme::GetColor(Theme::Color_DeckBackground)); - } + if (!mpCloseIndicator) + mpCloseIndicator.reset(VclPtr<CloseIndicator>::Create(mpParentWindow)); // Place and show the indicator. const Size aWindowSize (mpParentWindow->GetSizePixel()); diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx index 6ad2b891657c..dd187aa26edc 100644 --- a/sfx2/source/sidebar/Theme.cxx +++ b/sfx2/source/sidebar/Theme.cxx @@ -37,7 +37,6 @@ Theme& Theme::GetCurrentTheme() Theme::Theme() : ThemeInterfaceBase(m_aMutex), - maImages(), maColors(), maIntegers(), maBooleans(), @@ -57,15 +56,6 @@ Theme::~Theme() { } -Image Theme::GetImage (const ThemeItem eItem) -{ - const PropertyType eType (GetPropertyType(eItem)); - OSL_ASSERT(eType==PT_Image); - const sal_Int32 nIndex (GetIndex(eItem, eType)); - const Theme& rTheme (GetCurrentTheme()); - return rTheme.maImages[nIndex]; -} - Color Theme::GetColor (const ThemeItem eItem) { const PropertyType eType (GetPropertyType(eItem)); @@ -196,9 +186,6 @@ void Theme::UpdateTheme() setPropertyValue( maPropertyIdToNameMap[Color_VerticalBorder], Any(sal_Int32(aBorderColor.GetRGBColor()))); - setPropertyValue( - maPropertyIdToNameMap[Image_CloseIndicator], - Any(OUString("private:graphicrepository/cmd/lc_decrementlevel.png"))); } catch(beans::UnknownPropertyException const &) { @@ -485,15 +472,10 @@ sal_Bool SAL_CALL Theme::hasPropertyByName (const OUString& rsPropertyName) void Theme::SetupPropertyMaps() { maPropertyIdToNameMap.resize(Post_Bool_); - maImages.resize(Image_Color_ - Pre_Image_ - 1); - maColors.resize(Color_Int_ - Image_Color_ - 1); + maColors.resize(Color_Int_ - Pre_Color_ - 1); maIntegers.resize(Int_Bool_ - Color_Int_ - 1); maBooleans.resize(Post_Bool_ - Int_Bool_ - 1); - maPropertyNameToIdMap["Image_CloseIndicator"]=Image_CloseIndicator; - maPropertyIdToNameMap[Image_CloseIndicator]="Image_CloseIndicator"; - - maPropertyNameToIdMap["Color_DeckTitleFont"]=Color_DeckTitleFont; maPropertyIdToNameMap[Color_DeckTitleFont]="Color_DeckTitleFont"; @@ -570,9 +552,6 @@ Theme::PropertyType Theme::GetPropertyType (const ThemeItem eItem) { switch(eItem) { - case Image_CloseIndicator: - return PT_Image; - case Color_DeckTitleFont: case Color_PanelTitleFont: case Color_Highlight: @@ -610,9 +589,6 @@ css::uno::Type const & Theme::GetCppuType (const PropertyType eType) { switch(eType) { - case PT_Image: - return cppu::UnoType<OUString>::get(); - case PT_Color: return cppu::UnoType<sal_uInt32>::get(); @@ -632,10 +608,8 @@ sal_Int32 Theme::GetIndex (const ThemeItem eItem, const PropertyType eType) { switch(eType) { - case PT_Image: - return eItem - Pre_Image_-1; case PT_Color: - return eItem - Image_Color_-1; + return eItem - Pre_Color_-1; case PT_Integer: return eItem - Color_Int_-1; case PT_Boolean: @@ -733,15 +707,6 @@ void Theme::ProcessNewValue ( const sal_Int32 nIndex (GetIndex (eItem, eType)); switch (eType) { - case PT_Image: - { - OUString sURL; - if (rValue >>= sURL) - { - maImages[nIndex] = Image(Tools::GetImage(sURL, nullptr)); - } - break; - } case PT_Color: { Color nColorValue; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
