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 | |
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>
-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 | ||||
-rw-r--r-- | cui/uiconfig/ui/mosaicdialog.ui | 50 | ||||
-rw-r--r-- | include/svx/svxdlg.hxx | 2 | ||||
-rw-r--r-- | svx/source/dialog/grfflt.cxx | 4 |
7 files changed, 74 insertions, 68 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 diff --git a/cui/uiconfig/ui/mosaicdialog.ui b/cui/uiconfig/ui/mosaicdialog.ui index ba8cbd423852..5497f7994bde 100644 --- a/cui/uiconfig/ui/mosaicdialog.ui +++ b/cui/uiconfig/ui/mosaicdialog.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="lower">1</property> <property name="upper">999</property> @@ -10,12 +9,24 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="lower">1</property> + <property name="upper">999</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkDialog" id="MosaicDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="mosaicdialog|MosaicDialog">Mosaic</property> <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -102,11 +113,28 @@ <property name="vexpand">True</property> <property name="column_spacing">24</property> <child> - <object class="cuilo-GraphicPreviewWindow" id="preview"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="preview"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + </child> + </object> + </child> </object> <packing> <property name="left_attach">1</property> @@ -124,10 +152,10 @@ <property name="can_focus">False</property> <property name="row_spacing">6</property> <child> - <object class="GtkSpinButton" id="width:px"> + <object class="GtkSpinButton" id="width"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="no">2</property> + <property name="text">2</property> <property name="adjustment">adjustment1</property> <property name="value">2</property> </object> @@ -140,10 +168,10 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="mosaicdialog|label2">_Width:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">width:px</property> + <property name="mnemonic_widget">width</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -162,11 +190,11 @@ <property name="can_focus">False</property> <property name="row_spacing">6</property> <child> - <object class="GtkSpinButton" id="height:px"> + <object class="GtkSpinButton" id="height"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="text" translatable="yes" context="mosaicdialog|height">2</property> - <property name="adjustment">adjustment1</property> + <property name="adjustment">adjustment2</property> <property name="value">2</property> </object> <packing> @@ -178,10 +206,10 @@ <object class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="mosaicdialog|label3">_Height:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">height:px</property> + <property name="mnemonic_widget">height</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index 2fe3ff8c1ddf..0f8b386c01c9 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -423,7 +423,7 @@ public: double nRadius)=0; virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic)=0; - virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterMosaic (vcl::Window* pParent, + virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic)=0; virtual VclPtr<AbstractSvxAreaTabDialog> CreateSvxAreaTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, diff --git a/svx/source/dialog/grfflt.cxx b/svx/source/dialog/grfflt.cxx index bc53e6cfa92d..793e7f066f42 100644 --- a/svx/source/dialog/grfflt.cxx +++ b/svx/source/dialog/grfflt.cxx @@ -159,7 +159,7 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const case SID_GRFFILTER_MOSAIC: { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterMosaic(pWindow, rGraphic)); + ScopedVclPtr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterMosaic(pWindow ? pWindow->GetFrameWeld() : nullptr, rGraphic)); if( aDlg->Execute() == RET_OK ) aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); } @@ -211,7 +211,7 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const case SID_GRFFILTER_SEPIA: { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterSepia(pWindow, rGraphic)); + ScopedVclPtr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterSepia(pWindow ? pWindow->GetFrameWeld() : nullptr, rGraphic)); if( aDlg->Execute() == RET_OK ) aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); } |