diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-11-04 15:22:53 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-11-12 09:49:09 +0100 |
commit | 64dcfe295762864656bc5876da10bec37b7fb6ec (patch) | |
tree | 4e8ca37b771bfd19a7cc1ae1c8dde264e05cf639 /sfx2/source | |
parent | 590b4e75e3a3d4d415f71c17f2aa2aea2326daf9 (diff) |
weld panel TitleBar
use an expander for the expander-like feature
Change-Id: I3af63dc252479914a0000aab59a30744f8073fd1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105310
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/sidebar/AccessibleTitleBar.cxx | 60 | ||||
-rw-r--r-- | sfx2/source/sidebar/DeckTitleBar.cxx | 134 | ||||
-rw-r--r-- | sfx2/source/sidebar/FocusManager.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/sidebar/Panel.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/sidebar/PanelTitleBar.cxx | 136 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/sidebar/Theme.cxx | 35 | ||||
-rw-r--r-- | sfx2/source/sidebar/TitleBar.cxx | 142 |
8 files changed, 139 insertions, 405 deletions
diff --git a/sfx2/source/sidebar/AccessibleTitleBar.cxx b/sfx2/source/sidebar/AccessibleTitleBar.cxx deleted file mode 100644 index c92fbf59e812..000000000000 --- a/sfx2/source/sidebar/AccessibleTitleBar.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sidebar/AccessibleTitleBar.hxx> -#include <sidebar/Accessible.hxx> -#include <sidebar/TitleBar.hxx> - -#include <com/sun/star/accessibility/AccessibleStateType.hpp> - -#include <unotools/accessiblestatesethelper.hxx> - -using namespace css; -using namespace css::uno; - -namespace sfx2::sidebar { - -Reference<accessibility::XAccessible> AccessibleTitleBar::Create (TitleBar& rTitleBar) -{ - rTitleBar.GetComponentInterface(); - VCLXWindow* pWindow = rTitleBar.GetWindowPeer(); - if (pWindow != nullptr) - return new Accessible(new AccessibleTitleBar(pWindow)); - else - return nullptr; -} - -AccessibleTitleBar::AccessibleTitleBar (VCLXWindow* pWindow) - : VCLXAccessibleComponent(pWindow) -{ -} - -AccessibleTitleBar::~AccessibleTitleBar() -{ -} - -void AccessibleTitleBar::FillAccessibleStateSet (utl::AccessibleStateSetHelper& rStateSet) -{ - VCLXAccessibleComponent::FillAccessibleStateSet(rStateSet); - rStateSet.AddState(accessibility::AccessibleStateType::FOCUSABLE); -} - -} // end of namespace sfx2::sidebar - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/DeckTitleBar.cxx b/sfx2/source/sidebar/DeckTitleBar.cxx index 2d8fcd92b1c2..f7e0a8df7b7e 100644 --- a/sfx2/source/sidebar/DeckTitleBar.cxx +++ b/sfx2/source/sidebar/DeckTitleBar.cxx @@ -22,8 +22,7 @@ #include <sfx2/sfxresid.hxx> #include <sfx2/strings.hrc> -#include <vcl/event.hxx> -#include <vcl/image.hxx> +#include <vcl/customweld.hxx> #include <vcl/ptrstyle.hxx> #ifdef DEBUG @@ -32,19 +31,46 @@ namespace sfx2::sidebar { -namespace +class GripWidget : public weld::CustomWidgetController { -const sal_Int32 gaLeftGripPadding (3); -const sal_Int32 gaRightGripPadding (6); -} +private: + BitmapEx maGrip; +public: + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override + { + weld::CustomWidgetController::SetDrawingArea(pDrawingArea); + StyleUpdated(); + } + + virtual void StyleUpdated() override + { + maGrip = BitmapEx("sfx2/res/grip.png"); + Size aGripSize(maGrip.GetSizePixel()); + set_size_request(aGripSize.Width(), aGripSize.Height()); + weld::CustomWidgetController::StyleUpdated(); + } + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) override + { + rRenderContext.SetBackground(Theme::GetColor(Theme::Color_DeckTitleBarBackground)); + rRenderContext.DrawBitmapEx(Point(0, 0), maGrip); + } +}; DeckTitleBar::DeckTitleBar (const OUString& rsTitle, vcl::Window* pParentWindow, const std::function<void()>& rCloserAction) - : TitleBar(rsTitle, pParentWindow, GetBackgroundPaintColor()) + : TitleBar(pParentWindow, "sfx/ui/decktitlebar.ui", "DeckTitleBar", + Theme::Color_DeckTitleBarBackground) + , mxGripWidget(new GripWidget) + , mxGripWeld(new weld::CustomWeld(*m_xBuilder, "grip", *mxGripWidget)) + , mxLabel(m_xBuilder->weld_label("label")) , maCloserAction(rCloserAction) , mbIsCloserVisible(false) { + mxLabel->set_label(rsTitle); + mxGripWidget->SetPointer(PointerStyle::Move); + OSL_ASSERT(pParentWindow != nullptr); if (maCloserAction) @@ -55,91 +81,69 @@ DeckTitleBar::DeckTitleBar (const OUString& rsTitle, #endif } -void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible) +DeckTitleBar::~DeckTitleBar() { - if (mbIsCloserVisible == bIsCloserVisible) - return; - - mbIsCloserVisible = bIsCloserVisible; - - if (mbIsCloserVisible) - { - maToolBox->InsertItem(mnCloserItemIndex, - Theme::GetImage(Theme::Image_Closer)); - maToolBox->SetQuickHelpText(mnCloserItemIndex, - SfxResId(SFX_STR_SIDEBAR_CLOSE_DECK)); - } - else - maToolBox->RemoveItem(maToolBox->GetItemPos(mnCloserItemIndex)); + disposeOnce(); } -tools::Rectangle DeckTitleBar::GetTitleArea (const tools::Rectangle& rTitleBarBox) +void DeckTitleBar::dispose() { - Image aGripImage (Theme::GetImage(Theme::Image_Grip)); - return tools::Rectangle( - aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding, - rTitleBarBox.Top(), - rTitleBarBox.Right(), - rTitleBarBox.Bottom()); + mxLabel.reset(); + mxGripWeld.reset(); + mxGripWidget.reset(); + TitleBar::dispose(); } tools::Rectangle DeckTitleBar::GetDragArea() { - Image aGripImage (Theme::GetImage(Theme::Image_Grip)); - return tools::Rectangle(0,0, - aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding, - aGripImage.GetSizePixel().Height() - ); + int x, y, width, height; + if (mxGripWidget->GetDrawingArea()->get_extents_relative_to(*m_xContainer, x, y, width, height)) + return tools::Rectangle(Point(x, y), Size(width, height)); + return tools::Rectangle(); } -void DeckTitleBar::PaintDecoration(vcl::RenderContext& rRenderContext) +void DeckTitleBar::SetTitle(const OUString& rsTitle) { - Image aImage (Theme::GetImage(Theme::Image_Grip)); - const Point aTopLeft(gaLeftGripPadding, - (GetSizePixel().Height() - aImage.GetSizePixel().Height()) / 2); - rRenderContext.DrawImage(aTopLeft, aImage); + mxLabel->set_label(rsTitle); } -Color DeckTitleBar::GetBackgroundPaintColor() +OUString DeckTitleBar::GetTitle() const { - return Theme::GetColor(Theme::Color_DeckTitleBarBackground); + return mxLabel->get_label(); } -void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) +void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible) { - if (nItemIndex == mnCloserItemIndex && maCloserAction) - maCloserAction(); + if (mbIsCloserVisible == bIsCloserVisible) + return; + + mbIsCloserVisible = bIsCloserVisible; + + if (mbIsCloserVisible) + { + mxToolBox->set_item_visible("button", true); + mxToolBox->set_item_icon_name("button", "sfx2/res/closedoc.png"); + mxToolBox->set_item_tooltip_text("button", + SfxResId(SFX_STR_SIDEBAR_CLOSE_DECK)); + } + else + { + mxToolBox->set_item_visible("button", false); + } } -css::uno::Reference<css::accessibility::XAccessible> DeckTitleBar::CreateAccessible() +void DeckTitleBar::HandleToolBoxItemClick() { - SetAccessibleName(msTitle); - SetAccessibleDescription(msTitle); - return TitleBar::CreateAccessible(); + if (maCloserAction) + maCloserAction(); } void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent) { - maToolBox->SetItemImage( - mnCloserItemIndex, - Theme::GetImage(Theme::Image_Closer)); + mxToolBox->set_item_icon_name("button", "sfx2/res/closedoc.png"); TitleBar::DataChanged(rEvent); } - -void DeckTitleBar::MouseMove (const MouseEvent& rMouseEvent) -{ - tools::Rectangle aGrip = GetDragArea(); - PointerStyle eStyle = PointerStyle::Arrow; - - if ( aGrip.IsInside( rMouseEvent.GetPosPixel() ) ) - eStyle = PointerStyle::Move; - - SetPointer( eStyle ); - - Window::MouseMove( rMouseEvent ); -} - } // end of namespace sfx2::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx index 4a5140c1ae17..7c6ab781ff83 100644 --- a/sfx2/source/sidebar/FocusManager.cxx +++ b/sfx2/source/sidebar/FocusManager.cxx @@ -78,7 +78,6 @@ void FocusManager::ClearPanels() if (panel->GetTitleBar()) { UnregisterWindow(*panel->GetTitleBar()); - UnregisterWindow(panel->GetTitleBar()->GetToolBox()); } panel->RemoveChildEventListener(LINK(this, FocusManager, ChildEventListener)); @@ -100,14 +99,12 @@ void FocusManager::SetDeckTitle (DeckTitleBar* pDeckTitleBar) if (mpDeckTitleBar != nullptr) { UnregisterWindow(*mpDeckTitleBar); - UnregisterWindow(mpDeckTitleBar->GetToolBox()); } mpDeckTitleBar = pDeckTitleBar; if (mpDeckTitleBar != nullptr) { RegisterWindow(*mpDeckTitleBar); - RegisterWindow(mpDeckTitleBar->GetToolBox()); } } @@ -120,7 +117,6 @@ void FocusManager::SetPanels (const SharedPanelContainer& rPanels) if (panel->GetTitleBar()) { RegisterWindow(*panel->GetTitleBar()); - RegisterWindow(panel->GetTitleBar()->GetToolBox()); } // Register also as child event listener at the panel. @@ -157,8 +153,6 @@ FocusManager::FocusLocation FocusManager::GetFocusLocation (const vcl::Window& r { if (mpDeckTitleBar == &rWindow) return FocusLocation(PC_DeckTitle, -1); - else if (&mpDeckTitleBar->GetToolBox() == &rWindow) - return FocusLocation(PC_DeckToolBox, -1); } // Search the panels. @@ -169,8 +163,6 @@ FocusManager::FocusLocation FocusManager::GetFocusLocation (const vcl::Window& r VclPtr<TitleBar> pTitleBar = maPanels[nIndex]->GetTitleBar(); if (pTitleBar == &rWindow) return FocusLocation(PC_PanelTitle, nIndex); - if (pTitleBar!=nullptr && &pTitleBar->GetToolBox()==&rWindow) - return FocusLocation(PC_PanelToolBox, nIndex); } // Search the buttons. @@ -190,11 +182,10 @@ void FocusManager::FocusDeckTitle() { mpDeckTitleBar->GrabFocus(); } - else if (mpDeckTitleBar->GetToolBox().GetItemCount() > 0) + else if (mpDeckTitleBar->GetToolBox().get_n_items() > 0) { - ToolBox& rToolBox = mpDeckTitleBar->GetToolBox(); - rToolBox.GrabFocus(); - rToolBox.Invalidate(); + weld::Toolbar& rToolBox = mpDeckTitleBar->GetToolBox(); + rToolBox.grab_focus(); } else FocusPanel(0, false); @@ -293,7 +284,6 @@ void FocusManager::RemoveWindow (vcl::Window& rWindow) if ((*iPanel)->GetTitleBar() != nullptr) { UnregisterWindow(*(*iPanel)->GetTitleBar()); - UnregisterWindow((*iPanel)->GetTitleBar()->GetToolBox()); } maPanels.erase(iPanel); return; @@ -313,12 +303,12 @@ void FocusManager::MoveFocusInsidePanel ( const sal_Int32 nDirection) { const bool bHasToolBoxItem ( - maPanels[rFocusLocation.mnIndex]->GetTitleBar()->GetToolBox().GetItemCount() > 0); + maPanels[rFocusLocation.mnIndex]->GetTitleBar()->GetToolBox().get_n_items() > 0); switch (rFocusLocation.meComponent) { case PC_PanelTitle: if (nDirection > 0 && bHasToolBoxItem) - maPanels[rFocusLocation.mnIndex]->GetTitleBar()->GetToolBox().GrabFocus(); + maPanels[rFocusLocation.mnIndex]->GetTitleBar()->GetToolBox().grab_focus(); else FocusPanelContent(rFocusLocation.mnIndex); break; @@ -343,14 +333,14 @@ void FocusManager::MoveFocusInsideDeckTitle ( // is moved between a) deck title, b) deck closer and c) content // of panel 0. const bool bHasToolBoxItem ( - mpDeckTitleBar->GetToolBox().GetItemCount() > 0); + mpDeckTitleBar->GetToolBox().get_n_items() > 0); switch (rFocusLocation.meComponent) { case PC_DeckTitle: if (nDirection<0 && ! IsPanelTitleVisible(0)) FocusPanelContent(0); else if (bHasToolBoxItem) - mpDeckTitleBar->GetToolBox().GrabFocus(); + mpDeckTitleBar->GetToolBox().grab_focus(); break; case PC_DeckToolBox: diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx index c4de2280f891..c45a1e5efd42 100644 --- a/sfx2/source/sidebar/Panel.cxx +++ b/sfx2/source/sidebar/Panel.cxx @@ -51,7 +51,6 @@ Panel::Panel(const PanelDescriptor& rPanelDescriptor, ) : Window(pParentWindow) , msPanelId(rPanelDescriptor.msId) - , mpTitleBar(VclPtr<PanelTitleBar>::Create(rPanelDescriptor.msTitle, pParentWindow, this)) , mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional) , mxElement() , mxPanelComponent() @@ -60,6 +59,7 @@ Panel::Panel(const PanelDescriptor& rPanelDescriptor, , maDeckLayoutTrigger(rDeckLayoutTrigger) , maContextAccess(rContextAccess) , mxFrame(rxFrame) + , mpTitleBar(VclPtr<PanelTitleBar>::Create(rPanelDescriptor.msTitle, pParentWindow, this)) { SetText(rPanelDescriptor.msTitle); } @@ -134,6 +134,7 @@ void Panel::SetExpanded (const bool bIsExpanded) return; mbIsExpanded = bIsExpanded; + mpTitleBar->UpdateExpandedState(); maDeckLayoutTrigger(); if (maContextAccess && pSidebarController) diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx b/sfx2/source/sidebar/PanelTitleBar.cxx index 4dbb787cd3bd..3cf1cff8fbb1 100644 --- a/sfx2/source/sidebar/PanelTitleBar.cxx +++ b/sfx2/source/sidebar/PanelTitleBar.cxx @@ -36,25 +36,43 @@ using namespace css::uno; namespace sfx2::sidebar { -const sal_Int32 gaLeftIconPadding (5); -const sal_Int32 gaRightIconPadding (5); - PanelTitleBar::PanelTitleBar(const OUString& rsTitle, vcl::Window* pParentWindow, Panel* pPanel) - : TitleBar(rsTitle, pParentWindow, GetBackgroundPaintColor()), - mbIsLeftButtonDown(false), + : TitleBar(pParentWindow, "sfx/ui/paneltitlebar.ui", "PanelTitleBar", + Theme::Color_PanelTitleBarBackground), + mxExpander(m_xBuilder->weld_expander("expander")), mpPanel(pPanel), mxFrame(), msMoreOptionsCommand() { - OSL_ASSERT(mpPanel != nullptr); + mxExpander->set_label(rsTitle); + mxExpander->connect_expanded(LINK(this, PanelTitleBar, ExpandHdl)); + + assert(mpPanel); + + UpdateExpandedState(); #ifdef DEBUG SetText(OUString("PanelTitleBar")); #endif } +void PanelTitleBar::SetTitle(const OUString& rsTitle) +{ + mxExpander->set_label(rsTitle); +} + +OUString PanelTitleBar::GetTitle() const +{ + return mxExpander->get_label(); +} + +void PanelTitleBar::UpdateExpandedState() +{ + mxExpander->set_expanded(mpPanel->IsExpanded()); +} + PanelTitleBar::~PanelTitleBar() { disposeOnce(); @@ -63,18 +81,18 @@ PanelTitleBar::~PanelTitleBar() void PanelTitleBar::dispose() { mpPanel.clear(); + mxExpander.reset(); TitleBar::dispose(); } void PanelTitleBar::SetMoreOptionsCommand(const OUString& rsCommandName, - const css::uno::Reference<css::frame::XFrame>& rxFrame, - const css::uno::Reference<css::frame::XController>& rxController) + const css::uno::Reference<css::frame::XFrame>& rxFrame) { if (rsCommandName == msMoreOptionsCommand) return; if (msMoreOptionsCommand.getLength() > 0) - maToolBox->RemoveItem(maToolBox->GetItemPos(mnMenuItemIndex)); + mxToolBox->set_item_visible("button", false); msMoreOptionsCommand = rsCommandName; mxFrame = rxFrame; @@ -82,63 +100,15 @@ void PanelTitleBar::SetMoreOptionsCommand(const OUString& rsCommandName, if (msMoreOptionsCommand.getLength() <= 0) return; - maToolBox->InsertItem( - mnMenuItemIndex, - Theme::GetImage(Theme::Image_PanelMenu)); - Reference<frame::XToolbarController> xController ( - ControllerFactory::CreateToolBoxController( - maToolBox.get(), - mnMenuItemIndex, - msMoreOptionsCommand, - rxFrame, rxController, - VCLUnoHelper::GetInterface(maToolBox.get()), - 0, true)); - maToolBox->SetController(mnMenuItemIndex, xController); - maToolBox->SetQuickHelpText( - mnMenuItemIndex, + mxToolBox->set_item_visible("button", true); + mxToolBox->set_item_icon_name("button", "sfx2/res/symphony/morebutton.png"); + mxToolBox->set_item_tooltip_text( + "button", SfxResId(SFX_STR_SIDEBAR_MORE_OPTIONS)); } -tools::Rectangle PanelTitleBar::GetTitleArea (const tools::Rectangle& rTitleBarBox) -{ - if (mpPanel != nullptr) - { - Image aImage (mpPanel->IsExpanded() - ? Theme::GetImage(Theme::Image_Expand) - : Theme::GetImage(Theme::Image_Collapse)); - return tools::Rectangle( - aImage.GetSizePixel().Width() + gaLeftIconPadding + gaRightIconPadding, - rTitleBarBox.Top(), - rTitleBarBox.Right(), - rTitleBarBox.Bottom()); - } - else - return rTitleBarBox; -} - -void PanelTitleBar::PaintDecoration (vcl::RenderContext& rRenderContext) +void PanelTitleBar::HandleToolBoxItemClick() { - if (mpPanel != nullptr) - { - Image aImage (mpPanel->IsExpanded() - ? Theme::GetImage(Theme::Image_Collapse) - : Theme::GetImage(Theme::Image_Expand)); - const Point aTopLeft(gaLeftIconPadding, - (GetSizePixel().Height() - aImage.GetSizePixel().Height()) / 2); - rRenderContext.DrawImage(aTopLeft, aImage); - } -} - -Color PanelTitleBar::GetBackgroundPaintColor() -{ - return Theme::GetColor(Theme::Color_PanelTitleBarBackground); -} - -void PanelTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) -{ - if (nItemIndex != mnMenuItemIndex) - return; - if (msMoreOptionsCommand.getLength() <= 0) return; @@ -155,48 +125,16 @@ void PanelTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) } } -Reference<accessibility::XAccessible> PanelTitleBar::CreateAccessible() -{ - SetAccessibleName(msTitle); - SetAccessibleDescription(msTitle); - return TitleBar::CreateAccessible(); -} - -void PanelTitleBar::MouseButtonDown (const MouseEvent& rMouseEvent) +IMPL_LINK(PanelTitleBar, ExpandHdl, weld::Expander&, rExpander, void) { - if (rMouseEvent.IsLeft()) - { - mbIsLeftButtonDown = true; - CaptureMouse(); - } -} - -void PanelTitleBar::MouseButtonUp (const MouseEvent& rMouseEvent) -{ - if (IsMouseCaptured()) - ReleaseMouse(); - - if (rMouseEvent.IsLeft()) - { - if (mbIsLeftButtonDown) - { - if (mpPanel != nullptr) - { - mpPanel->SetExpanded( ! mpPanel->IsExpanded()); - Invalidate(); - GrabFocus(); - } - } - } - if (mbIsLeftButtonDown) - mbIsLeftButtonDown = false; + if (!mpPanel) + return; + mpPanel->SetExpanded(rExpander.get_expanded()); } void PanelTitleBar::DataChanged (const DataChangedEvent& rEvent) { - maToolBox->SetItemImage( - mnMenuItemIndex, - Theme::GetImage(Theme::Image_PanelMenu)); + mxToolBox->set_item_icon_name("button", "sfx2/res/symphony/morebutton.png"); TitleBar::DataChanged(rEvent); } diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 435ea63150d3..8a0e851cff66 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -734,7 +734,7 @@ void SidebarController::CreatePanels(const OUString& rDeckId, const Context& rCo { pTitleBar->SetMoreOptionsCommand( rPanelContexDescriptor.msMenuCommand, - mxFrame, xController); + mxFrame); } ++nWriteIndex; } @@ -1575,17 +1575,15 @@ void SidebarController::FadeIn() tools::Rectangle SidebarController::GetDeckDragArea() const { tools::Rectangle aRect; - - if(mpCurrentDeck) + if (mpCurrentDeck) { VclPtr<DeckTitleBar> pTitleBar(mpCurrentDeck->GetTitleBar()); - if(pTitleBar) + if (pTitleBar) { - aRect = DeckTitleBar::GetDragArea(); + aRect = pTitleBar->GetDragArea(); } } - return aRect; } diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx index da66a71c292d..361a77414a8e 100644 --- a/sfx2/source/sidebar/Theme.cxx +++ b/sfx2/source/sidebar/Theme.cxx @@ -241,24 +241,9 @@ void Theme::UpdateTheme() maPropertyIdToNameMap[Color_VerticalBorder], Any(sal_Int32(aBorderColor.GetRGBColor()))); setPropertyValue( - maPropertyIdToNameMap[Image_Grip], - Any(OUString("private:graphicrepository/sfx2/res/grip.png"))); - setPropertyValue( - maPropertyIdToNameMap[Image_Expand], - Any(OUString("private:graphicrepository/res/plus.png"))); - setPropertyValue( - maPropertyIdToNameMap[Image_Collapse], - Any(OUString("private:graphicrepository/res/minus.png"))); - setPropertyValue( maPropertyIdToNameMap[Image_TabBarMenu], Any(OUString("private:graphicrepository/sfx2/res/symphony/open_more.png"))); setPropertyValue( - maPropertyIdToNameMap[Image_PanelMenu], - Any(OUString("private:graphicrepository/sfx2/res/symphony/morebutton.png"))); - setPropertyValue( - maPropertyIdToNameMap[Image_Closer], - Any(OUString("private:graphicrepository/sfx2/res/closedoc.png"))); - setPropertyValue( maPropertyIdToNameMap[Image_CloseIndicator], Any(OUString("private:graphicrepository/cmd/lc_decrementlevel.png"))); } @@ -532,24 +517,9 @@ void Theme::SetupPropertyMaps() maIntegers.resize(Int_Bool_ - Color_Int_ - 1); maBooleans.resize(Post_Bool_ - Int_Bool_ - 1); - maPropertyNameToIdMap["Image_Grip"]=Image_Grip; - maPropertyIdToNameMap[Image_Grip]="Image_Grip"; - - maPropertyNameToIdMap["Image_Expand"]=Image_Expand; - maPropertyIdToNameMap[Image_Expand]="Image_Expand"; - - maPropertyNameToIdMap["Image_Collapse"]=Image_Collapse; - maPropertyIdToNameMap[Image_Collapse]="Image_Collapse"; - maPropertyNameToIdMap["Image_TabBarMenu"]=Image_TabBarMenu; maPropertyIdToNameMap[Image_TabBarMenu]="Image_TabBarMenu"; - maPropertyNameToIdMap["Image_PanelMenu"]=Image_PanelMenu; - maPropertyIdToNameMap[Image_PanelMenu]="Image_PanelMenu"; - - maPropertyNameToIdMap["Image_Closer"]=Image_Closer; - maPropertyIdToNameMap[Image_Closer]="Image_Closer"; - maPropertyNameToIdMap["Image_CloseIndicator"]=Image_CloseIndicator; maPropertyIdToNameMap[Image_CloseIndicator]="Image_CloseIndicator"; @@ -672,12 +642,7 @@ Theme::PropertyType Theme::GetPropertyType (const ThemeItem eItem) { switch(eItem) { - case Image_Grip: - case Image_Expand: - case Image_Collapse: case Image_TabBarMenu: - case Image_PanelMenu: - case Image_Closer: case Image_CloseIndicator: return PT_Image; diff --git a/sfx2/source/sidebar/TitleBar.cxx b/sfx2/source/sidebar/TitleBar.cxx index 5324857c56cc..615cb6de3b7b 100644 --- a/sfx2/source/sidebar/TitleBar.cxx +++ b/sfx2/source/sidebar/TitleBar.cxx @@ -18,28 +18,22 @@ */ #include <sidebar/TitleBar.hxx> -#include <sidebar/AccessibleTitleBar.hxx> - -#include <com/sun/star/accessibility/AccessibleRole.hpp> - -namespace -{ - const sal_Int32 gnLeftIconSpace (3); - const sal_Int32 gnRightIconSpace (3); -} namespace sfx2::sidebar { -TitleBar::TitleBar(const OUString& rsTitle, - vcl::Window* pParentWindow, - const Color& rInitialBackgroundColor) - : Window(pParentWindow) - , maToolBox(VclPtr<SidebarToolBox>::Create(this)) - , msTitle(rsTitle) - , maIcon() - , maBackgroundColor(rInitialBackgroundColor) +TitleBar::TitleBar(vcl::Window* pParentWindow, + const OUString& rUIXMLDescription, const OString& rID, + Theme::ThemeItem eThemeItem) + : InterimItemWindow(pParentWindow, rUIXMLDescription, rID) + , mxAddonImage(m_xBuilder->weld_image("addonimage")) + , mxToolBox(m_xBuilder->weld_toolbar("toolbar")) + , meThemeItem(eThemeItem) { - maToolBox->SetSelectHdl(LINK(this, TitleBar, SelectionHandler)); + Color aBgColor = Theme::GetColor(meThemeItem); + m_xContainer->set_background(aBgColor); + mxToolBox->set_background(aBgColor); + + mxToolBox->connect_clicked(LINK(this, TitleBar, SelectionHandler)); } TitleBar::~TitleBar() @@ -49,121 +43,25 @@ TitleBar::~TitleBar() void TitleBar::dispose() { - maToolBox.disposeAndClear(); - vcl::Window::dispose(); -} - -void TitleBar::SetTitle(const OUString& rsTitle) -{ - msTitle = rsTitle; - Invalidate(); + mxToolBox.reset(); + mxAddonImage.reset(); + InterimItemWindow::dispose(); } void TitleBar::SetIcon(const css::uno::Reference<css::graphic::XGraphic>& rIcon) { - maIcon = Image(rIcon); - Invalidate(); -} - -void TitleBar::ApplySettings(vcl::RenderContext& rRenderContext) -{ - rRenderContext.SetBackground(maBackgroundColor); -} - -void TitleBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rUpdateArea*/) -{ - // Paint title bar background. - Size aWindowSize (GetSizePixel()); - tools::Rectangle aTitleBarBox(0,0, aWindowSize.Width(), aWindowSize.Height()); - - PaintDecoration(rRenderContext); - const tools::Rectangle aTitleBox(GetTitleArea(aTitleBarBox)); - PaintTitle(rRenderContext, aTitleBox); - PaintFocus(rRenderContext, aTitleBox); + mxAddonImage->set_image(rIcon); + mxAddonImage->set_visible(rIcon.is()); } void TitleBar::DataChanged (const DataChangedEvent& /*rEvent*/) { - maBackgroundColor = GetBackgroundPaintColor(); - Invalidate(); -} - -void TitleBar::setPosSizePixel (tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags) -{ - Window::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags); - - // Place the toolbox. - const sal_Int32 nToolBoxWidth (maToolBox->GetItemPosRect(0).GetWidth()); - maToolBox->setPosSizePixel(nWidth - nToolBoxWidth,0, nToolBoxWidth, nHeight); - maToolBox->Show(); + m_xContainer->set_background(Theme::GetColor(meThemeItem)); } -void TitleBar::HandleToolBoxItemClick(const sal_uInt16 /*nItemIndex*/) +IMPL_LINK_NOARG(TitleBar, SelectionHandler, const OString&, void) { - // Any real processing has to be done in derived class. -} - -css::uno::Reference<css::accessibility::XAccessible> TitleBar::CreateAccessible() -{ - SetAccessibleRole(css::accessibility::AccessibleRole::PANEL); - return AccessibleTitleBar::Create(*this); -} - -void TitleBar::PaintTitle(vcl::RenderContext& rRenderContext, const tools::Rectangle& rTitleBox) -{ - rRenderContext.Push(PushFlags::FONT | PushFlags::TEXTCOLOR); - - tools::Rectangle aTitleBox(rTitleBox); - - // When there is an icon then paint it at the left of the given - // box. - if (!!maIcon) - { - rRenderContext.DrawImage(Point(aTitleBox.Left() + gnLeftIconSpace, - aTitleBox.Top() + (aTitleBox.GetHeight() - maIcon.GetSizePixel().Height()) / 2), - maIcon); - aTitleBox.AdjustLeft(gnLeftIconSpace + maIcon.GetSizePixel().Width() + gnRightIconSpace ); - } - - vcl::Font aFont(rRenderContext.GetFont()); - aFont.SetWeight(WEIGHT_BOLD); - rRenderContext.SetFont(aFont); - - // Paint title bar text. - rRenderContext.SetTextColor(rRenderContext.GetTextColor()); - rRenderContext.DrawText(aTitleBox, msTitle, DrawTextFlags::Left | DrawTextFlags::VCenter); - rRenderContext.Pop(); -} - -void TitleBar::PaintFocus(vcl::RenderContext& rRenderContext, const tools::Rectangle& rFocusBox) -{ - rRenderContext.Push(PushFlags::FONT | PushFlags::TEXTCOLOR); - - vcl::Font aFont(rRenderContext.GetFont()); - aFont.SetWeight(WEIGHT_BOLD); - rRenderContext.SetFont(aFont); - - const tools::Rectangle aTextBox(rRenderContext.GetTextRect(rFocusBox, msTitle, DrawTextFlags::Left | DrawTextFlags::VCenter)); - - const tools::Rectangle aLargerTextBox(aTextBox.Left() - 2, - aTextBox.Top() - 2, - aTextBox.Right() + 2, - aTextBox.Bottom() + 2); - - if (HasFocus()) - Window::ShowFocus(aLargerTextBox); - else - Window::HideFocus(); - - rRenderContext.Pop(); -} - -IMPL_LINK(TitleBar, SelectionHandler, ToolBox*, pToolBox, void) -{ - OSL_ASSERT(maToolBox.get()==pToolBox); - const sal_uInt16 nItemId (maToolBox->GetHighlightItemId()); - - HandleToolBoxItemClick(nItemId); + HandleToolBoxItemClick(); } } // end of namespace sfx2::sidebar |