diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-09-18 14:02:30 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-09-19 16:51:09 +0200 |
commit | d85d206077bd400162157dadd1a36184e4851dbf (patch) | |
tree | 7b2b98c8d258a6d8ba6fbbe6ec51303e0bf02f72 /cui/source | |
parent | b5f67308c6d19fd8bce1515312fb3fcd0eb28af4 (diff) |
weld GraphicFilterMosaic
Change-Id: I2bd52c8a998ecfc168b4fd0cecf79e49c12604eb
Reviewed-on: https://gerrit.libreoffice.org/60709
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/dialogs/cuigrfflt.cxx | 58 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.cxx | 5 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.hxx | 2 | ||||
-rw-r--r-- | cui/source/inc/cuigrfflt.hxx | 21 |
4 files changed, 32 insertions, 54 deletions
diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx index 3fd751a953cf..0ba79e581a0a 100644 --- a/cui/source/dialogs/cuigrfflt.cxx +++ b/cui/source/dialogs/cuigrfflt.cxx @@ -302,63 +302,43 @@ IMPL_LINK_NOARG(GraphicFilterDialogController, ImplModifyHdl, LinkParamNone*, vo } } -GraphicFilterMosaic::GraphicFilterMosaic( vcl::Window* pParent, const Graphic& rGraphic, - sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges ) - : GraphicFilterDialog(pParent, "MosaicDialog", - "cui/ui/mosaicdialog.ui", rGraphic) +GraphicFilterMosaic::GraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic, + sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges) + : GraphicFilterDialogController(pParent, "cui/ui/mosaicdialog.ui", "MosaicDialog", rGraphic) + , mxMtrWidth(m_xBuilder->weld_metric_spin_button("width", FUNIT_PIXEL)) + , mxMtrHeight(m_xBuilder->weld_metric_spin_button("height", FUNIT_PIXEL)) + , mxCbxEdges(m_xBuilder->weld_check_button("edges")) { - get(mpMtrWidth, "width"); - get(mpMtrHeight, "height"); - get(mpCbxEdges, "edges"); + mxMtrWidth->set_value(nTileWidth, FUNIT_PIXEL); + mxMtrWidth->set_max(GetGraphicSizePixel().Width(), FUNIT_PIXEL); + mxMtrWidth->connect_value_changed(LINK(this, GraphicFilterMosaic, EditModifyHdl)); - mpMtrWidth->SetValue( nTileWidth ); - mpMtrWidth->SetLast( GetGraphicSizePixel().Width() ); - mpMtrWidth->SetModifyHdl( LINK(this, GraphicFilterMosaic, EditModifyHdl) ); + mxMtrHeight->set_value(nTileHeight, FUNIT_PIXEL); + mxMtrHeight->set_max(GetGraphicSizePixel().Height(), FUNIT_PIXEL); + mxMtrHeight->connect_value_changed(LINK(this, GraphicFilterMosaic, EditModifyHdl)); - mpMtrHeight->SetValue( nTileHeight ); - mpMtrHeight->SetLast( GetGraphicSizePixel().Height() ); - mpMtrHeight->SetModifyHdl( LINK(this, GraphicFilterMosaic, EditModifyHdl) ); + mxCbxEdges->set_active(bEnhanceEdges); + mxCbxEdges->connect_toggled(LINK(this, GraphicFilterMosaic, CheckBoxModifyHdl)); - mpCbxEdges->Check( bEnhanceEdges ); - mpCbxEdges->SetToggleHdl( LINK(this, GraphicFilterMosaic, CheckBoxModifyHdl) ); - - mpMtrWidth->GrabFocus(); + mxMtrWidth->grab_focus(); } - -IMPL_LINK_NOARG(GraphicFilterMosaic, CheckBoxModifyHdl, CheckBox&, void) +IMPL_LINK_NOARG(GraphicFilterMosaic, CheckBoxModifyHdl, weld::ToggleButton&, void) { GetModifyHdl().Call(nullptr); } - -IMPL_LINK_NOARG(GraphicFilterMosaic, EditModifyHdl, Edit&, void) +IMPL_LINK_NOARG(GraphicFilterMosaic, EditModifyHdl, weld::MetricSpinButton&, void) { GetModifyHdl().Call(nullptr); } - -GraphicFilterMosaic::~GraphicFilterMosaic() -{ - disposeOnce(); -} - - -void GraphicFilterMosaic::dispose() -{ - mpMtrWidth.clear(); - mpMtrHeight.clear(); - mpCbxEdges.clear(); - GraphicFilterDialog::dispose(); -} - - Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) { Graphic aRet; - long nTileWidth = static_cast<long>(mpMtrWidth->GetValue()); - long nTileHeight = static_cast<long>(mpMtrHeight->GetValue()); + long nTileWidth = static_cast<long>(mxMtrWidth->get_value(FUNIT_PIXEL)); + long nTileHeight = static_cast<long>(mxMtrHeight->get_value(FUNIT_PIXEL)); const Size aSize( std::max( FRound( nTileWidth * fScaleX ), 1L ), std::max( FRound( nTileHeight * fScaleY ), 1L ) ); diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 40863a65d543..108ac73ca14d 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -1311,11 +1311,10 @@ VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFil return VclPtr<AbstractGraphicFilterDialogController_Impl>::Create(o3tl::make_unique<GraphicFilterSolarize>(pParent, rGraphic, 128, false /*bInvert*/)); } -VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterMosaic (vcl::Window* pParent, +VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic) { - VclPtrInstance<GraphicFilterMosaic> pDlg(pParent, rGraphic, 4, 4, false/*bEnhanceEdges*/); - return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg ); + return VclPtr<AbstractGraphicFilterDialogController_Impl>::Create(o3tl::make_unique<GraphicFilterMosaic>(pParent, rGraphic, 4, 4, false /*bEnhanceEdges*/)); } VclPtr<AbstractSvxAreaTabDialog> AbstractDialogFactory_Impl::CreateSvxAreaTabDialog(weld::Window* pParent, diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index ec2a4285182e..d26d30fa1dce 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -763,7 +763,7 @@ public: const Graphic& rGraphic, double nRadius) override; virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic) override; - virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterMosaic (vcl::Window* pParent, + virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic) override; virtual VclPtr<AbstractSvxAreaTabDialog> CreateSvxAreaTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, diff --git a/cui/source/inc/cuigrfflt.hxx b/cui/source/inc/cuigrfflt.hxx index 9ff9c2b6a29a..3ba2b75148e5 100644 --- a/cui/source/inc/cuigrfflt.hxx +++ b/cui/source/inc/cuigrfflt.hxx @@ -97,6 +97,7 @@ public: const Graphic& GetScaledOriginal() const { return maScaledOrig; } double GetScaleX() const { return mfScaleX; } double GetScaleY() const { return mfScaleY; } + const Size& GetGraphicSizePixel() const { return maOrigGraphicSizePixel; } }; class GraphicFilterDialog : public ModalDialog @@ -142,7 +143,7 @@ protected: std::unique_ptr<weld::CustomWeld> mxPreview; const Link<LinkParamNone*,void>& GetModifyHdl() const { return maModifyHdl; } - const Size& GetGraphicSizePixel() const; + const Size& GetGraphicSizePixel() const { return maPreview.GetGraphicSizePixel(); } public: @@ -165,23 +166,21 @@ public: virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override; }; -class GraphicFilterMosaic : public GraphicFilterDialog +class GraphicFilterMosaic : public GraphicFilterDialogController { private: - VclPtr<MetricField> mpMtrWidth; - VclPtr<MetricField> mpMtrHeight; - VclPtr<CheckBox> mpCbxEdges; - DECL_LINK(CheckBoxModifyHdl, CheckBox&, void); - DECL_LINK(EditModifyHdl, Edit&, void); + std::unique_ptr<weld::MetricSpinButton> mxMtrWidth; + std::unique_ptr<weld::MetricSpinButton> mxMtrHeight; + std::unique_ptr<weld::CheckButton> mxCbxEdges; + DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton&, void); + DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void); public: - GraphicFilterMosaic(vcl::Window* pParent, const Graphic& rGraphic, + GraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic, sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges); - virtual ~GraphicFilterMosaic() override; - virtual void dispose() override; virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override; - bool IsEnhanceEdges() const { return mpCbxEdges->IsChecked(); } + bool IsEnhanceEdges() const { return mxCbxEdges->get_active(); } }; class GraphicFilterSolarize : public GraphicFilterDialogController |