weld GraphicFilterSolarize

Change-Id: If729ea1688e9dc15372a59d75c972ee37511f76e
Reviewed-on: https://gerrit.libreoffice.org/60680
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2018-09-18 12:10:37 +01:00
parent 3a87fb1824
commit 4b743a2cc1
8 changed files with 55 additions and 56 deletions

View file

@ -449,53 +449,33 @@ Graphic GraphicFilterSmooth::GetFilteredGraphic( const Graphic& rGraphic, double
return aRet;
}
GraphicFilterSolarize::GraphicFilterSolarize( vcl::Window* pParent, const Graphic& rGraphic,
sal_uInt8 cGreyThreshold, bool bInvert )
: GraphicFilterDialog(pParent, "SolarizeDialog",
"cui/ui/solarizedialog.ui", rGraphic)
GraphicFilterSolarize::GraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic,
sal_uInt8 cGreyThreshold, bool bInvert)
: GraphicFilterDialogController(pParent, "cui/ui/solarizedialog.ui", "SolarizeDialog", rGraphic)
, mxMtrThreshold(m_xBuilder->weld_metric_spin_button("value", FUNIT_PERCENT))
, mxCbxInvert(m_xBuilder->weld_check_button("invert"))
{
get(mpMtrThreshold, "value");
get(mpCbxInvert, "invert");
mxMtrThreshold->set_value(FRound(cGreyThreshold / 2.55), FUNIT_PERCENT);
mxMtrThreshold->connect_value_changed(LINK(this, GraphicFilterSolarize, EditModifyHdl));
mpMtrThreshold->SetValue( FRound( cGreyThreshold / 2.55 ) );
mpMtrThreshold->SetModifyHdl( LINK(this, GraphicFilterSolarize, EditModifyHdl) );
mpCbxInvert->Check( bInvert );
mpCbxInvert->SetToggleHdl( LINK(this, GraphicFilterSolarize, CheckBoxModifyHdl) );
mxCbxInvert->set_active(bInvert);
mxCbxInvert->connect_toggled(LINK(this, GraphicFilterSolarize, CheckBoxModifyHdl));
}
IMPL_LINK_NOARG(GraphicFilterSolarize, CheckBoxModifyHdl, CheckBox&, void)
IMPL_LINK_NOARG(GraphicFilterSolarize, CheckBoxModifyHdl, weld::ToggleButton&, void)
{
GetModifyHdl().Call(nullptr);
}
IMPL_LINK_NOARG(GraphicFilterSolarize, EditModifyHdl, Edit&, void)
IMPL_LINK_NOARG(GraphicFilterSolarize, EditModifyHdl, weld::MetricSpinButton&, void)
{
GetModifyHdl().Call(nullptr);
}
GraphicFilterSolarize::~GraphicFilterSolarize()
{
disposeOnce();
}
void GraphicFilterSolarize::dispose()
{
mpMtrThreshold.clear();
mpCbxInvert.clear();
GraphicFilterDialog::dispose();
}
Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic, double, double )
{
Graphic aRet;
sal_uInt8 nGreyThreshold = static_cast<sal_uInt8>(FRound( mpMtrThreshold->GetValue() * 2.55 ));
sal_uInt8 nGreyThreshold = static_cast<sal_uInt8>(FRound(mxMtrThreshold->get_value(FUNIT_PERCENT) * 2.55));
if( rGraphic.IsAnimated() )
{

View file

@ -1306,11 +1306,10 @@ VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFil
return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
}
VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterSolarize (vcl::Window* pParent,
VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterSolarize(weld::Window* pParent,
const Graphic& rGraphic)
{
VclPtrInstance<GraphicFilterSolarize> pDlg( pParent, rGraphic, 128, false/*bInvert*/ );
return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
return VclPtr<AbstractGraphicFilterDialogController_Impl>::Create(o3tl::make_unique<GraphicFilterSolarize>(pParent, rGraphic, 128, false /*bInvert*/));
}
VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterMosaic (vcl::Window* pParent,

View file

@ -761,7 +761,7 @@ public:
const Graphic& rGraphic) override;
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSmooth (vcl::Window* pParent,
const Graphic& rGraphic, double nRadius) override;
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSolarize (vcl::Window* pParent,
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSolarize(weld::Window* pParent,
const Graphic& rGraphic) override;
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterMosaic (vcl::Window* pParent,
const Graphic& rGraphic) override;

View file

@ -184,23 +184,19 @@ public:
bool IsEnhanceEdges() const { return mpCbxEdges->IsChecked(); }
};
class GraphicFilterSolarize : public GraphicFilterDialog
class GraphicFilterSolarize : public GraphicFilterDialogController
{
private:
VclPtr<MetricField> mpMtrThreshold;
VclPtr<CheckBox> mpCbxInvert;
DECL_LINK(CheckBoxModifyHdl, CheckBox&, void);
DECL_LINK(EditModifyHdl, Edit&, void);
std::unique_ptr<weld::MetricSpinButton> mxMtrThreshold;
std::unique_ptr<weld::CheckButton> mxCbxInvert;
DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton&, void);
DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
public:
GraphicFilterSolarize( vcl::Window* pParent, const Graphic& rGraphic,
sal_uInt8 nGreyThreshold, bool bInvert );
virtual ~GraphicFilterSolarize() override;
virtual void dispose() override;
virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
bool IsInvert() const { return mpCbxInvert->IsChecked(); }
GraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic,
sal_uInt8 nGreyThreshold, bool bInvert);
virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
bool IsInvert() const { return mxCbxInvert->get_active(); }
};
class GraphicFilterSepia : public GraphicFilterDialog

View file

@ -6,6 +6,7 @@
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="embossdialog|EmbossDialog">Emboss</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>

View file

@ -1,5 +1,5 @@
<?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"/>
@ -13,7 +13,13 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="solarizedialog|SolarizeDialog">Solarization</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>
@ -100,11 +106,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>
@ -117,7 +140,7 @@
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkSpinButton" id="value:0%">
<object class="GtkSpinButton" id="value">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
@ -131,10 +154,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="solarizedialog|label2">Threshold _value:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">value:0%</property>
<property name="mnemonic_widget">value</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>

View file

@ -421,7 +421,7 @@ public:
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSmooth (vcl::Window* pParent,
const Graphic& rGraphic,
double nRadius)=0;
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSolarize (vcl::Window* pParent,
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterSolarize(weld::Window* pParent,
const Graphic& rGraphic)=0;
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterMosaic (vcl::Window* pParent,
const Graphic& rGraphic)=0;

View file

@ -220,7 +220,7 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const
case SID_GRFFILTER_SOLARIZE:
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
ScopedVclPtr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterSolarize(pWindow, rGraphic));
ScopedVclPtr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterSolarize(pWindow ? pWindow->GetFrameWeld() : nullptr, rGraphic));
if( aDlg->Execute() == RET_OK )
aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
}