summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/cuigrfflt.cxx163
-rw-r--r--cui/source/factory/dlgfact.cxx15
-rw-r--r--cui/source/factory/dlgfact.hxx16
-rw-r--r--cui/source/inc/cuigrfflt.hxx83
-rw-r--r--cui/uiconfig/ui/embossdialog.ui51
5 files changed, 279 insertions, 49 deletions
diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx
index e9f84d1789ef..f8f2b76bc4a5 100644
--- a/cui/source/dialogs/cuigrfflt.cxx
+++ b/cui/source/dialogs/cuigrfflt.cxx
@@ -79,7 +79,6 @@ void GraphicPreviewWindow::SetPreview(const Graphic& rGraphic)
Invalidate();
}
-
void GraphicPreviewWindow::ScaleImageToFit()
{
if (!mpOrigGraphic)
@@ -125,13 +124,105 @@ void GraphicPreviewWindow::ScaleImageToFit()
maModifyHdl.Call(nullptr);
}
-
void GraphicPreviewWindow::Resize()
{
Control::Resize();
ScaleImageToFit();
}
+CuiGraphicPreviewWindow::CuiGraphicPreviewWindow()
+ : mpOrigGraphic(nullptr)
+ , mfScaleX(0.0)
+ , mfScaleY(0.0)
+{
+}
+
+void CuiGraphicPreviewWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
+{
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
+ OutputDevice &rDevice = pDrawingArea->get_ref_device();
+ maOutputSizePixel = rDevice.LogicToPixel(Size(81, 73), MapMode(MapUnit::MapAppFont));
+ pDrawingArea->set_size_request(maOutputSizePixel.Width(), maOutputSizePixel.Height());
+}
+
+void CuiGraphicPreviewWindow::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&)
+{
+ rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetDialogColor()));
+ rRenderContext.Erase();
+
+ const Size aOutputSize(GetOutputSizePixel());
+
+ if (maPreview.IsAnimated())
+ {
+ const Size aGraphicSize(rRenderContext.LogicToPixel(maPreview.GetPrefSize(), maPreview.GetPrefMapMode()));
+ const Point aGraphicPosition((aOutputSize.Width() - aGraphicSize.Width() ) >> 1,
+ (aOutputSize.Height() - aGraphicSize.Height() ) >> 1);
+ maPreview.StartAnimation(&rRenderContext, aGraphicPosition, aGraphicSize);
+ }
+ else
+ {
+ const Size aGraphicSize(maPreview.GetSizePixel());
+ const Point aGraphicPosition((aOutputSize.Width() - aGraphicSize.Width()) >> 1,
+ (aOutputSize.Height() - aGraphicSize.Height()) >> 1);
+ maPreview.Draw(&rRenderContext, aGraphicPosition, aGraphicSize);
+ }
+}
+
+void CuiGraphicPreviewWindow::SetPreview(const Graphic& rGraphic)
+{
+ maPreview = rGraphic;
+ Invalidate();
+}
+
+void CuiGraphicPreviewWindow::ScaleImageToFit()
+{
+ if (!mpOrigGraphic)
+ return;
+
+ maScaledOrig = *mpOrigGraphic;
+
+ const Size aPreviewSize(GetOutputSizePixel());
+ Size aGrfSize(maOrigGraphicSizePixel);
+
+ if( mpOrigGraphic->GetType() == GraphicType::Bitmap &&
+ aPreviewSize.Width() && aPreviewSize.Height() &&
+ aGrfSize.Width() && aGrfSize.Height() )
+ {
+ const double fGrfWH = static_cast<double>(aGrfSize.Width()) / aGrfSize.Height();
+ const double fPreWH = static_cast<double>(aPreviewSize.Width()) / aPreviewSize.Height();
+
+ if( fGrfWH < fPreWH )
+ {
+ aGrfSize.setWidth( static_cast<long>( aPreviewSize.Height() * fGrfWH ) );
+ aGrfSize.setHeight( aPreviewSize.Height() );
+ }
+ else
+ {
+ aGrfSize.setWidth( aPreviewSize.Width() );
+ aGrfSize.setHeight( static_cast<long>( aPreviewSize.Width() / fGrfWH ) );
+ }
+
+ mfScaleX = static_cast<double>(aGrfSize.Width()) / maOrigGraphicSizePixel.Width();
+ mfScaleY = static_cast<double>(aGrfSize.Height()) / maOrigGraphicSizePixel.Height();
+
+ if( !mpOrigGraphic->IsAnimated() )
+ {
+ BitmapEx aBmpEx( mpOrigGraphic->GetBitmapEx() );
+
+ if( aBmpEx.Scale( aGrfSize ) )
+ maScaledOrig = aBmpEx;
+ }
+ }
+
+ maModifyHdl.Call(nullptr);
+}
+
+void CuiGraphicPreviewWindow::Resize()
+{
+ maOutputSizePixel = GetOutputSizePixel();
+ ScaleImageToFit();
+}
+
GraphicFilterDialog::GraphicFilterDialog(vcl::Window* pParent,
const OUString& rID, const OUString& rUIXMLDescription,
const Graphic& rGraphic)
@@ -180,6 +271,36 @@ IMPL_LINK_NOARG(GraphicFilterDialog, ImplModifyHdl, LinkParamNone*, void)
}
}
+GraphicFilterDialogController::GraphicFilterDialogController(weld::Window* pParent,
+ const OUString& rUIXMLDescription, const OString& rID,
+ const Graphic& rGraphic)
+ : GenericDialogController(pParent, rUIXMLDescription, rID)
+ , maModifyHdl(LINK(this, GraphicFilterDialogController, ImplModifyHdl))
+ , mxPreview(new weld::CustomWeld(*m_xBuilder, "preview", maPreview))
+{
+ bIsBitmap = rGraphic.GetType() == GraphicType::Bitmap;
+
+ maTimer.SetInvokeHandler(LINK(this, GraphicFilterDialogController, ImplPreviewTimeoutHdl));
+ maTimer.SetTimeout(5);
+
+ maPreview.init(&rGraphic, maModifyHdl);
+}
+
+IMPL_LINK_NOARG(GraphicFilterDialogController, ImplPreviewTimeoutHdl, Timer *, void)
+{
+ maTimer.Stop();
+ maPreview.SetPreview(GetFilteredGraphic(maPreview.GetScaledOriginal(),
+ maPreview.GetScaleX(), maPreview.GetScaleY()));
+}
+
+IMPL_LINK_NOARG(GraphicFilterDialogController, ImplModifyHdl, LinkParamNone*, void)
+{
+ if (bIsBitmap)
+ {
+ maTimer.Stop();
+ maTimer.Start();
+ }
+}
GraphicFilterMosaic::GraphicFilterMosaic( vcl::Window* pParent, const Graphic& rGraphic,
sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges )
@@ -517,53 +638,39 @@ void EmbossControl::MouseButtonDown( const MouseEvent& rEvt )
{
const RectPoint eOldRP = GetActualRP();
- SvxRectCtl::MouseButtonDown( rEvt );
+ RectCtl::MouseButtonDown( rEvt );
if( GetActualRP() != eOldRP )
maModifyHdl.Call( nullptr );
}
-
-Size EmbossControl::GetOptimalSize() const
+void EmbossControl::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
- return LogicToPixel(Size(77, 60), MapMode(MapUnit::MapAppFont));
+ RectCtl::SetDrawingArea(pDrawingArea);
+ Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(77, 60), MapMode(MapUnit::MapAppFont)));
+ pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
}
-
-VCL_BUILDER_FACTORY(EmbossControl)
-
-
-GraphicFilterEmboss::GraphicFilterEmboss(vcl::Window* pParent,
+GraphicFilterEmboss::GraphicFilterEmboss(weld::Window* pParent,
const Graphic& rGraphic, RectPoint eLightSource)
- : GraphicFilterDialog (pParent, "EmbossDialog",
- "cui/ui/embossdialog.ui", rGraphic)
+ : GraphicFilterDialogController(pParent, "cui/ui/embossdialog.ui", "EmbossDialog", rGraphic)
+ , mxCtlLight(new weld::CustomWeld(*m_xBuilder, "lightsource", maCtlLight))
{
- get(mpCtlLight, "lightsource");
- mpCtlLight->SetActualRP(eLightSource);
- mpCtlLight->SetModifyHdl( GetModifyHdl() );
- mpCtlLight->GrabFocus();
+ maCtlLight.SetActualRP(eLightSource);
+ maCtlLight.SetModifyHdl( GetModifyHdl() );
+ maCtlLight.GrabFocus();
}
-
GraphicFilterEmboss::~GraphicFilterEmboss()
{
- disposeOnce();
}
-
-void GraphicFilterEmboss::dispose()
-{
- mpCtlLight.clear();
- GraphicFilterDialog::dispose();
-}
-
-
Graphic GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic, double, double )
{
Graphic aRet;
sal_uInt16 nAzim, nElev;
- switch( mpCtlLight->GetActualRP() )
+ switch (maCtlLight.GetActualRP())
{
default: OSL_FAIL("svx::GraphicFilterEmboss::GetFilteredGraphic(), unknown Reference Point!" );
SAL_FALLTHROUGH;
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index e2c8a6fda1c8..63868ad23534 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -190,6 +190,11 @@ IMPL_ABSTDLG_BASE(AbstractSvxHpLinkDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractFmSearchDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractGraphicFilterDialog_Impl);
+short AbstractGraphicFilterDialogController_Impl::Execute()
+{
+ return m_xDlg->run();
+}
+
short AbstractSvxAreaTabDialog_Impl::Execute()
{
return m_xDlg->execute();
@@ -814,6 +819,11 @@ Graphic AbstractGraphicFilterDialog_Impl::GetFilteredGraphic( const Graphic& rGr
return pDlg->GetFilteredGraphic( rGraphic, fScaleX, fScaleY );
}
+Graphic AbstractGraphicFilterDialogController_Impl::GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY)
+{
+ return m_xDlg->GetFilteredGraphic(rGraphic, fScaleX, fScaleY);
+}
+
// AbstractSvxAreaTabDialog implementations just forwards everything to the dialog
void AbstractSvxAreaTabDialog_Impl::SetCurPageId( const OString& rName )
{
@@ -1269,11 +1279,10 @@ VclPtr<AbstractFmSearchDialog> AbstractDialogFactory_Impl::CreateFmSearchDialog(
return VclPtr<AbstractFmSearchDialog_Impl>::Create( pDlg );
}
-VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterEmboss (vcl::Window* pParent,
+VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterEmboss(weld::Window* pParent,
const Graphic& rGraphic)
{
- VclPtrInstance<GraphicFilterEmboss> pDlg( pParent, rGraphic, RectPoint::MM );
- return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
+ return VclPtr<AbstractGraphicFilterDialogController_Impl>::Create(o3tl::make_unique<GraphicFilterEmboss>(pParent, rGraphic, RectPoint::MM));
}
VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterPoster(vcl::Window* pParent,
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 503ffb68b99c..6df50a3b0f52 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -46,6 +46,7 @@ class SvxHpLinkDlg;
class FmSearchDialog;
class Graphic;
class GraphicFilterDialog;
+class GraphicFilterDialogController;
class SvxAreaTabDialog;
class InsertObjectDialog_Impl;
class SvPasteObjectDialog;
@@ -475,6 +476,19 @@ class AbstractGraphicFilterDialog_Impl :public AbstractGraphicFilterDialog
virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
};
+class AbstractGraphicFilterDialogController_Impl : public AbstractGraphicFilterDialog
+{
+protected:
+ std::unique_ptr<GraphicFilterDialogController> m_xDlg;
+public:
+ explicit AbstractGraphicFilterDialogController_Impl(std::unique_ptr<GraphicFilterDialogController> p)
+ : m_xDlg(std::move(p))
+ {
+ }
+ virtual short Execute() override;
+ virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
+};
+
class SvxAreaTabDialog;
class AbstractSvxAreaTabDialog_Impl : public AbstractSvxAreaTabDialog
{
@@ -739,7 +753,7 @@ public:
const std::vector< OUString >& _rContexts,
sal_Int16 nInitialContext,
const Link<FmSearchContext&,sal_uInt32>& lnkContextSupplier) override;
- virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterEmboss(vcl::Window* pParent,
+ virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterEmboss(weld::Window* pParent,
const Graphic& rGraphic) override;
virtual VclPtr<AbstractGraphicFilterDialog> CreateGraphicFilterPoster(vcl::Window* pParent,
const Graphic& rGraphic) override;
diff --git a/cui/source/inc/cuigrfflt.hxx b/cui/source/inc/cuigrfflt.hxx
index 9daa44d02fba..2a8a8f35229c 100644
--- a/cui/source/inc/cuigrfflt.hxx
+++ b/cui/source/inc/cuigrfflt.hxx
@@ -64,6 +64,41 @@ public:
double GetScaleY() const { return mfScaleY; }
};
+class CuiGraphicPreviewWindow : public weld::CustomWidgetController
+{
+private:
+ const Graphic* mpOrigGraphic;
+ Size maOrigGraphicSizePixel;
+ Size maOutputSizePixel;
+ Link<LinkParamNone*,void> maModifyHdl;
+ Graphic maScaledOrig;
+ Graphic maPreview;
+ double mfScaleX;
+ double mfScaleY;
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;
+ virtual void Resize() override;
+
+ void ScaleImageToFit();
+
+public:
+ CuiGraphicPreviewWindow();
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+ void init(const Graphic* pOrigGraphic, const Link<LinkParamNone*,void>& rLink)
+ {
+ mpOrigGraphic = pOrigGraphic;
+ maModifyHdl = rLink;
+ maOrigGraphicSizePixel = GetDrawingArea()->get_ref_device().LogicToPixel(mpOrigGraphic->GetPrefSize(),
+ mpOrigGraphic->GetPrefMapMode());
+ ScaleImageToFit();
+ }
+
+ void SetPreview(const Graphic& rGraphic);
+ const Graphic& GetScaledOriginal() const { return maScaledOrig; }
+ double GetScaleX() const { return mfScaleX; }
+ double GetScaleY() const { return mfScaleY; }
+};
+
class GraphicFilterDialog : public ModalDialog
{
private:
@@ -91,6 +126,30 @@ public:
virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) = 0;
};
+class GraphicFilterDialogController : public weld::GenericDialogController
+{
+private:
+
+ Timer maTimer;
+ Link<LinkParamNone*,void> maModifyHdl;
+ bool bIsBitmap;
+
+ DECL_LINK( ImplPreviewTimeoutHdl, Timer *, void );
+ DECL_LINK( ImplModifyHdl, LinkParamNone*, void);
+
+protected:
+ CuiGraphicPreviewWindow maPreview;
+ std::unique_ptr<weld::CustomWeld> mxPreview;
+
+ const Link<LinkParamNone*,void>& GetModifyHdl() const { return maModifyHdl; }
+ const Size& GetGraphicSizePixel() const;
+
+public:
+
+ GraphicFilterDialogController(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, const Graphic& rGraphic);
+ virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) = 0;
+};
+
class GraphicFilterSmooth : public GraphicFilterDialog
{
private:
@@ -171,30 +230,32 @@ public:
virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
};
-class EmbossControl : public SvxRectCtl
+class EmbossControl : public RectCtl
{
private:
Link<LinkParamNone*, void> maModifyHdl;
- virtual void MouseButtonDown( const MouseEvent& rEvt ) override;
- virtual Size GetOptimalSize() const override;
+ virtual void MouseButtonDown( const MouseEvent& rEvt ) override;
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
public:
- EmbossControl(vcl::Window* pParent)
- : SvxRectCtl(pParent) {}
+ EmbossControl()
+ : RectCtl(nullptr)
+ {
+ }
void SetModifyHdl( const Link<LinkParamNone*,void>& rHdl ) { maModifyHdl = rHdl; }
};
-class GraphicFilterEmboss : public GraphicFilterDialog
+class GraphicFilterEmboss : public GraphicFilterDialogController
{
private:
- VclPtr<EmbossControl> mpCtlLight;
+ EmbossControl maCtlLight;
+ std::unique_ptr<weld::CustomWeld> mxCtlLight;
public:
- GraphicFilterEmboss( vcl::Window* pParent, const Graphic& rGraphic,
- RectPoint eLightSource );
+ GraphicFilterEmboss(weld::Window* pParent, const Graphic& rGraphic,
+ RectPoint eLightSource);
virtual ~GraphicFilterEmboss() override;
- virtual void dispose() override;
- virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
+ virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) override;
};
#endif
diff --git a/cui/uiconfig/ui/embossdialog.ui b/cui/uiconfig/ui/embossdialog.ui
index 90f0ef49e70c..d8457c5f91ce 100644
--- a/cui/uiconfig/ui/embossdialog.ui
+++ b/cui/uiconfig/ui/embossdialog.ui
@@ -1,13 +1,17 @@
<?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="GtkDialog" id="EmbossDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="embossdialog|EmbossDialog">Emboss</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>
@@ -94,11 +98,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>
@@ -116,10 +137,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="embossdialog|label2">_Light source:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">lightsource</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -127,11 +148,29 @@
</packing>
</child>
<child>
- <object class="cuilo-EmbossControl" id="lightsource">
+ <object class="GtkScrolledWindow" id="frameselwin">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</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="lightsource">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>