include/svx/float3d.hxx | 48 ++++++++++------ svx/source/engine3d/float3d.cxx | 120 ++++++++++++++++------------------------ 2 files changed, 80 insertions(+), 88 deletions(-)
New commits: commit 01fe1b0b0356b2f0d0d9f5114390079f7c0c1925 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jul 17 11:14:01 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 18 07:07:24 2025 +0200 tdf#130857 svx Svx3DWin: Stop relying on weld::ToggleButton indeterminate state Stop relying on weld::ToggleButton supporting TRISTATE_INDET in the TriStateToggleButton helper class, but instead introduce TriStateToggleButton::m_bIndeterminate to explicitly get/set that state in the helper class to indicate a "no real value set" state, in preparation of removing support for TRISTATE_INDET from weld::ToggleButton in an upcoming commit. See also previous commit Change-Id: I4b39f941fdda886390079a00aed4c2ce29be5a43 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Thu Jul 17 10:31:06 2025 +0200 svx: Extract TriStateToggleButton base from LightButton for more background. No change in behavior intended/expected for that dialog, but (independent of this change) I didn't see this "indeterminate" code path being taken in practice in a quick test of that dialog started as follows: * start Impress * enable "View" -> "Toolbars" -> "3D-Objects" * click on any object in the toolbar (e.g. "Cube") and insert it into the slide * right-click on the object and select the "3D Dffects" context menu entry Change-Id: Ib781e9108d526f90282a203b53065111a9d12236 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188001 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/svx/float3d.hxx b/include/svx/float3d.hxx index d45059da3e60..3e712bf0c8db 100644 --- a/include/svx/float3d.hxx +++ b/include/svx/float3d.hxx @@ -52,11 +52,15 @@ class UNLESS_MERGELIBS(SVX_DLLPUBLIC) TriStateToggleButton { public: explicit TriStateToggleButton(std::unique_ptr<weld::ToggleButton> xButton); - bool get_active() const { return m_xButton->get_active(); } - void set_active(bool bActive) { m_xButton->set_active(bActive); } + bool get_active() const { return m_xButton->get_active(); }; + void set_active(bool bActive) + { + m_bIndeterminate = false; + m_xButton->set_active(bActive); + } - TriState get_state() const { return m_xButton->get_state(); } - void set_state(TriState eState) { m_xButton->set_state(eState); } + bool is_indeterminate() { return m_bIndeterminate; }; + void set_indeterminate() { m_bIndeterminate = true; }; weld::ToggleButton* get_widget() const { return m_xButton.get(); } @@ -67,6 +71,7 @@ public: private: std::unique_ptr<weld::ToggleButton> m_xButton; + bool m_bIndeterminate = false; }; class UNLESS_MERGELIBS(SVX_DLLPUBLIC) LightButton final : public TriStateToggleButton diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx index bd498a086532..bf9185304367 100644 --- a/svx/source/engine3d/float3d.cxx +++ b/svx/source/engine3d/float3d.cxx @@ -491,14 +491,14 @@ void Svx3DWin::UpdateLight(const SfxItemSet& rAttrs, TypedWhichId<SvxColorItem> rLightButton.switchLightOn(bOn); bUpdate = true; } - if (rLightButton.get_state() == TRISTATE_INDET) + if (rLightButton.is_indeterminate()) rLightButton.set_active(rLightButton.get_active()); } else { - if (rLightButton.get_state() != TRISTATE_INDET) + if (!rLightButton.is_indeterminate()) { - rLightButton.set_state(TRISTATE_INDET); + rLightButton.set_indeterminate(); bUpdate = true; } } @@ -522,14 +522,14 @@ void Svx3DWin::UpdateToggleButton(const SfxItemSet& rAttrs, TypedWhichId<SfxBool rButton.set_active(bValue); bUpdate = true; } - else if (rButton.get_state() == TRISTATE_INDET) + else if (rButton.is_indeterminate()) rButton.set_active(bValue); } else { - if (rButton.get_state() != TRISTATE_INDET) + if (!rButton.is_indeterminate()) { - rButton.set_state(TRISTATE_INDET); + rButton.set_indeterminate(); bUpdate = true; } } @@ -872,14 +872,14 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs ) m_xMtrSlant->set_sensitive( bValue ); bUpdate = true; } - else if( m_xBtnShadow3d->get_state() == TRISTATE_INDET ) + else if (m_xBtnShadow3d->is_indeterminate()) m_xBtnShadow3d->set_active( bValue ); } else { - if( m_xBtnShadow3d->get_state() != TRISTATE_INDET ) + if (!m_xBtnShadow3d->is_indeterminate()) { - m_xBtnShadow3d->set_state( TRISTATE_INDET ); + m_xBtnShadow3d->set_indeterminate(); bUpdate = true; } } @@ -1214,14 +1214,14 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs ) m_xBtnPerspective->set_active( ePT == ProjectionType::Perspective ); bUpdate = true; } - if( m_xBtnPerspective->get_state() == TRISTATE_INDET ) + if (m_xBtnPerspective->is_indeterminate()) m_xBtnPerspective->set_active( ePT == ProjectionType::Perspective ); } else { - if( m_xBtnPerspective->get_state() != TRISTATE_INDET ) + if (!m_xBtnPerspective->is_indeterminate()) { - m_xBtnPerspective->set_state( TRISTATE_INDET ); + m_xBtnPerspective->set_indeterminate(); bUpdate = true; } } @@ -1302,7 +1302,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) //Others must stand as the front on all sides // Perspective - if( m_xBtnPerspective->get_state() != TRISTATE_INDET ) + if (!m_xBtnPerspective->is_indeterminate()) { ProjectionType nValue; if( m_xBtnPerspective->get_active() ) @@ -1354,12 +1354,8 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) rAttrs.InvalidateItem(SDRATTR_3DOBJ_DEPTH); // Double-sided - TriState eState = m_xBtnDoubleSided->get_state(); - if( eState != TRISTATE_INDET ) - { - bool bValue = TRISTATE_TRUE == eState; - rAttrs.Put(makeSvx3DDoubleSidedItem(bValue)); - } + if (!m_xBtnDoubleSided->is_indeterminate()) + rAttrs.Put(makeSvx3DDoubleSidedItem(m_xBtnDoubleSided->get_active())); else rAttrs.InvalidateItem(SDRATTR_3DOBJ_DOUBLE_SIDED); @@ -1405,22 +1401,14 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_KIND); // Normal inverted - eState = m_xBtnNormalsInvert->get_state(); - if( eState != TRISTATE_INDET ) - { - bool bValue = TRISTATE_TRUE == eState; - rAttrs.Put(makeSvx3DNormalsInvertItem(bValue)); - } + if (!m_xBtnNormalsInvert->is_indeterminate()) + rAttrs.Put(makeSvx3DNormalsInvertItem(m_xBtnNormalsInvert->get_active())); else rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_INVERT); // 2-sided lighting - eState = m_xBtnTwoSidedLighting->get_state(); - if( eState != TRISTATE_INDET ) - { - bool bValue = TRISTATE_TRUE == eState; - rAttrs.Put(makeSvx3DTwoSidedLightingItem(bValue)); - } + if (!m_xBtnTwoSidedLighting->is_indeterminate()) + rAttrs.Put(makeSvx3DTwoSidedLightingItem(m_xBtnTwoSidedLighting->get_active())); else rAttrs.InvalidateItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING); @@ -1435,10 +1423,9 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADE_MODE); // 3D-Shadow - eState = m_xBtnShadow3d->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnShadow3d->is_indeterminate()) { - bool bValue = TRISTATE_TRUE == eState; + bool bValue = m_xBtnShadow3d->get_active(); rAttrs.Put(makeSvx3DShadow3DItem(bValue)); rAttrs.Put(makeSdrShadowItem(bValue)); } @@ -1488,8 +1475,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_1); // Light 1 (on/off) - eState = m_xBtnLight1->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight1->is_indeterminate()) { bool bValue = m_xBtnLight1->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff1Item(bValue)); @@ -1513,8 +1499,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_2); // Light 2 (on/off) - eState = m_xBtnLight2->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight2->is_indeterminate()) { bool bValue = m_xBtnLight2->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff2Item(bValue)); @@ -1537,8 +1522,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_3); // Light 3 (on/off) - eState = m_xBtnLight3->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight3->is_indeterminate()) { bool bValue = m_xBtnLight3->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff3Item(bValue)); @@ -1561,8 +1545,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_4); // Light 4 (on/off) - eState = m_xBtnLight4->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight4->is_indeterminate()) { bool bValue = m_xBtnLight4->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff4Item(bValue)); @@ -1585,8 +1568,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_5); // Light 5 (on/off) - eState = m_xBtnLight5->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight5->is_indeterminate()) { bool bValue = m_xBtnLight5->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff5Item(bValue)); @@ -1609,8 +1591,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_6); // Light 6 (on/off) - eState = m_xBtnLight6->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight6->is_indeterminate()) { bool bValue = m_xBtnLight6->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff6Item(bValue)); @@ -1633,8 +1614,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_7); // Light 7 (on/off) - eState = m_xBtnLight7->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight7->is_indeterminate()) { bool bValue = m_xBtnLight7->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff7Item(bValue)); @@ -1657,8 +1637,7 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) else rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_8); // Light 8 (on/off) - eState = m_xBtnLight8->get_state(); - if( eState != TRISTATE_INDET ) + if (!m_xBtnLight8->is_indeterminate()) { bool bValue = m_xBtnLight8->isLightOn(); rAttrs.Put(makeSvx3DLightOnOff8Item(bValue)); @@ -1744,12 +1723,8 @@ void Svx3DWin::GetAttr( SfxItemSet& rAttrs ) // Filter - eState = m_xBtnTexFilter->get_state(); - if( eState != TRISTATE_INDET ) - { - bool bValue = TRISTATE_TRUE == eState; - rAttrs.Put(makeSvx3DTextureFilterItem(bValue)); - } + if (!m_xBtnTexFilter->is_indeterminate()) + rAttrs.Put(makeSvx3DTextureFilterItem(m_xBtnTexFilter->get_active())); else rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_FILTER); commit 4c9666acb937f1f53b1ab83add7701a944134b7d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jul 17 10:49:13 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 18 07:07:17 2025 +0200 svx Svx3DWin: Use TriStateToggleButton for tristate toggle buttons Stop using weld::ToggleButton directly, in preparation of removing support for the inconsistent state from weld::ToggleButton. Instead, use the new helper class introduced in Change-Id: I4b39f941fdda886390079a00aed4c2ce29be5a43 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Thu Jul 17 10:31:06 2025 +0200 svx: Extract TriStateToggleButton base from LightButton , s.a. commit message of that commit for more details. For now, the logic is still implemented in weld::ToggleButton and TriStateToggleButton just forwards the calls, but that will change in an upcoming commit. Change-Id: I50686c061de55cd35ba9c6e63785636765f67964 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188000 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/svx/float3d.hxx b/include/svx/float3d.hxx index 67be4a4c5ebd..d45059da3e60 100644 --- a/include/svx/float3d.hxx +++ b/include/svx/float3d.hxx @@ -118,16 +118,16 @@ private: std::unique_ptr<weld::ToggleButton> m_xBtnNormalsObj; std::unique_ptr<weld::ToggleButton> m_xBtnNormalsFlat; std::unique_ptr<weld::ToggleButton> m_xBtnNormalsSphere; - std::unique_ptr<weld::ToggleButton> m_xBtnNormalsInvert; - std::unique_ptr<weld::ToggleButton> m_xBtnTwoSidedLighting; - std::unique_ptr<weld::ToggleButton> m_xBtnDoubleSided; + std::unique_ptr<TriStateToggleButton> m_xBtnNormalsInvert; + std::unique_ptr<TriStateToggleButton> m_xBtnTwoSidedLighting; + std::unique_ptr<TriStateToggleButton> m_xBtnDoubleSided; // presentation std::unique_ptr<weld::Container> m_xFLRepresentation; std::unique_ptr<weld::ComboBox> m_xLbShademode; std::unique_ptr<weld::Container> m_xFLShadow; - std::unique_ptr<weld::ToggleButton> m_xBtnShadow3d; + std::unique_ptr<TriStateToggleButton> m_xBtnShadow3d; std::unique_ptr<weld::Label> m_xFtSlant; std::unique_ptr<weld::MetricSpinButton> m_xMtrSlant; @@ -169,7 +169,7 @@ private: std::unique_ptr<weld::ToggleButton> m_xBtnTexObjectY; std::unique_ptr<weld::ToggleButton> m_xBtnTexParallelY; std::unique_ptr<weld::ToggleButton> m_xBtnTexCircleY; - std::unique_ptr<weld::ToggleButton> m_xBtnTexFilter; + std::unique_ptr<TriStateToggleButton> m_xBtnTexFilter; // material // material editor @@ -199,7 +199,7 @@ private: // bottom part std::unique_ptr<weld::Button> m_xBtnConvertTo3D; std::unique_ptr<weld::Button> m_xBtnLatheObject; - std::unique_ptr<weld::ToggleButton> m_xBtnPerspective; + std::unique_ptr<TriStateToggleButton> m_xBtnPerspective; // the rest ... bool bUpdate; @@ -265,7 +265,7 @@ private: LightButton& rLightButton, TypedWhichId<SvxB3DVectorItem> nWhichLightDirection); void UpdateToggleButton(const SfxItemSet& rAttrs, TypedWhichId<SfxBoolItem> nWhich, - weld::ToggleButton& rButton); + TriStateToggleButton& rButton); }; /************************************************************************* diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx index 1c83bb8c6773..bd498a086532 100644 --- a/svx/source/engine3d/float3d.cxx +++ b/svx/source/engine3d/float3d.cxx @@ -111,15 +111,15 @@ Svx3DWin::Svx3DWin(SfxBindings* pInBindings, SfxChildWindow *pCW, vcl::Window* p , m_xBtnNormalsObj(m_xBuilder->weld_toggle_button(u"objspecific"_ustr)) , m_xBtnNormalsFlat(m_xBuilder->weld_toggle_button(u"flat"_ustr)) , m_xBtnNormalsSphere(m_xBuilder->weld_toggle_button(u"spherical"_ustr)) - , m_xBtnNormalsInvert(m_xBuilder->weld_toggle_button(u"invertnormals"_ustr)) - , m_xBtnTwoSidedLighting(m_xBuilder->weld_toggle_button(u"doublesidedillum"_ustr)) - , m_xBtnDoubleSided(m_xBuilder->weld_toggle_button(u"doublesided"_ustr)) + , m_xBtnNormalsInvert(new TriStateToggleButton(m_xBuilder->weld_toggle_button(u"invertnormals"_ustr))) + , m_xBtnTwoSidedLighting(new TriStateToggleButton(m_xBuilder->weld_toggle_button(u"doublesidedillum"_ustr))) + , m_xBtnDoubleSided(new TriStateToggleButton(m_xBuilder->weld_toggle_button(u"doublesided"_ustr))) , m_xFLRepresentation(m_xBuilder->weld_container(u"shadingframe"_ustr)) , m_xLbShademode(m_xBuilder->weld_combo_box(u"mode"_ustr)) , m_xFLShadow(m_xBuilder->weld_container(u"shadowframe"_ustr)) - , m_xBtnShadow3d(m_xBuilder->weld_toggle_button(u"shadow"_ustr)) + , m_xBtnShadow3d(new TriStateToggleButton(m_xBuilder->weld_toggle_button(u"shadow"_ustr))) , m_xFtSlant(m_xBuilder->weld_label(u"slantft"_ustr)) , m_xMtrSlant(m_xBuilder->weld_metric_spin_button(u"slant"_ustr, FieldUnit::DEGREE)) @@ -159,7 +159,7 @@ Svx3DWin::Svx3DWin(SfxBindings* pInBindings, SfxChildWindow *pCW, vcl::Window* p , m_xBtnTexObjectY(m_xBuilder->weld_toggle_button(u"texobjy"_ustr)) , m_xBtnTexParallelY(m_xBuilder->weld_toggle_button(u"texparallely"_ustr)) , m_xBtnTexCircleY(m_xBuilder->weld_toggle_button(u"texcircley"_ustr)) - , m_xBtnTexFilter(m_xBuilder->weld_toggle_button(u"texfilter"_ustr)) + , m_xBtnTexFilter(new TriStateToggleButton(m_xBuilder->weld_toggle_button(u"texfilter"_ustr))) , m_xFLMaterial(m_xBuilder->weld_container(u"materialframe"_ustr)) , m_xLbMatFavorites(m_xBuilder->weld_combo_box(u"favorites"_ustr)) @@ -186,7 +186,7 @@ Svx3DWin::Svx3DWin(SfxBindings* pInBindings, SfxChildWindow *pCW, vcl::Window* p , m_xBtnConvertTo3D(m_xBuilder->weld_button(u"to3d"_ustr)) , m_xBtnLatheObject(m_xBuilder->weld_button(u"tolathe"_ustr)) - , m_xBtnPerspective(m_xBuilder->weld_toggle_button(u"perspective"_ustr)) + , m_xBtnPerspective(new TriStateToggleButton(m_xBuilder->weld_toggle_button(u"perspective"_ustr))) , bUpdate(false) , eViewType(ViewType3D::Geo) @@ -511,7 +511,7 @@ void Svx3DWin::UpdateLight(const SfxItemSet& rAttrs, TypedWhichId<SvxColorItem> } void Svx3DWin::UpdateToggleButton(const SfxItemSet& rAttrs, TypedWhichId<SfxBoolItem> nWhich, - weld::ToggleButton& rButton) + TriStateToggleButton& rButton) { SfxItemState eState = rAttrs.GetItemState(nWhich); if (eState != SfxItemState::INVALID) @@ -1807,7 +1807,7 @@ void Svx3DWin::Resize() m_xBtnConvertTo3D->hide(); m_xBtnLatheObject->hide(); - m_xBtnPerspective->hide(); + m_xBtnPerspective->get_widget()->hide(); m_xCtlPreview->Hide(); m_xLightPreviewGrid->hide(); @@ -1824,7 +1824,7 @@ void Svx3DWin::Resize() m_xBtnConvertTo3D->show(); m_xBtnLatheObject->show(); - m_xBtnPerspective->show(); + m_xBtnPerspective->get_widget()->show(); if( m_xBtnGeo->get_active() ) ClickViewTypeHdl(*m_xBtnGeo); @@ -2101,7 +2101,7 @@ IMPL_LINK( Svx3DWin, ClickHdl, weld::Button&, rBtn, void ) m_xBtnTexObjectY->set_active( &rBtn == m_xBtnTexObjectY.get() ); bUpdatePreview = true; } - else if (&rBtn == m_xBtnShadow3d.get()) + else if (&rBtn == m_xBtnShadow3d->get_widget()) { m_xFtSlant->set_sensitive( m_xBtnShadow3d->get_active() ); m_xMtrSlant->set_sensitive( m_xBtnShadow3d->get_active() ); commit d7097a5157803658793edc6925363bc3bef6e79b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jul 17 10:31:06 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 18 07:07:10 2025 +0200 svx: Extract TriStateToggleButton base from LightButton Svx3DWin is the only place where weld::ToggleButton is currently used with TRISTATE_INDET to indicate a special "inconsistent"/invalid state. That state is not supported by QtInstanceToggleButton and for GTK 4, GtkToggleButton also no longer directly supports that as it did in GTK 3, see GTK commit [1] commit 2aea8dfee97b514e1fca7f577fefdac4e449e906 Author: Timm Bäder <m...@baedert.org> Date: Sat Jan 28 08:11:14 2017 +0100 togglebutton: Move :inconsistent to GtkCheckButton In order to make the inconsistent state specific to weld::CheckButton and dropping weld::Toggleable::set_state etc. in an upcoming commit, the relevant logic to have that special indeterminate state still available for Svx3DWin, introduce TriStateToggleButton used only here to still support the use in this one use case. (There might be a better approach altogether here, too, but I'm not familiar enough with the underlying logic, so try to keep the general logic unchanged for now.) This will be used for more ToggleButtons in Svx3DWin that also make use of TRISTATE_INDET. [1] https://gitlab.gnome.org/GNOME/gtk/-/commit/2aea8dfee97b514e1fca7f577fefdac4e449e906 Change-Id: I4b39f941fdda886390079a00aed4c2ce29be5a43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187999 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/include/svx/float3d.hxx b/include/svx/float3d.hxx index a539a87ddc01..67be4a4c5ebd 100644 --- a/include/svx/float3d.hxx +++ b/include/svx/float3d.hxx @@ -48,14 +48,10 @@ class ColorListBox; struct Svx3DWinImpl; -class UNLESS_MERGELIBS(SVX_DLLPUBLIC) LightButton final +class UNLESS_MERGELIBS(SVX_DLLPUBLIC) TriStateToggleButton { public: - explicit LightButton(std::unique_ptr<weld::ToggleButton> xButton); - - void switchLightOn(bool bOn); - bool isLightOn() const { return m_bLightOn;} - + explicit TriStateToggleButton(std::unique_ptr<weld::ToggleButton> xButton); bool get_active() const { return m_xButton->get_active(); } void set_active(bool bActive) { m_xButton->set_active(bActive); } @@ -69,11 +65,22 @@ public: m_xButton->connect_clicked(rLink); } +private: + std::unique_ptr<weld::ToggleButton> m_xButton; +}; + +class UNLESS_MERGELIBS(SVX_DLLPUBLIC) LightButton final : public TriStateToggleButton +{ +public: + explicit LightButton(std::unique_ptr<weld::ToggleButton> xButton); + + void switchLightOn(bool bOn); + bool isLightOn() const { return m_bLightOn;} + bool get_prev_active() const { return m_bButtonPrevActive; } void set_prev_active(bool bPrevActive) { m_bButtonPrevActive = bPrevActive; } private: - std::unique_ptr<weld::ToggleButton> m_xButton; bool m_bLightOn; bool m_bButtonPrevActive; }; diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx index dbfbe30ca431..1c83bb8c6773 100644 --- a/svx/source/engine3d/float3d.cxx +++ b/svx/source/engine3d/float3d.cxx @@ -2569,12 +2569,17 @@ void SvxConvertTo3DItem::StateChangedAtToolBoxControl(sal_uInt16 /*_nId*/, SfxIt } } -LightButton::LightButton(std::unique_ptr<weld::ToggleButton> xButton) +TriStateToggleButton::TriStateToggleButton(std::unique_ptr<weld::ToggleButton> xButton) : m_xButton(std::move(xButton)) +{ +} + +LightButton::LightButton(std::unique_ptr<weld::ToggleButton> xButton) + : TriStateToggleButton(std::move(xButton)) , m_bLightOn(false) , m_bButtonPrevActive(false) { - m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF); + get_widget()->set_from_icon_name(RID_SVXBMP_LAMP_OFF); } void LightButton::switchLightOn(bool bOn) @@ -2583,9 +2588,9 @@ void LightButton::switchLightOn(bool bOn) return; m_bLightOn = bOn; if (m_bLightOn) - m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_ON); + get_widget()->set_from_icon_name(RID_SVXBMP_LAMP_ON); else - m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF); + get_widget()->set_from_icon_name(RID_SVXBMP_LAMP_OFF); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */