diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-10-04 15:39:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-10-04 17:25:13 +0100 |
commit | 5d812cae7eacccb7819a46ae45c577295db9f190 (patch) | |
tree | d04e8dbaafedca13e1014d0c04d6234cdfa0f04c /svx/source/sidebar | |
parent | 7e61e1d644270f05664d358abeffbc8f72b01a96 (diff) |
These are just floating windows, no need for all the special intrastructure
get rid of the roundabout way that these popups are popup controllers
(of a kind) for real popups
for the moment keeping them as loaded from resources
Change-Id: I083e8609ab133e3dc4a036daf8bfb44c08a6719f
Diffstat (limited to 'svx/source/sidebar')
-rw-r--r-- | svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 18 | ||||
-rw-r--r-- | svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx | 25 | ||||
-rw-r--r-- | svx/source/sidebar/tools/Popup.cxx | 129 |
3 files changed, 20 insertions, 152 deletions
diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index d9ef7c235332..6cb5b08c2254 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -95,7 +95,6 @@ AreaPropertyPanelBase::AreaPropertyPanelBase( maImgRadial(SVX_RES(IMG_RADIAL)), maImgSquare(SVX_RES(IMG_SQUARE)), maImgLinear(SVX_RES(IMG_LINEAR)), - maTrGrPopup(this, [this] (PopupContainer *const pContainer) { return this->CreateTransparencyGradientControl(pContainer); }), mpFloatTransparenceItem(), mpTransparanceItem(), mxFrame(rxFrame), @@ -126,6 +125,7 @@ AreaPropertyPanelBase::~AreaPropertyPanelBase() void AreaPropertyPanelBase::dispose() { + mxTrGrPopup.disposeAndClear(); mpColorTextFT.clear(); mpLbFillType.clear(); mpLbFillAttr.clear(); @@ -495,11 +495,6 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, ChangeGradientAngle, Edit&, void) SelectFillAttrHdl_Impl(); } -VclPtr<Control> AreaPropertyPanelBase::CreateTransparencyGradientControl (PopupContainer* pParent) -{ - return VclPtrInstance<AreaTransparencyGradientControl>(pParent, *this); -} - void AreaPropertyPanelBase::DataChanged( const DataChangedEvent& /*rEvent*/) { @@ -675,9 +670,9 @@ void AreaPropertyPanelBase::ImpUpdateTransparencies() SetTransparency(nValue); } - if(!bZeroValue) + if (!bZeroValue && mxTrGrPopup) { - maTrGrPopup.Hide(); + mxTrGrPopup->EndPopupMode(); } } @@ -1327,9 +1322,12 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, ModifyTransSliderHdl, Slider*, void IMPL_LINK_TYPED( AreaPropertyPanelBase, ClickTrGrHdl_Impl, ToolBox*, pToolBox, void ) { - maTrGrPopup.Rearrange(mpFloatTransparenceItem.get()); + if (!mxTrGrPopup) + mxTrGrPopup = VclPtr<AreaTransparencyGradientPopup>::Create(pToolBox, *this); + mxTrGrPopup->Rearrange(mpFloatTransparenceItem.get()); OSL_ASSERT( pToolBox->GetItemCommand(pToolBox->GetCurItemId()) == UNO_SIDEBARGRADIENT); - maTrGrPopup.Show(*pToolBox); + mxTrGrPopup->StartPopupMode(pToolBox, FloatWinPopupFlags::Down | + FloatWinPopupFlags::NoAppFocusClose); } IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, ChangeTrgrTypeHdl_Impl, ListBox&, void) diff --git a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx index 5dfe37c63362..0e646833711d 100644 --- a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx +++ b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx @@ -21,29 +21,28 @@ namespace svx { namespace sidebar { -AreaTransparencyGradientPopup::AreaTransparencyGradientPopup ( - vcl::Window* pParent, - const ::std::function<Control* (PopupContainer*)>& rControlCreator) - : Popup( - pParent, - rControlCreator, - OUString( "Transparency and Gradient")) +AreaTransparencyGradientPopup::AreaTransparencyGradientPopup(vcl::Window* pParent, AreaPropertyPanelBase& rPanel) + : FloatingWindow(pParent, WB_BORDER | WB_SYSTEMWINDOW) + , m_xControl(VclPtr<AreaTransparencyGradientControl>::Create(this, rPanel)) { } AreaTransparencyGradientPopup::~AreaTransparencyGradientPopup() { + disposeOnce(); } -void AreaTransparencyGradientPopup::Rearrange (XFillFloatTransparenceItem* pItem) +void AreaTransparencyGradientPopup::Rearrange(XFillFloatTransparenceItem* pItem) { - ProvideContainerAndControl(); - - AreaTransparencyGradientControl* pControl = dynamic_cast<AreaTransparencyGradientControl*>(mxControl.get()); - if (pControl != nullptr) - pControl->Rearrange(pItem); + m_xControl->Rearrange(pItem); + SetSizePixel(m_xControl->GetOutputSizePixel()); } +void AreaTransparencyGradientPopup::dispose() +{ + m_xControl.disposeAndClear(); + FloatingWindow::dispose(); +} } } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/tools/Popup.cxx b/svx/source/sidebar/tools/Popup.cxx deleted file mode 100644 index ffd1bf5e7404..000000000000 --- a/svx/source/sidebar/tools/Popup.cxx +++ /dev/null @@ -1,129 +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 "svx/sidebar/Popup.hxx" -#include "svx/sidebar/PopupContainer.hxx" - -#include <vcl/toolbox.hxx> - - -namespace svx { namespace sidebar { - -Popup::Popup ( - vcl::Window* pParent, - const ::std::function<Control* (PopupContainer*)>& rControlCreator, - const ::rtl::OUString& rsAccessibleName) - : mxControl(), - mpParent(pParent), - maControlCreator(rControlCreator), - maPopupModeEndCallback(), - msAccessibleName(rsAccessibleName), - mxContainer() -{ - OSL_ASSERT(mpParent!=nullptr); - OSL_ASSERT(maControlCreator); -} - -void Popup::dispose() -{ - mxControl.disposeAndClear(); - mxContainer.disposeAndClear(); - mpParent.clear(); -} - -Popup::~Popup() -{ - dispose(); -} - -void Popup::Show (ToolBox& rToolBox) -{ - rToolBox.SetItemDown(rToolBox.GetCurItemId(), true); - - ProvideContainerAndControl(); - if ( ! (mxContainer && mxControl)) - { - OSL_ASSERT(mxContainer); - OSL_ASSERT(mxControl); - return; - } - - if ( !mxContainer->IsInPopupMode() ) - { - mxContainer->SetSizePixel(mxControl->GetOutputSizePixel()); - - const Point aPos (rToolBox.GetParent()->OutputToScreenPixel(rToolBox.GetPosPixel())); - const Size aSize (rToolBox.GetSizePixel()); - const Rectangle aRect (aPos, aSize); - - mxContainer->StartPopupMode( - aRect, - FloatWinPopupFlags::Down); - mxContainer->SetPopupModeFlags( - mxContainer->GetPopupModeFlags() - | FloatWinPopupFlags::NoAppFocusClose); - - mxControl->GetFocus(); - } -} - -void Popup::Hide() -{ - if (mxContainer) - if (mxContainer->IsInPopupMode()) - mxContainer->EndPopupMode(); -} - -void Popup::ProvideContainerAndControl() -{ - if ( ! (mxContainer && mxControl) - && mpParent != nullptr - && maControlCreator) - { - CreateContainerAndControl(); - } -} - -void Popup::CreateContainerAndControl() -{ - // Clean previous components, if any - mxControl.disposeAndClear(); - mxContainer.disposeAndClear(); - - mxContainer.set(VclPtr<PopupContainer>::Create(mpParent)); - mxContainer->SetAccessibleName(msAccessibleName); - mxContainer->SetPopupModeEndHdl(LINK(this, Popup, PopupModeEndHandler)); - mxContainer->SetBorderStyle(mxContainer->GetBorderStyle() | WindowBorderStyle::MENU); - - mxControl.set(maControlCreator(mxContainer.get())); -} - -IMPL_LINK_NOARG_TYPED(Popup, PopupModeEndHandler, FloatingWindow*, void) -{ - if (maPopupModeEndCallback) - maPopupModeEndCallback(); - - // Popup control is no longer needed and can be destroyed. - mxControl.disposeAndClear(); - mxContainer.disposeAndClear(); -} - - -} } // end of namespace svx::sidebar - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |