diff options
23 files changed, 1829 insertions, 547 deletions
diff --git a/chart2/IwyuFilter_chart2.yaml b/chart2/IwyuFilter_chart2.yaml index 68761f242b30..445a9f7d60eb 100644 --- a/chart2/IwyuFilter_chart2.yaml +++ b/chart2/IwyuFilter_chart2.yaml @@ -463,7 +463,7 @@ blacklist: - namespace chart { class ThreeD_SceneIllumination_TabPage; } chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx: # Needed for vclptr type - - class SvxColorListBox + - class ColorListBox chart2/source/controller/inc/ItemPropertyMap.hxx: # base class has to be a complete type - map diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx b/chart2/inc/pch/precompiled_chartcontroller.hxx index a72dea77cccc..a6519d6dac8c 100644 --- a/chart2/inc/pch/precompiled_chartcontroller.hxx +++ b/chart2/inc/pch/precompiled_chartcontroller.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2019-05-12 16:56:57 using: + Generated on 2019-06-06 21:24:00 using: ./bin/update_pch chart2 chartcontroller --cutoff=6 --exclude:system --include:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -84,7 +84,6 @@ #include <vcl/GraphicExternalLink.hxx> #include <vcl/GraphicObject.hxx> #include <vcl/IContext.hxx> -#include <vcl/NotebookbarContextControl.hxx> #include <vcl/abstdlg.hxx> #include <vcl/alpha.hxx> #include <vcl/animate/Animation.hxx> @@ -124,7 +123,6 @@ #include <vcl/outdev.hxx> #include <vcl/outdevmap.hxx> #include <vcl/outdevstate.hxx> -#include <vcl/print.hxx> #include <vcl/prntypes.hxx> #include <vcl/region.hxx> #include <vcl/salgtype.hxx> @@ -134,12 +132,9 @@ #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> #include <vcl/syswin.hxx> -#include <vcl/tabctrl.hxx> -#include <vcl/tabdlg.hxx> #include <vcl/tabpage.hxx> #include <vcl/task.hxx> #include <vcl/timer.hxx> -#include <vcl/toolbox.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> #include <vcl/vclptr.hxx> @@ -335,7 +330,6 @@ #include <svtools/colorcfg.hxx> #include <svtools/optionsdrawinglayer.hxx> #include <svtools/svtdllapi.h> -#include <svtools/valueset.hxx> #include <svx/ActionDescriptionProvider.hxx> #include <svx/XPropertyEntry.hxx> #include <svx/chrtitem.hxx> @@ -345,10 +339,8 @@ #include <svx/pageitem.hxx> #include <svx/sdgcpitm.hxx> #include <svx/sdr/animation/scheduler.hxx> -#include <svx/sdr/contact/viewobjectcontactredirector.hxx> #include <svx/sdr/overlay/overlayobject.hxx> #include <svx/sdr/overlay/overlayobjectlist.hxx> -#include <svx/sdrmasterpagedescriptor.hxx> #include <svx/sdrobjectuser.hxx> #include <svx/sdrpageuser.hxx> #include <svx/sdtaditm.hxx> @@ -382,7 +374,6 @@ #include <svx/svdtypes.hxx> #include <svx/svdundo.hxx> #include <svx/svxdllapi.h> -#include <svx/viewpt3d.hxx> #include <svx/xdash.hxx> #include <svx/xdef.hxx> #include <svx/xenum.hxx> diff --git a/chart2/source/controller/dialogs/dlg_View3D.cxx b/chart2/source/controller/dialogs/dlg_View3D.cxx index fc329ce6b733..03a5fcc299f5 100644 --- a/chart2/source/controller/dialogs/dlg_View3D.cxx +++ b/chart2/source/controller/dialogs/dlg_View3D.cxx @@ -35,52 +35,44 @@ using namespace ::com::sun::star::chart2; sal_uInt16 View3DDialog::m_nLastPageId = 0; -View3DDialog::View3DDialog(vcl::Window* pParent, const uno::Reference< frame::XModel > & xChartModel) - : TabDialog(pParent, "3DViewDialog", "modules/schart/ui/3dviewdialog.ui") - , m_pGeometry(nullptr) - , m_pAppearance(nullptr) - , m_pIllumination(nullptr) +View3DDialog::View3DDialog(weld::Window* pParent, const uno::Reference< frame::XModel > & xChartModel) + : GenericDialogController(pParent, "modules/schart/ui/3dviewdialog.ui", "3DViewDialog") , m_aControllerLocker(xChartModel) + , m_xTabControl(m_xBuilder->weld_notebook("tabcontrol")) { - get(m_pTabControl, "tabcontrol"); - uno::Reference< beans::XPropertySet > xSceneProperties( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); - m_pGeometry = VclPtr<ThreeD_SceneGeometry_TabPage>::Create(m_pTabControl,xSceneProperties,m_aControllerLocker); - m_pAppearance = VclPtr<ThreeD_SceneAppearance_TabPage>::Create(m_pTabControl,xChartModel,m_aControllerLocker); - m_pIllumination = VclPtr<ThreeD_SceneIllumination_TabPage>::Create(m_pTabControl,xSceneProperties,xChartModel); - m_pTabControl->InsertPage( TP_3D_SCENEGEOMETRY, SchResId(STR_PAGE_PERSPECTIVE) ); - m_pTabControl->InsertPage( TP_3D_SCENEAPPEARANCE, SchResId(STR_PAGE_APPEARANCE) ); - m_pTabControl->InsertPage( TP_3D_SCENEILLUMINATION, SchResId(STR_PAGE_ILLUMINATION) ); + m_xTabControl->append_page("geometry", SchResId(STR_PAGE_PERSPECTIVE)); + m_xGeometry.reset(new ThreeD_SceneGeometry_TabPage(m_xTabControl->get_page("geometry"), xSceneProperties, m_aControllerLocker)); + + m_xTabControl->append_page("appearance", SchResId(STR_PAGE_APPEARANCE)); + m_xAppearance.reset(new ThreeD_SceneAppearance_TabPage(m_xTabControl->get_page("appearance"), xChartModel, m_aControllerLocker)); + + m_xTabControl->append_page("illumination", SchResId(STR_PAGE_ILLUMINATION)); + m_xIllumination.reset(new ThreeD_SceneIllumination_TabPage(m_xTabControl->get_page("illumination"), m_xDialog.get(), + xSceneProperties, xChartModel)); - m_pTabControl->SetTabPage( TP_3D_SCENEGEOMETRY, m_pGeometry ); - m_pTabControl->SetTabPage( TP_3D_SCENEAPPEARANCE, m_pAppearance ); - m_pTabControl->SetTabPage( TP_3D_SCENEILLUMINATION, m_pIllumination ); + m_xTabControl->connect_enter_page(LINK(this, View3DDialog, ActivatePageHdl)); - m_pTabControl->SelectTabPage( m_nLastPageId ); + m_xTabControl->set_current_page(m_nLastPageId); } -View3DDialog::~View3DDialog() +IMPL_LINK(View3DDialog, ActivatePageHdl, const OString&, rPage, void) { - disposeOnce(); + if (rPage == "appearance") + m_xAppearance->ActivatePage(); } -void View3DDialog::dispose() +View3DDialog::~View3DDialog() { - m_pGeometry.disposeAndClear(); - m_pAppearance.disposeAndClear(); - m_pIllumination.disposeAndClear(); - if (m_pTabControl) - m_nLastPageId = m_pTabControl->GetCurPageId(); - m_pTabControl.clear(); - TabDialog::dispose(); + m_nLastPageId = m_xTabControl->get_current_page(); } -short View3DDialog::Execute() +short View3DDialog::run() { - short nResult = TabDialog::Execute(); - if( nResult == RET_OK && m_pGeometry ) - m_pGeometry->commitPendingChanges(); + short nResult = GenericDialogController::run(); + if (nResult == RET_OK && m_xGeometry) + m_xGeometry->commitPendingChanges(); return nResult; } diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx index 781cd535b47c..1168fe0f18c7 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/drawing/ShadeMode.hpp> #include <tools/diagnose_ex.h> +#include <vcl/svapp.hxx> using namespace ::com::sun::star; @@ -86,53 +87,34 @@ namespace chart #define POS_3DSCHEME_REALISTIC 1 #define POS_3DSCHEME_CUSTOM 2 -ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage( - vcl::Window* pWindow - , const uno::Reference< frame::XModel > & xChartModel - , ControllerLockHelper & rControllerLockHelper ) - : TabPage ( pWindow - , "tp_3D_SceneAppearance" - , "modules/schart/ui/tp_3D_SceneAppearance.ui") - , m_xChartModel ( xChartModel ) - , m_bUpdateOtherControls( true ) - , m_bCommitToModel( true ) - , m_rControllerLockHelper( rControllerLockHelper ) +ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage(weld::Container* pParent, + const uno::Reference<frame::XModel>& xChartModel, + ControllerLockHelper& rControllerLockHelper) + : m_xChartModel(xChartModel) + , m_bUpdateOtherControls(true) + , m_bCommitToModel(true) + , m_rControllerLockHelper(rControllerLockHelper) + , m_xBuilder(Application::CreateBuilder(pParent, "modules/schart/ui/tp_3D_SceneAppearance.ui")) + , m_xContainer(m_xBuilder->weld_container("tp_3D_SceneAppearance")) + , m_xLB_Scheme(m_xBuilder->weld_combo_box("LB_SCHEME")) + , m_xCB_Shading(m_xBuilder->weld_check_button("CB_SHADING")) + , m_xCB_ObjectLines(m_xBuilder->weld_check_button("CB_OBJECTLINES")) + , m_xCB_RoundedEdge(m_xBuilder->weld_check_button("CB_ROUNDEDEDGE")) { + m_aCustom = m_xLB_Scheme->get_text(POS_3DSCHEME_CUSTOM); + m_xLB_Scheme->remove(POS_3DSCHEME_CUSTOM); - get(m_pLB_Scheme, "LB_SCHEME"); - get(m_pCB_Shading, "CB_SHADING"); - get(m_pCB_ObjectLines, "CB_OBJECTLINES"); - get(m_pCB_RoundedEdge, "CB_ROUNDEDEDGE"); + m_xLB_Scheme->connect_changed( LINK( this, ThreeD_SceneAppearance_TabPage, SelectSchemeHdl ) ); - m_aCustom = m_pLB_Scheme->GetEntry(POS_3DSCHEME_CUSTOM); - m_pLB_Scheme->RemoveEntry(POS_3DSCHEME_CUSTOM); - m_pLB_Scheme->SetDropDownLineCount(2); - - m_pLB_Scheme->SetSelectHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectSchemeHdl ) ); - - m_pCB_RoundedEdge->SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); - m_pCB_Shading->SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectShading ) ); - m_pCB_ObjectLines->SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); - - m_pCB_RoundedEdge->EnableTriState(); - m_pCB_Shading->EnableTriState(); - m_pCB_ObjectLines->EnableTriState(); + m_xCB_RoundedEdge->connect_toggled( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); + m_xCB_Shading->connect_toggled( LINK( this, ThreeD_SceneAppearance_TabPage, SelectShading ) ); + m_xCB_ObjectLines->connect_toggled( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); initControlsFromModel(); } ThreeD_SceneAppearance_TabPage::~ThreeD_SceneAppearance_TabPage() { - disposeOnce(); -} - -void ThreeD_SceneAppearance_TabPage::dispose() -{ - m_pLB_Scheme.clear(); - m_pCB_Shading.clear(); - m_pCB_ObjectLines.clear(); - m_pCB_RoundedEdge.clear(); - TabPage::dispose(); } void ThreeD_SceneAppearance_TabPage::ActivatePage() @@ -147,7 +129,7 @@ void ThreeD_SceneAppearance_TabPage::applyRoundedEdgeAndObjectLinesToModel() sal_Int32 nObjectLines = -1; - switch( m_pCB_ObjectLines->GetState()) + switch( m_xCB_ObjectLines->get_state()) { case TRISTATE_FALSE: nObjectLines = 0; @@ -161,7 +143,7 @@ void ThreeD_SceneAppearance_TabPage::applyRoundedEdgeAndObjectLinesToModel() } sal_Int32 nCurrentRoundedEdges = -1; - switch( m_pCB_RoundedEdge->GetState() ) + switch( m_xCB_RoundedEdge->get_state() ) { case TRISTATE_FALSE: nCurrentRoundedEdges = 0; @@ -187,7 +169,7 @@ void ThreeD_SceneAppearance_TabPage::applyShadeModeToModel() drawing::ShadeMode aShadeMode = drawing::ShadeMode_PHONG; - switch( m_pCB_Shading->GetState()) + switch( m_xCB_Shading->get_state()) { case TRISTATE_FALSE: aShadeMode = drawing::ShadeMode_FLAT; @@ -212,52 +194,43 @@ void ThreeD_SceneAppearance_TabPage::initControlsFromModel() if(aProps.m_aShadeMode == drawing::ShadeMode_FLAT) { - m_pCB_Shading->EnableTriState( false ); - m_pCB_Shading->Check(false); + m_xCB_Shading->set_active(false); } else if(aProps.m_aShadeMode == drawing::ShadeMode_SMOOTH) { - m_pCB_Shading->EnableTriState( false ); - m_pCB_Shading->Check(); + m_xCB_Shading->set_active(true); } else { - m_pCB_Shading->EnableTriState(); - m_pCB_Shading->SetState( TRISTATE_INDET ); + m_xCB_Shading->set_state(TRISTATE_INDET); } if(aProps.m_nObjectLines == 0) { - m_pCB_ObjectLines->EnableTriState( false ); - m_pCB_ObjectLines->Check(false); + m_xCB_ObjectLines->set_active(false); } else if(aProps.m_nObjectLines==1) { - m_pCB_ObjectLines->EnableTriState( false ); - m_pCB_ObjectLines->Check(); + m_xCB_ObjectLines->set_active(true); } else { - m_pCB_ObjectLines->EnableTriState(); - m_pCB_ObjectLines->SetState( TRISTATE_INDET ); + m_xCB_ObjectLines->set_state(TRISTATE_INDET); } if(aProps.m_nRoundedEdges >= 5) { - m_pCB_RoundedEdge->EnableTriState( false ); - m_pCB_RoundedEdge->Check(); + m_xCB_RoundedEdge->set_active(true); } else if(aProps.m_nRoundedEdges<0) { - m_pCB_RoundedEdge->EnableTriState( false ); - m_pCB_RoundedEdge->SetState( TRISTATE_INDET ); + m_xCB_RoundedEdge->set_state(TRISTATE_INDET); } else { - m_pCB_RoundedEdge->EnableTriState(); - m_pCB_RoundedEdge->Check(false); + m_xCB_RoundedEdge->set_active(false); } - m_pCB_RoundedEdge->Enable( !m_pCB_ObjectLines->IsChecked() ); + m_xCB_RoundedEdge->set_sensitive( !m_xCB_ObjectLines->get_active() ); updateScheme(); @@ -269,30 +242,26 @@ void ThreeD_SceneAppearance_TabPage::updateScheme() { lcl_ModelProperties aProps( lcl_getPropertiesFromModel( m_xChartModel )); - if( m_pLB_Scheme->GetEntryCount() == (POS_3DSCHEME_CUSTOM+1) ) - { - m_pLB_Scheme->RemoveEntry(POS_3DSCHEME_CUSTOM); - m_pLB_Scheme->SetDropDownLineCount(2); - } + if (m_xLB_Scheme->get_count() == (POS_3DSCHEME_CUSTOM+1)) + m_xLB_Scheme->remove(POS_3DSCHEME_CUSTOM); switch( aProps.m_eScheme ) { case ThreeDLookScheme_Simple: - m_pLB_Scheme->SelectEntryPos( POS_3DSCHEME_SIMPLE ); + m_xLB_Scheme->set_active( POS_3DSCHEME_SIMPLE ); break; case ThreeDLookScheme_Realistic: - m_pLB_Scheme->SelectEntryPos( POS_3DSCHEME_REALISTIC ); + m_xLB_Scheme->set_active( POS_3DSCHEME_REALISTIC ); break; case ThreeDLookScheme_Unknown: { - m_pLB_Scheme->InsertEntry(m_aCustom,POS_3DSCHEME_CUSTOM); - m_pLB_Scheme->SelectEntryPos( POS_3DSCHEME_CUSTOM ); - m_pLB_Scheme->SetDropDownLineCount(3); + m_xLB_Scheme->insert_text(POS_3DSCHEME_CUSTOM, m_aCustom); + m_xLB_Scheme->set_active(POS_3DSCHEME_CUSTOM); } break; } } -IMPL_LINK_NOARG(ThreeD_SceneAppearance_TabPage, SelectSchemeHdl, ListBox&, void) +IMPL_LINK_NOARG(ThreeD_SceneAppearance_TabPage, SelectSchemeHdl, weld::ComboBox&, void) { if( !m_bUpdateOtherControls ) return; @@ -303,9 +272,9 @@ IMPL_LINK_NOARG(ThreeD_SceneAppearance_TabPage, SelectSchemeHdl, ListBox&, void) uno::Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( m_xChartModel ) ); - if( m_pLB_Scheme->GetSelectedEntryPos() == POS_3DSCHEME_REALISTIC ) + if( m_xLB_Scheme->get_active() == POS_3DSCHEME_REALISTIC ) ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Realistic ); - else if( m_pLB_Scheme->GetSelectedEntryPos() == POS_3DSCHEME_SIMPLE ) + else if( m_xLB_Scheme->get_active() == POS_3DSCHEME_SIMPLE ) ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Simple ); else { @@ -317,31 +286,29 @@ IMPL_LINK_NOARG(ThreeD_SceneAppearance_TabPage, SelectSchemeHdl, ListBox&, void) initControlsFromModel(); } -IMPL_LINK_NOARG(ThreeD_SceneAppearance_TabPage, SelectShading, CheckBox&, void) +IMPL_LINK_NOARG(ThreeD_SceneAppearance_TabPage, SelectShading, weld::ToggleButton&, void) { if( !m_bUpdateOtherControls ) return; - m_pCB_Shading->EnableTriState( false ); applyShadeModeToModel(); updateScheme(); } -IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines, CheckBox&, rCheckBox, void ) + +IMPL_LINK(ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines, weld::ToggleButton&, rCheckBox, void) { if( !m_bUpdateOtherControls ) return; - if( &rCheckBox == m_pCB_ObjectLines ) + if (&rCheckBox == m_xCB_ObjectLines.get()) { - m_pCB_ObjectLines->EnableTriState( false ); m_bUpdateOtherControls = false; - m_pCB_RoundedEdge->Enable( !m_pCB_ObjectLines->IsChecked() ); - if(!m_pCB_RoundedEdge->IsEnabled()) - m_pCB_RoundedEdge->Check(false); + m_xCB_RoundedEdge->set_sensitive( !m_xCB_ObjectLines->get_active() ); + if(!m_xCB_RoundedEdge->get_sensitive()) + m_xCB_RoundedEdge->set_active(false); m_bUpdateOtherControls = true; } - else - m_pCB_RoundedEdge->EnableTriState( false ); + applyRoundedEdgeAndObjectLinesToModel(); updateScheme(); } diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx index f85d33290c67..6a00d3fb71be 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx @@ -19,9 +19,7 @@ #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_3D_SCENEAPPEARANCE_HXX #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_3D_SCENEAPPEARANCE_HXX -#include <vcl/tabpage.hxx> -#include <vcl/button.hxx> -#include <vcl/lstbox.hxx> +#include <vcl/weld.hxx> namespace chart { class ControllerLockHelper; } namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } } @@ -29,22 +27,20 @@ namespace com { namespace sun { namespace star { namespace frame { class XModel; namespace chart { -class ThreeD_SceneAppearance_TabPage : public TabPage +class ThreeD_SceneAppearance_TabPage { public: ThreeD_SceneAppearance_TabPage( - vcl::Window* pWindow, + weld::Container* pParent, const css::uno::Reference< css::frame::XModel > & xChartModel, ControllerLockHelper & rControllerLockHelper ); - virtual ~ThreeD_SceneAppearance_TabPage() override; - virtual void dispose() override; - - virtual void ActivatePage() override; + void ActivatePage(); + ~ThreeD_SceneAppearance_TabPage(); private: - DECL_LINK( SelectSchemeHdl, ListBox&, void ); - DECL_LINK( SelectShading, CheckBox&, void ); - DECL_LINK( SelectRoundedEdgeOrObjectLines, CheckBox&, void ); + DECL_LINK( SelectSchemeHdl, weld::ComboBox&, void ); + DECL_LINK( SelectShading, weld::ToggleButton&, void ); + DECL_LINK( SelectRoundedEdgeOrObjectLines, weld::ToggleButton&, void ); void initControlsFromModel(); void applyShadeModeToModel(); @@ -52,20 +48,20 @@ private: void updateScheme(); private: - css::uno::Reference< css::frame::XModel > - m_xChartModel; - - VclPtr<ListBox> m_pLB_Scheme; - - VclPtr<CheckBox> m_pCB_Shading; - VclPtr<CheckBox> m_pCB_ObjectLines; - VclPtr<CheckBox> m_pCB_RoundedEdge; + css::uno::Reference<css::frame::XModel> m_xChartModel; bool m_bUpdateOtherControls; bool m_bCommitToModel; OUString m_aCustom; - ControllerLockHelper & m_rControllerLockHelper; + ControllerLockHelper& m_rControllerLockHelper; + + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::ComboBox> m_xLB_Scheme; + std::unique_ptr<weld::CheckButton> m_xCB_Shading; + std::unique_ptr<weld::CheckButton> m_xCB_ObjectLines; + std::unique_ptr<weld::CheckButton> m_xCB_RoundedEdge; }; } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx index 729f9606033e..af08b2e1751c 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx @@ -26,6 +26,8 @@ #include <com/sun/star/drawing/ProjectionMode.hpp> #include <tools/diagnose_ex.h> #include <tools/helpers.hxx> +#include <vcl/edit.hxx> +#include <vcl/svapp.hxx> namespace chart { @@ -35,37 +37,33 @@ using namespace ::com::sun::star; namespace { -void lcl_SetMetricFieldLimits( MetricField& rField, sal_Int64 nLimit ) +void lcl_SetMetricFieldLimits(weld::MetricSpinButton& rField, sal_Int64 nLimit) { - rField.SetMin(-1*nLimit); - rField.SetFirst(-1*nLimit); - rField.SetMax(nLimit); - rField.SetLast(nLimit); + rField.set_range(-1*nLimit, nLimit, FieldUnit::DEGREE); } } -ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( vcl::Window* pWindow - , const uno::Reference< beans::XPropertySet > & xSceneProperties - , ControllerLockHelper & rControllerLockHelper ) - : TabPage ( pWindow - , "tp_3DSceneGeometry" - , "modules/schart/ui/tp_3D_SceneGeometry.ui") - , m_xSceneProperties( xSceneProperties ) - , m_nXRotation(0) - , m_nYRotation(0) - , m_nZRotation(0) - , m_bAngleChangePending( false ) - , m_bPerspectiveChangePending( false ) - , m_rControllerLockHelper( rControllerLockHelper ) -{ - get(m_pCbxRightAngledAxes,"CBX_RIGHT_ANGLED_AXES"); - get(m_pMFXRotation, "MTR_FLD_X_ROTATION"); - get(m_pMFYRotation, "MTR_FLD_Y_ROTATION"); - get(m_pFtZRotation, "FT_Z_ROTATION"); - get(m_pMFZRotation, "MTR_FLD_Z_ROTATION"); - get(m_pCbxPerspective,"CBX_PERSPECTIVE"); - get(m_pMFPerspective, "MTR_FLD_PERSPECTIVE"); +ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage(weld::Container* pParent, + const uno::Reference< beans::XPropertySet > & xSceneProperties, + ControllerLockHelper & rControllerLockHelper) + : m_xSceneProperties( xSceneProperties ) + , m_nXRotation(0) + , m_nYRotation(0) + , m_nZRotation(0) + , m_bAngleChangePending( false ) + , m_bPerspectiveChangePending( false ) + , m_rControllerLockHelper( rControllerLockHelper ) + , m_xBuilder(Application::CreateBuilder(pParent, "modules/schart/ui/tp_3D_SceneGeometry.ui")) + , m_xContainer(m_xBuilder->weld_container("tp_3DSceneGeometry")) + , m_xCbxRightAngledAxes(m_xBuilder->weld_check_button("CBX_RIGHT_ANGLED_AXES")) + , m_xMFXRotation(m_xBuilder->weld_metric_spin_button("MTR_FLD_X_ROTATION", FieldUnit::DEGREE)) + , m_xMFYRotation(m_xBuilder->weld_metric_spin_button("MTR_FLD_Y_ROTATION", FieldUnit::DEGREE)) + , m_xFtZRotation(m_xBuilder->weld_label("FT_Z_ROTATION")) + , m_xMFZRotation(m_xBuilder->weld_metric_spin_button("MTR_FLD_Z_ROTATION", FieldUnit::DEGREE)) + , m_xCbxPerspective(m_xBuilder->weld_check_button("CBX_PERSPECTIVE")) + , m_xMFPerspective(m_xBuilder->weld_metric_spin_button("MTR_FLD_PERSPECTIVE", FieldUnit::PERCENT)) +{ double fXAngle, fYAngle, fZAngle; ThreeDHelper::getRotationAngleFromDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle ); @@ -75,83 +73,62 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( vcl::Window* pWindow OSL_ENSURE( fZAngle>=-90 && fZAngle<=90, "z angle is out of valid range" ); - lcl_SetMetricFieldLimits( *m_pMFZRotation, 90 ); + lcl_SetMetricFieldLimits( *m_xMFZRotation, 90 ); m_nXRotation = NormAngle180( - ::basegfx::fround(fXAngle * pow(10.0, m_pMFXRotation->GetDecimalDigits()))); + ::basegfx::fround(fXAngle * pow(10.0, m_xMFXRotation->get_digits()))); m_nYRotation = NormAngle180( - ::basegfx::fround(-1.0 * fYAngle * pow(10.0, m_pMFYRotation->GetDecimalDigits()))); + ::basegfx::fround(-1.0 * fYAngle * pow(10.0, m_xMFYRotation->get_digits()))); m_nZRotation = NormAngle180( - ::basegfx::fround(-1.0 * fZAngle * pow(10.0, m_pMFZRotation->GetDecimalDigits()))); - - m_pMFXRotation->SetValue(m_nXRotation); - m_pMFYRotation->SetValue(m_nYRotation); - m_pMFZRotation->SetValue(m_nZRotation); + ::basegfx::fround(-1.0 * fZAngle * pow(10.0, m_xMFZRotation->get_digits()))); - const sal_uLong nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; - Link<Edit&,void> aAngleChangedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleChanged )); - Link<Edit&,void> aAngleEditedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleEdited )); + m_xMFXRotation->set_value(m_nXRotation, FieldUnit::DEGREE); + m_xMFYRotation->set_value(m_nYRotation, FieldUnit::DEGREE); + m_xMFZRotation->set_value(m_nZRotation, FieldUnit::DEGREE); - m_pMFXRotation->EnableUpdateData( nTimeout ); - m_pMFXRotation->SetUpdateDataHdl( aAngleChangedLink ); - m_pMFXRotation->SetModifyHdl( aAngleEditedLink ); + const int nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; + m_aAngleTimer.SetTimeout(nTimeout); + m_aAngleTimer.SetInvokeHandler( LINK( this, ThreeD_SceneGeometry_TabPage, AngleChanged ) ); - m_pMFYRotation->EnableUpdateData( nTimeout ); - m_pMFYRotation->SetUpdateDataHdl( aAngleChangedLink ); - m_pMFYRotation->SetModifyHdl( aAngleEditedLink ); - - m_pMFZRotation->EnableUpdateData( nTimeout ); - m_pMFZRotation->SetUpdateDataHdl( aAngleChangedLink ); - m_pMFZRotation->SetModifyHdl( aAngleEditedLink ); + Link<weld::MetricSpinButton&,void> aAngleEditedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleEdited )); + m_xMFXRotation->connect_value_changed( aAngleEditedLink ); + m_xMFYRotation->connect_value_changed( aAngleEditedLink ); + m_xMFZRotation->connect_value_changed( aAngleEditedLink ); drawing::ProjectionMode aProjectionMode = drawing::ProjectionMode_PERSPECTIVE; m_xSceneProperties->getPropertyValue( "D3DScenePerspective" ) >>= aProjectionMode; - m_pCbxPerspective->Check( aProjectionMode == drawing::ProjectionMode_PERSPECTIVE ); - m_pCbxPerspective->SetToggleHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveToggled )); + m_xCbxPerspective->set_active( aProjectionMode == drawing::ProjectionMode_PERSPECTIVE ); + m_xCbxPerspective->connect_toggled( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveToggled )); sal_Int32 nPerspectivePercentage = 20; m_xSceneProperties->getPropertyValue( "Perspective" ) >>= nPerspectivePercentage; - m_pMFPerspective->SetValue( nPerspectivePercentage ); + m_xMFPerspective->set_value(nPerspectivePercentage, FieldUnit::PERCENT); - m_pMFPerspective->EnableUpdateData( nTimeout ); - m_pMFPerspective->SetUpdateDataHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveChanged ) ); - m_pMFPerspective->SetModifyHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveEdited ) ); - m_pMFPerspective->Enable( m_pCbxPerspective->IsChecked() ); + m_aPerspectiveTimer.SetTimeout(nTimeout); + m_aPerspectiveTimer.SetInvokeHandler( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveChanged ) ); + m_xMFPerspective->connect_value_changed( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveEdited ) ); + m_xMFPerspective->set_sensitive( m_xCbxPerspective->get_active() ); //RightAngledAxes uno::Reference< chart2::XDiagram > xDiagram( m_xSceneProperties, uno::UNO_QUERY ); - if( ChartTypeHelper::isSupportingRightAngledAxes( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) ) + if (ChartTypeHelper::isSupportingRightAngledAxes(DiagramHelper::getChartTypeByIndex(xDiagram, 0))) { bool bRightAngledAxes = false; m_xSceneProperties->getPropertyValue( "RightAngledAxes" ) >>= bRightAngledAxes; - m_pCbxRightAngledAxes->SetToggleHdl( LINK( this, ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled )); - m_pCbxRightAngledAxes->Check( bRightAngledAxes ); + m_xCbxRightAngledAxes->connect_toggled( LINK( this, ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled )); + m_xCbxRightAngledAxes->set_active( bRightAngledAxes ); + RightAngledAxesToggled(*m_xCbxRightAngledAxes); } else { - m_pCbxRightAngledAxes->Enable(false); + m_xCbxRightAngledAxes->set_sensitive(false); } } ThreeD_SceneGeometry_TabPage::~ThreeD_SceneGeometry_TabPage() { - disposeOnce(); } -void ThreeD_SceneGeometry_TabPage::dispose() -{ - m_pCbxRightAngledAxes.clear(); - m_pMFXRotation.clear(); - m_pMFYRotation.clear(); - m_pFtZRotation.clear(); - m_pMFZRotation.clear(); - m_pCbxPerspective.clear(); - m_pMFPerspective.clear(); - TabPage::dispose(); -} - - void ThreeD_SceneGeometry_TabPage::commitPendingChanges() { ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); @@ -168,12 +145,12 @@ void ThreeD_SceneGeometry_TabPage::applyAnglesToModel() double fXAngle = 0.0, fYAngle = 0.0, fZAngle = 0.0; - if( !m_pMFZRotation->IsEmptyFieldValue() ) - m_nZRotation = m_pMFZRotation->GetValue(); + if (m_xMFZRotation->get_sensitive()) + m_nZRotation = m_xMFZRotation->get_value(FieldUnit::DEGREE); - fXAngle = double(m_nXRotation)/pow(10.0,m_pMFXRotation->GetDecimalDigits()); - fYAngle = double(-1.0*m_nYRotation)/pow(10.0,m_pMFYRotation->GetDecimalDigits()); - fZAngle = double(-1.0*m_nZRotation)/pow(10.0,m_pMFZRotation->GetDecimalDigits()); + fXAngle = double(m_nXRotation)/pow(10.0,m_xMFXRotation->get_digits()); + fYAngle = double(-1.0*m_nYRotation)/pow(10.0,m_xMFYRotation->get_digits()); + fZAngle = double(-1.0*m_nZRotation)/pow(10.0,m_xMFZRotation->get_digits()); fXAngle = basegfx::deg2rad(fXAngle); fYAngle = basegfx::deg2rad(fYAngle); @@ -182,17 +159,20 @@ void ThreeD_SceneGeometry_TabPage::applyAnglesToModel() ThreeDHelper::setRotationAngleToDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle ); m_bAngleChangePending = false; + m_aAngleTimer.Stop(); } -IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, AngleEdited, Edit&, void) +IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, AngleEdited, weld::MetricSpinButton&, void) { - m_nXRotation = m_pMFXRotation->GetValue(); - m_nYRotation = m_pMFYRotation->GetValue(); + m_nXRotation = m_xMFXRotation->get_value(FieldUnit::DEGREE); + m_nYRotation = m_xMFYRotation->get_value(FieldUnit::DEGREE); m_bAngleChangePending = true; + + m_aAngleTimer.Start(); } -IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, AngleChanged, Edit&, void) +IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, AngleChanged, Timer *, void) { applyAnglesToModel(); } @@ -201,14 +181,14 @@ void ThreeD_SceneGeometry_TabPage::applyPerspectiveToModel() { ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); - drawing::ProjectionMode aMode = m_pCbxPerspective->IsChecked() + drawing::ProjectionMode aMode = m_xCbxPerspective->get_active() ? drawing::ProjectionMode_PERSPECTIVE : drawing::ProjectionMode_PARALLEL; try { m_xSceneProperties->setPropertyValue( "D3DScenePerspective" , uno::Any( aMode )); - m_xSceneProperties->setPropertyValue( "Perspective" , uno::Any( static_cast<sal_Int32>(m_pMFPerspective->GetValue()) )); + m_xSceneProperties->setPropertyValue( "Perspective" , uno::Any( static_cast<sal_Int32>(m_xMFPerspective->get_value(FieldUnit::PERCENT)) )); } catch( const uno::Exception & ) { @@ -216,56 +196,57 @@ void ThreeD_SceneGeometry_TabPage::applyPerspectiveToModel() } m_bPerspectiveChangePending = false; + m_aPerspectiveTimer.Stop(); } -IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveEdited, Edit&, void) +IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveEdited, weld::MetricSpinButton&, void) { m_bPerspectiveChangePending = true; + m_aPerspectiveTimer.Start(); } -IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveChanged, Edit&, void) +IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveChanged, Timer *, void) { applyPerspectiveToModel(); } -IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveToggled, CheckBox&, void) +IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveToggled, weld::ToggleButton&, void) { - m_pMFPerspective->Enable( m_pCbxPerspective->IsChecked() ); + m_xMFPerspective->set_sensitive(m_xCbxPerspective->get_active()); applyPerspectiveToModel(); } -IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled, CheckBox&, void) +IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled, weld::ToggleButton&, void) { ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); - bool bEnableZ = !m_pCbxRightAngledAxes->IsChecked(); - m_pFtZRotation->Enable( bEnableZ ); - m_pMFZRotation->Enable( bEnableZ ); - m_pMFZRotation->EnableEmptyFieldValue( !bEnableZ ); - if( !bEnableZ ) + bool bEnableZ = !m_xCbxRightAngledAxes->get_active(); + m_xFtZRotation->set_sensitive( bEnableZ ); + m_xMFZRotation->set_sensitive( bEnableZ ); + if (!bEnableZ) { - m_nXRotation = m_pMFXRotation->GetValue(); - m_nYRotation = m_pMFYRotation->GetValue(); - m_nZRotation = m_pMFZRotation->GetValue(); + m_nXRotation = m_xMFXRotation->get_value(FieldUnit::DEGREE); + m_nYRotation = m_xMFYRotation->get_value(FieldUnit::DEGREE); + m_nZRotation = m_xMFZRotation->get_value(FieldUnit::DEGREE); - m_pMFXRotation->SetValue(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nXRotation), ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes()))); - m_pMFYRotation->SetValue(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nYRotation), ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes()))); - m_pMFZRotation->SetEmptyFieldValue(); + m_xMFXRotation->set_value(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nXRotation), ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes())), FieldUnit::DEGREE); + m_xMFYRotation->set_value(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nYRotation), ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes())), FieldUnit::DEGREE); + m_xMFZRotation->set_text(""); - lcl_SetMetricFieldLimits( *m_pMFXRotation, static_cast<sal_Int64>(ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes())); - lcl_SetMetricFieldLimits( *m_pMFYRotation, static_cast<sal_Int64>(ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes())); + lcl_SetMetricFieldLimits( *m_xMFXRotation, static_cast<sal_Int64>(ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes())); + lcl_SetMetricFieldLimits( *m_xMFYRotation, static_cast<sal_Int64>(ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes())); } else { - lcl_SetMetricFieldLimits( *m_pMFXRotation, 180 ); - lcl_SetMetricFieldLimits( *m_pMFYRotation, 180 ); + lcl_SetMetricFieldLimits( *m_xMFXRotation, 180 ); + lcl_SetMetricFieldLimits( *m_xMFYRotation, 180 ); - m_pMFXRotation->SetValue(m_nXRotation); - m_pMFYRotation->SetValue(m_nYRotation); - m_pMFZRotation->SetValue(m_nZRotation); + m_xMFXRotation->set_value(m_nXRotation, FieldUnit::DEGREE); + m_xMFYRotation->set_value(m_nYRotation, FieldUnit::DEGREE); + m_xMFZRotation->set_value(m_nZRotation, FieldUnit::DEGREE); } - ThreeDHelper::switchRightAngledAxes( m_xSceneProperties, m_pCbxRightAngledAxes->IsChecked() ); + ThreeDHelper::switchRightAngledAxes( m_xSceneProperties, m_xCbxRightAngledAxes->get_active() ); } } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx index 5ce39c0c18ca..22c5651d8995 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx @@ -19,10 +19,8 @@ #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_3D_SCENEGEOMETRY_HXX #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_3D_SCENEGEOMETRY_HXX -#include <vcl/tabpage.hxx> -#include <vcl/fixed.hxx> -#include <vcl/field.hxx> -#include <vcl/button.hxx> +#include <vcl/timer.hxx> +#include <vcl/weld.hxx> namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } } namespace chart { class ControllerLockHelper; } @@ -30,29 +28,28 @@ namespace chart { class ControllerLockHelper; } namespace chart { -class ThreeD_SceneGeometry_TabPage : public TabPage +class ThreeD_SceneGeometry_TabPage { public: - ThreeD_SceneGeometry_TabPage( vcl::Window* pWindow, - const css::uno::Reference< css::beans::XPropertySet > & xSceneProperties, - ControllerLockHelper & rControllerLockHelper ); - virtual ~ThreeD_SceneGeometry_TabPage() override; - virtual void dispose() override; + ThreeD_SceneGeometry_TabPage(weld::Container* pWindow, + const css::uno::Reference< css::beans::XPropertySet > & xSceneProperties, + ControllerLockHelper & rControllerLockHelper); + ~ThreeD_SceneGeometry_TabPage(); // has to be called in case the dialog was closed with OK void commitPendingChanges(); // is called by timer to apply changes to model - DECL_LINK( AngleChanged, Edit&, void ); + DECL_LINK( AngleChanged, Timer *, void); // is called immediately when a field changes - DECL_LINK( AngleEdited, Edit&, void ); + DECL_LINK( AngleEdited, weld::MetricSpinButton&, void ); // is called by timer to apply changes to model - DECL_LINK( PerspectiveChanged, Edit&, void ); + DECL_LINK( PerspectiveChanged, Timer *, void); // is called immediately when a field changes - DECL_LINK( PerspectiveEdited, Edit&, void ); - DECL_LINK( PerspectiveToggled, CheckBox&, void ); - DECL_LINK( RightAngledAxesToggled, CheckBox&, void ); + DECL_LINK( PerspectiveEdited, weld::MetricSpinButton&, void ); + DECL_LINK( PerspectiveToggled, weld::ToggleButton&, void ); + DECL_LINK( RightAngledAxesToggled, weld::ToggleButton&, void ); private: void applyAnglesToModel(); @@ -60,17 +57,8 @@ private: css::uno::Reference< css::beans::XPropertySet > m_xSceneProperties; - VclPtr<CheckBox> m_pCbxRightAngledAxes; - - VclPtr<MetricField> m_pMFXRotation; - - VclPtr<MetricField> m_pMFYRotation; - - VclPtr<FixedText> m_pFtZRotation; - VclPtr<MetricField> m_pMFZRotation; - - VclPtr<CheckBox> m_pCbxPerspective; - VclPtr<MetricField> m_pMFPerspective; + Timer m_aAngleTimer; + Timer m_aPerspectiveTimer; //to keep old values when switching to right angled axes sal_Int64 m_nXRotation; @@ -81,6 +69,16 @@ private: bool m_bPerspectiveChangePending; ControllerLockHelper & m_rControllerLockHelper; + + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::CheckButton> m_xCbxRightAngledAxes; + std::unique_ptr<weld::MetricSpinButton> m_xMFXRotation; + std::unique_ptr<weld::MetricSpinButton> m_xMFYRotation; + std::unique_ptr<weld::Label> m_xFtZRotation; + std::unique_ptr<weld::MetricSpinButton> m_xMFZRotation; + std::unique_ptr<weld::CheckButton> m_xCbxPerspective; + std::unique_ptr<weld::MetricSpinButton> m_xMFPerspective; }; } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx index 78b203321c80..b52cbfb0d774 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx @@ -28,7 +28,7 @@ #include <svtools/colrdlg.hxx> #include <svx/svx3ditems.hxx> #include <svx/svddef.hxx> -#include <vcl/builderfactory.hxx> +#include <vcl/svapp.hxx> #include <tools/diagnose_ex.h> #include <com/sun/star/beans/XPropertySet.hpp> @@ -39,28 +39,22 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -LightButton::LightButton( vcl::Window* pParent) - : ImageButton( pParent) - , m_bLightOn(false) +LightButton::LightButton(std::unique_ptr<weld::ToggleButton> xButton) + : m_xButton(std::move(xButton)) + , m_bLightOn(false) { - SetModeImage(Image(StockImage::Yes, RID_SVXBMP_LAMP_OFF)); + m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF); } -VCL_BUILDER_FACTORY(LightButton) - void LightButton::switchLightOn(bool bOn) { - if( m_bLightOn==bOn ) + if (m_bLightOn == bOn) return; m_bLightOn = bOn; - if(m_bLightOn) - { - SetModeImage(Image(StockImage::Yes, RID_SVXBMP_LAMP_ON)); - } + if (m_bLightOn) + m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_ON); else - { - SetModeImage(Image(StockImage::Yes, RID_SVXBMP_LAMP_OFF)); - } + m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF); } struct LightSource @@ -78,8 +72,9 @@ struct LightSource struct LightSourceInfo { - VclPtr<LightButton> pButton; - LightSource aLightSource; + LightButton* pButton; + bool bButtonActive; + LightSource aLightSource; LightSourceInfo(); void initButtonFromSource(); @@ -87,6 +82,7 @@ struct LightSourceInfo LightSourceInfo::LightSourceInfo() : pButton(nullptr) + , bButtonActive(false) , aLightSource() { aLightSource.nDiffuseColor = Color(0xffffff); // white @@ -96,11 +92,9 @@ LightSourceInfo::LightSourceInfo() void LightSourceInfo::initButtonFromSource() { - if(!pButton) + if (!pButton) return; - pButton->SetModeImage(Image(StockImage::Yes, - aLightSource.bIsEnabled ? OUString(RID_SVXBMP_LAMP_ON) : OUString(RID_SVXBMP_LAMP_OFF) - ) ); + pButton->switchLightOn(aLightSource.bIsEnabled); } namespace @@ -118,7 +112,7 @@ namespace return aStr; } - void lcl_selectColor(SvxColorListBox& rListBox, const Color& rColor) + void lcl_selectColor(ColorListBox& rListBox, const Color& rColor) { rListBox.SetNoSelection(); rListBox.SelectEntry(std::make_pair(rColor, lcl_makeColorName(rColor))); @@ -203,88 +197,71 @@ namespace } } -ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( vcl::Window* pWindow - , const uno::Reference< beans::XPropertySet > & xSceneProperties - , const uno::Reference< frame::XModel >& xChartModel ) - : TabPage ( pWindow - ,"tp_3D_SceneIllumination" - ,"modules/schart/ui/tp_3D_SceneIllumination.ui") - , m_xSceneProperties( xSceneProperties ) - , m_aTimerTriggeredControllerLock( xChartModel ) - , m_bInCommitToModel( false ) - , m_xChartModel( xChartModel ) +ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage(weld::Container* pParent, + weld::Window* pTopLevel, + const uno::Reference< beans::XPropertySet > & xSceneProperties, + const uno::Reference< frame::XModel >& xChartModel) + : m_xSceneProperties( xSceneProperties ) + , m_aTimerTriggeredControllerLock( xChartModel ) + , m_bInCommitToModel( false ) + , m_xChartModel( xChartModel ) + , m_pTopLevel(pTopLevel) + , m_xBuilder(Application::CreateBuilder(pParent, "modules/schart/ui/tp_3D_SceneIllumination.ui")) + , m_xContainer(m_xBuilder->weld_container("tp_3D_SceneIllumination")) + , m_xBtn_Light1(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_1"))) + , m_xBtn_Light2(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_2"))) + , m_xBtn_Light3(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_3"))) + , m_xBtn_Light4(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_4"))) + , m_xBtn_Light5(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_5"))) + , m_xBtn_Light6(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_6"))) + , m_xBtn_Light7(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_7"))) + , m_xBtn_Light8(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_8"))) + , m_xLB_LightSource(new ColorListBox(m_xBuilder->weld_menu_button("LB_LIGHTSOURCE"), pTopLevel)) + , m_xBtn_LightSource_Color(m_xBuilder->weld_button("BTN_LIGHTSOURCE_COLOR")) + , m_xLB_AmbientLight(new ColorListBox(m_xBuilder->weld_menu_button("LB_AMBIENTLIGHT"), pTopLevel)) + , m_xBtn_AmbientLight_Color(m_xBuilder->weld_button("BTN_AMBIENT_COLOR")) + , m_xHoriScale(m_xBuilder->weld_scale("hori")) + , m_xVertScale(m_xBuilder->weld_scale("vert")) + , m_xBtn_Corner(m_xBuilder->weld_button("corner")) + , m_xPreview(new LightControl3D) + , m_xPreviewWnd(new weld::CustomWeld(*m_xBuilder, "CTL_LIGHT_PREVIEW", *m_xPreview)) + , m_xCtl_Preview(new LightCtl3D(*m_xPreview, *m_xHoriScale, *m_xVertScale, *m_xBtn_Corner)) { - get(m_pBtn_Light1, "BTN_LIGHT_1"); - get(m_pBtn_Light2, "BTN_LIGHT_2"); - get(m_pBtn_Light3, "BTN_LIGHT_3"); - get(m_pBtn_Light4, "BTN_LIGHT_4"); - get(m_pBtn_Light5, "BTN_LIGHT_5"); - get(m_pBtn_Light6, "BTN_LIGHT_6"); - get(m_pBtn_Light7, "BTN_LIGHT_7"); - get(m_pBtn_Light8, "BTN_LIGHT_8"); - - get(m_pLB_LightSource, "LB_LIGHTSOURCE"); - get(m_pLB_AmbientLight, "LB_AMBIENTLIGHT"); - get(m_pBtn_LightSource_Color, "BTN_LIGHTSOURCE_COLOR"); - get(m_pBtn_AmbientLight_Color, "BTN_AMBIENT_COLOR"); - - get(m_pCtl_Preview, "CTL_LIGHT_PREVIEW"); - m_pLightSourceInfoList.reset(new LightSourceInfo[8]); - m_pLightSourceInfoList[0].pButton = m_pBtn_Light1; - m_pLightSourceInfoList[1].pButton = m_pBtn_Light2; - m_pLightSourceInfoList[2].pButton = m_pBtn_Light3; - m_pLightSourceInfoList[3].pButton = m_pBtn_Light4; - m_pLightSourceInfoList[4].pButton = m_pBtn_Light5; - m_pLightSourceInfoList[5].pButton = m_pBtn_Light6; - m_pLightSourceInfoList[6].pButton = m_pBtn_Light7; - m_pLightSourceInfoList[7].pButton = m_pBtn_Light8; + m_pLightSourceInfoList[0].pButton = m_xBtn_Light1.get(); + m_pLightSourceInfoList[1].pButton = m_xBtn_Light2.get(); + m_pLightSourceInfoList[2].pButton = m_xBtn_Light3.get(); + m_pLightSourceInfoList[3].pButton = m_xBtn_Light4.get(); + m_pLightSourceInfoList[4].pButton = m_xBtn_Light5.get(); + m_pLightSourceInfoList[5].pButton = m_xBtn_Light6.get(); + m_pLightSourceInfoList[6].pButton = m_xBtn_Light7.get(); + m_pLightSourceInfoList[7].pButton = m_xBtn_Light8.get(); fillControlsFromModel(nullptr); - m_pBtn_Light1->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pBtn_Light2->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pBtn_Light3->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pBtn_Light4->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pBtn_Light5->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pBtn_Light6->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pBtn_Light7->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pBtn_Light8->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light1->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light2->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light3->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light4->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light5->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light6->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light7->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_xBtn_Light8->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_pLB_AmbientLight->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); - m_pLB_LightSource->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); + m_xLB_AmbientLight->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); + m_xLB_LightSource->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); - m_pBtn_AmbientLight_Color->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) ); - m_pBtn_LightSource_Color->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) ); + m_xBtn_AmbientLight_Color->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) ); + m_xBtn_LightSource_Color->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) ); - m_pCtl_Preview->SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) ); - m_pCtl_Preview->SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) ); + m_xCtl_Preview->SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) ); + m_xCtl_Preview->SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) ); - ClickLightSourceButtonHdl(m_pBtn_Light2); + ClickLightSourceButtonHdl(*m_xBtn_Light2->get_widget()); } ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage() { - disposeOnce(); -} - -void ThreeD_SceneIllumination_TabPage::dispose() -{ - m_pLightSourceInfoList.reset(); - m_pBtn_Light1.clear(); - m_pBtn_Light2.clear(); - m_pBtn_Light3.clear(); - m_pBtn_Light4.clear(); - m_pBtn_Light5.clear(); - m_pBtn_Light6.clear(); - m_pBtn_Light7.clear(); - m_pBtn_Light8.clear(); - m_pLB_LightSource.clear(); - m_pBtn_LightSource_Color.clear(); - m_pLB_AmbientLight.clear(); - m_pBtn_AmbientLight_Color.clear(); - m_pCtl_Preview.clear(); - TabPage::dispose(); } IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, fillControlsFromModel, void*, void) @@ -298,7 +275,7 @@ IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, fillControlsFromModel, void*, for( nL=0; nL<8; nL++) m_pLightSourceInfoList[nL].initButtonFromSource(); - lcl_selectColor( *m_pLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties )); + lcl_selectColor( *m_xLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties )); updatePreview(); } @@ -321,12 +298,12 @@ void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel() m_aTimerTriggeredControllerLock.startTimer(); } -IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewChangeHdl, SvxLightCtl3D*, void) +IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewChangeHdl, LightCtl3D*, void) { m_aTimerTriggeredControllerLock.startTimer(); //update m_pLightSourceInfoList from preview - const SfxItemSet a3DLightAttributes(m_pCtl_Preview->GetSvx3DLightControl().Get3DAttributes()); + const SfxItemSet a3DLightAttributes(m_xCtl_Preview->GetSvx3DLightControl().Get3DAttributes()); LightSourceInfo* pInfo = &m_pLightSourceInfoList[0]; pInfo->aLightSource.nDiffuseColor = a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1).GetValue(); @@ -371,27 +348,27 @@ IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewChangeHdl, SvxLightCtl3 applyLightSourcesToModel(); } -IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewSelectHdl, SvxLightCtl3D*, void) +IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewSelectHdl, LightCtl3D*, void) { - sal_uInt32 nLightNumber = m_pCtl_Preview->GetSvx3DLightControl().GetSelectedLight(); + sal_uInt32 nLightNumber = m_xCtl_Preview->GetSvx3DLightControl().GetSelectedLight(); if(nLightNumber<8) { LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton; - if(!pButton->IsChecked()) - ClickLightSourceButtonHdl(pButton); + if(!pButton->get_active()) + ClickLightSourceButtonHdl(*pButton->get_widget()); applyLightSourcesToModel(); } } -IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton, void ) +IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, weld::Button&, rButton, void ) { - bool bIsAmbientLight = (pButton==m_pBtn_AmbientLight_Color); - SvxColorListBox* pListBox = bIsAmbientLight ? m_pLB_AmbientLight.get() : m_pLB_LightSource.get(); + bool bIsAmbientLight = (&rButton == m_xBtn_AmbientLight_Color.get()); + ColorListBox* pListBox = bIsAmbientLight ? m_xLB_AmbientLight.get() : m_xLB_LightSource.get(); SvColorDialog aColorDlg; aColorDlg.SetColor( pListBox->GetSelectEntryColor() ); - if( aColorDlg.Execute(GetFrameWeld()) == RET_OK ) + if( aColorDlg.Execute(m_pTopLevel) == RET_OK ) { Color aColor( aColorDlg.GetColor()); lcl_selectColor( *pListBox, aColor ); @@ -409,7 +386,7 @@ IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton, v for( nL=0; nL<8; nL++) { pInfo = &m_pLightSourceInfoList[nL]; - if(pInfo->pButton->IsChecked()) + if(pInfo->pButton->get_active()) break; pInfo = nullptr; } @@ -420,16 +397,16 @@ IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton, v } } -IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, SvxColorListBox&, rBox, void ) +IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, ColorListBox&, rBox, void ) { - SvxColorListBox* pListBox = &rBox; - if(pListBox==m_pLB_AmbientLight) + ColorListBox* pListBox = &rBox; + if (pListBox == m_xLB_AmbientLight.get()) { m_bInCommitToModel = true; lcl_setAmbientColor( m_xSceneProperties, pListBox->GetSelectEntryColor()); m_bInCommitToModel = false; } - else if(pListBox==m_pLB_LightSource) + else if (pListBox == m_xLB_LightSource.get()) { //get active lightsource: LightSourceInfo* pInfo = nullptr; @@ -437,7 +414,7 @@ IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, SvxColorListBox&, r for( nL=0; nL<8; nL++) { pInfo = &m_pLightSourceInfoList[nL]; - if(pInfo->pButton->IsChecked()) + if (pInfo->pButton->get_active()) break; pInfo = nullptr; } @@ -450,59 +427,64 @@ IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, SvxColorListBox&, r updatePreview(); } -IMPL_LINK( ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, Button*, pBtn, void ) +IMPL_LINK(ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, weld::Button&, rBtn, void) { - LightButton* pButton = static_cast<LightButton*>(pBtn); - if( !pButton ) - return; - + LightButton* pButton = nullptr; LightSourceInfo* pInfo = nullptr; sal_Int32 nL=0; for( nL=0; nL<8; nL++) { - if( m_pLightSourceInfoList[nL].pButton == pButton ) + if (m_pLightSourceInfoList[nL].pButton->get_widget() == &rBtn) { + pButton = m_pLightSourceInfoList[nL].pButton; pInfo = &m_pLightSourceInfoList[nL]; break; } } - //update light button - bool bIsChecked = pButton->IsChecked(); - if(bIsChecked) + bool bIsChecked = pInfo->bButtonActive; + + ControllerLockGuardUNO aGuard( m_xChartModel ); + for( nL=0; nL<8; nL++) { - pButton->switchLightOn(!pButton->isLightOn()); - if(pInfo) + LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton; + if (pLightButton == pButton) { - pInfo->aLightSource.bIsEnabled=pButton->isLightOn(); - applyLightSourceToModel( nL ); + pLightButton->set_active(true); + if (!pLightButton->get_widget()->has_focus()) + pLightButton->get_widget()->grab_focus(); + m_pLightSourceInfoList[nL].bButtonActive = true; } - } - else - { - ControllerLockGuardUNO aGuard( m_xChartModel ); - for( nL=0; nL<8; nL++) + else { - LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton; - pLightButton->Check( pLightButton == pButton ); + pLightButton->set_active(false); + m_pLightSourceInfoList[nL].bButtonActive = false; } } + //update light button + if (bIsChecked) + { + pButton->switchLightOn(!pButton->isLightOn()); + pInfo->aLightSource.bIsEnabled=pButton->isLightOn(); + applyLightSourceToModel( nL ); + } + //update color list box if(pInfo) { - lcl_selectColor( *m_pLB_LightSource, pInfo->aLightSource.nDiffuseColor ); + lcl_selectColor( *m_xLB_LightSource, pInfo->aLightSource.nDiffuseColor ); } updatePreview(); } void ThreeD_SceneIllumination_TabPage::updatePreview() { - SfxItemSet aItemSet(m_pCtl_Preview->GetSvx3DLightControl().Get3DAttributes()); + SfxItemSet aItemSet(m_xCtl_Preview->GetSvx3DLightControl().Get3DAttributes()); LightSourceInfo* pInfo = &m_pLightSourceInfoList[0]; // AmbientColor - aItemSet.Put(makeSvx3DAmbientcolorItem(m_pLB_AmbientLight->GetSelectEntryColor())); + aItemSet.Put(makeSvx3DAmbientcolorItem(m_xLB_AmbientLight->GetSelectEntryColor())); aItemSet.Put(makeSvx3DLightcolor1Item(pInfo->aLightSource.nDiffuseColor)); aItemSet.Put(makeSvx3DLightOnOff1Item(pInfo->aLightSource.bIsEnabled)); @@ -544,15 +526,15 @@ void ThreeD_SceneIllumination_TabPage::updatePreview() aItemSet.Put(makeSvx3DLightDirection8Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); // set lights and ambient light - m_pCtl_Preview->GetSvx3DLightControl().Set3DAttributes(aItemSet); + m_xCtl_Preview->GetSvx3DLightControl().Set3DAttributes(aItemSet); // select light for(sal_uInt32 a(0); a < 8; a++) { - if(m_pLightSourceInfoList[a].pButton->IsChecked()) + if (m_pLightSourceInfoList[a].pButton->get_active()) { - m_pCtl_Preview->GetSvx3DLightControl().SelectLight(a); - m_pCtl_Preview->CheckSelection(); + m_xCtl_Preview->GetSvx3DLightControl().SelectLight(a); + m_xCtl_Preview->CheckSelection(); break; } } diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx index 72e39d673539..81bb278e28eb 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx @@ -20,48 +20,56 @@ #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_3D_SCENEILLUMINATION_HXX #include <TimerTriggeredControllerLock.hxx> - -#include <vcl/tabpage.hxx> -#include <vcl/button.hxx> +#include <vcl/weld.hxx> #include <svx/dlgctl3d.hxx> namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } } -class SvxColorListBox; +class ColorListBox; namespace chart { -class LightButton : public ImageButton +class LightButton { public: - explicit LightButton( vcl::Window* pParent); + explicit LightButton(std::unique_ptr<weld::ToggleButton> xButton); void switchLightOn(bool bOn); bool isLightOn() const { return m_bLightOn;} + bool get_active() const { return m_xButton->get_active(); } + void set_active(bool bActive) { m_xButton->set_active(bActive); } + + weld::ToggleButton* get_widget() const { return m_xButton.get(); } + + void connect_clicked(const Link<weld::Button&, void>& rLink) + { + m_xButton->connect_clicked(rLink); + } + private: + std::unique_ptr<weld::ToggleButton> m_xButton; bool m_bLightOn; }; struct LightSourceInfo; -class ThreeD_SceneIllumination_TabPage : public TabPage +class ThreeD_SceneIllumination_TabPage { public: ThreeD_SceneIllumination_TabPage( - vcl::Window* pWindow, + weld::Container* pParent, weld::Window* pTopLevel, const css::uno::Reference< css::beans::XPropertySet > & xSceneProperties, const css::uno::Reference< css::frame::XModel >& xChartModel ); - virtual ~ThreeD_SceneIllumination_TabPage() override; - virtual void dispose() override; + ~ThreeD_SceneIllumination_TabPage(); private: - DECL_LINK( ClickLightSourceButtonHdl, Button*, void ); - DECL_LINK( SelectColorHdl, SvxColorListBox&, void ); - DECL_LINK( ColorDialogHdl, Button*, void ); - DECL_LINK( PreviewChangeHdl, SvxLightCtl3D*, void ); - DECL_LINK( PreviewSelectHdl, SvxLightCtl3D*, void ); + DECL_LINK( ClickLightSourceButtonHdl, weld::Button&, void ); + DECL_LINK( SelectColorHdl, ColorListBox&, void ); + DECL_LINK( ColorDialogHdl, weld::Button&, void ); + DECL_LINK( PreviewChangeHdl, LightCtl3D*, void ); + DECL_LINK( PreviewSelectHdl, LightCtl3D*, void ); void updatePreview(); @@ -71,23 +79,6 @@ private: void applyLightSourceToModel( sal_uInt32 nLightNumber ); void applyLightSourcesToModel(); - VclPtr<LightButton> m_pBtn_Light1; - VclPtr<LightButton> m_pBtn_Light2; - VclPtr<LightButton> m_pBtn_Light3; - VclPtr<LightButton> m_pBtn_Light4; - VclPtr<LightButton> m_pBtn_Light5; - VclPtr<LightButton> m_pBtn_Light6; - VclPtr<LightButton> m_pBtn_Light7; - VclPtr<LightButton> m_pBtn_Light8; - - VclPtr<SvxColorListBox> m_pLB_LightSource; - VclPtr<PushButton> m_pBtn_LightSource_Color; - - VclPtr<SvxColorListBox> m_pLB_AmbientLight; - VclPtr<PushButton> m_pBtn_AmbientLight_Color; - - VclPtr<SvxLightCtl3D> m_pCtl_Preview; - std::unique_ptr<LightSourceInfo[]> m_pLightSourceInfoList; css::uno::Reference< css::beans::XPropertySet > m_xSceneProperties; @@ -96,7 +87,29 @@ private: bool m_bInCommitToModel; - css::uno::Reference< css::frame::XModel > m_xChartModel; + css::uno::Reference<css::frame::XModel> m_xChartModel; + + weld::Window* m_pTopLevel; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<LightButton> m_xBtn_Light1; + std::unique_ptr<LightButton> m_xBtn_Light2; + std::unique_ptr<LightButton> m_xBtn_Light3; + std::unique_ptr<LightButton> m_xBtn_Light4; + std::unique_ptr<LightButton> m_xBtn_Light5; + std::unique_ptr<LightButton> m_xBtn_Light6; + std::unique_ptr<LightButton> m_xBtn_Light7; + std::unique_ptr<LightButton> m_xBtn_Light8; + std::unique_ptr<ColorListBox> m_xLB_LightSource; + std::unique_ptr<weld::Button> m_xBtn_LightSource_Color; + std::unique_ptr<ColorListBox> m_xLB_AmbientLight; + std::unique_ptr<weld::Button> m_xBtn_AmbientLight_Color; + std::unique_ptr<weld::Scale> m_xHoriScale; + std::unique_ptr<weld::Scale> m_xVertScale; + std::unique_ptr<weld::Button> m_xBtn_Corner; + std::unique_ptr<LightControl3D> m_xPreview; + std::unique_ptr<weld::CustomWeld> m_xPreviewWnd; + std::unique_ptr<LightCtl3D> m_xCtl_Preview; }; } //namespace chart diff --git a/chart2/source/controller/inc/dlg_View3D.hxx b/chart2/source/controller/inc/dlg_View3D.hxx index 300b4cb1d989..d386a9f33b94 100644 --- a/chart2/source/controller/inc/dlg_View3D.hxx +++ b/chart2/source/controller/inc/dlg_View3D.hxx @@ -19,9 +19,7 @@ #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_INC_DLG_VIEW3D_HXX #define INCLUDED_CHART2_SOURCE_CONTROLLER_INC_DLG_VIEW3D_HXX -#include <vcl/tabdlg.hxx> -#include <vcl/tabctrl.hxx> - +#include <vcl/weld.hxx> #include <ControllerLockGuard.hxx> namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } } @@ -32,27 +30,25 @@ class ThreeD_SceneGeometry_TabPage; class ThreeD_SceneAppearance_TabPage; class ThreeD_SceneIllumination_TabPage; -class View3DDialog : public TabDialog +class View3DDialog : public weld::GenericDialogController { public: - View3DDialog( vcl::Window* pWindow, - const css::uno::Reference< css::frame::XModel > & xChartModel ); + View3DDialog(weld::Window* pWindow, const css::uno::Reference<css::frame::XModel> & xChartModel); virtual ~View3DDialog() override; - virtual void dispose() override; - // from Dialog (base of TabDialog) - virtual short Execute() override; + virtual short run() override; private: - VclPtr<TabControl> m_pTabControl; - - VclPtr<ThreeD_SceneGeometry_TabPage> m_pGeometry; - VclPtr<ThreeD_SceneAppearance_TabPage> m_pAppearance; - VclPtr<ThreeD_SceneIllumination_TabPage> m_pIllumination; + DECL_LINK(ActivatePageHdl, const OString&, void); ControllerLockHelper m_aControllerLocker; static sal_uInt16 m_nLastPageId; + + std::unique_ptr<weld::Notebook> m_xTabControl; + std::unique_ptr<ThreeD_SceneGeometry_TabPage> m_xGeometry; + std::unique_ptr<ThreeD_SceneAppearance_TabPage> m_xAppearance; + std::unique_ptr<ThreeD_SceneIllumination_TabPage> m_xIllumination; }; } //namespace chart diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 9ba3f1f712e4..69fc84fdda90 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -820,8 +820,8 @@ void ChartController::executeDispatch_View3D() //open dialog SolarMutexGuard aSolarGuard; - ScopedVclPtrInstance< View3DDialog > aDlg(GetChartWindow(), getModel()); - if( aDlg->Execute() == RET_OK ) + View3DDialog aDlg(GetChartFrame(), getModel()); + if (aDlg.run() == RET_OK) aUndoGuard.commit(); } catch(const uno::RuntimeException& e) diff --git a/chart2/uiconfig/ui/3dviewdialog.ui b/chart2/uiconfig/ui/3dviewdialog.ui index a6c138b645c2..1b6e51f674b6 100644 --- a/chart2/uiconfig/ui/3dviewdialog.ui +++ b/chart2/uiconfig/ui/3dviewdialog.ui @@ -1,12 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="chart"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="3DViewDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="3dviewdialog|3DViewDialog">3D View</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> diff --git a/chart2/uiconfig/ui/tp_3D_SceneGeometry.ui b/chart2/uiconfig/ui/tp_3D_SceneGeometry.ui index a09bb40eec32..462ffa67713e 100644 --- a/chart2/uiconfig/ui/tp_3D_SceneGeometry.ui +++ b/chart2/uiconfig/ui/tp_3D_SceneGeometry.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.22.1 --> <interface domain="chart"> <requires lib="gtk+" version="3.18"/> <object class="GtkAdjustment" id="adjustmentPERSPECTIVE"> @@ -7,7 +7,19 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> - <object class="GtkAdjustment" id="adjustmentROTATION"> + <object class="GtkAdjustment" id="adjustmentROTATION1"> + <property name="lower">-180</property> + <property name="upper">180</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentROTATION2"> + <property name="lower">-180</property> + <property name="upper">180</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentROTATION3"> <property name="lower">-180</property> <property name="upper">180</property> <property name="step_increment">1</property> @@ -41,7 +53,7 @@ <property name="can_focus">False</property> <property name="label" translatable="yes" context="tp_3D_SceneGeometry|FT_X_ROTATION">_X rotation</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_FLD_X_ROTATION:0degrees</property> + <property name="mnemonic_widget">MTR_FLD_X_ROTATION</property> <property name="xalign">0</property> </object> <packing> @@ -55,7 +67,7 @@ <property name="can_focus">False</property> <property name="label" translatable="yes" context="tp_3D_SceneGeometry|FT_Y_ROTATION">_Y rotation</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_FLD_Y_ROTATION:0degrees</property> + <property name="mnemonic_widget">MTR_FLD_Y_ROTATION</property> <property name="xalign">0</property> </object> <packing> @@ -69,7 +81,7 @@ <property name="can_focus">False</property> <property name="label" translatable="yes" context="tp_3D_SceneGeometry|FT_Z_ROTATION">_Z rotation</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_FLD_Z_ROTATION:0degrees</property> + <property name="mnemonic_widget">MTR_FLD_Z_ROTATION</property> <property name="xalign">0</property> </object> <packing> @@ -87,7 +99,7 @@ <property name="xalign">0</property> <property name="draw_indicator">True</property> <accessibility> - <relation type="label-for" target="MTR_FLD_PERSPECTIVE:0%"/> + <relation type="label-for" target="MTR_FLD_PERSPECTIVE"/> </accessibility> </object> <packing> @@ -96,15 +108,16 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_FLD_PERSPECTIVE:0%"> + <object class="GtkSpinButton" id="MTR_FLD_PERSPECTIVE"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustmentPERSPECTIVE</property> <accessibility> <relation type="labelled-by" target="CBX_PERSPECTIVE"/> </accessibility> <child internal-child="accessible"> - <object class="AtkObject" id="MTR_FLD_PERSPECTIVE:0%-atkobject"> + <object class="AtkObject" id="MTR_FLD_PERSPECTIVE-atkobject"> <property name="AtkObject::accessible-name" translatable="yes" context="tp_3D_SceneGeometry|MTR_FLD_PERSPECTIVE-atkobject">Perspective</property> </object> </child> @@ -115,11 +128,12 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_FLD_Z_ROTATION:0degrees"> + <object class="GtkSpinButton" id="MTR_FLD_Z_ROTATION"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="input_purpose">alpha</property> - <property name="adjustment">adjustmentROTATION</property> + <property name="adjustment">adjustmentROTATION3</property> <property name="update_policy">if-valid</property> </object> <packing> @@ -128,10 +142,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_FLD_Y_ROTATION:0degrees"> + <object class="GtkSpinButton" id="MTR_FLD_Y_ROTATION"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="adjustment">adjustmentROTATION</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentROTATION2</property> </object> <packing> <property name="left_attach">1</property> @@ -139,10 +154,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_FLD_X_ROTATION:0degrees"> + <object class="GtkSpinButton" id="MTR_FLD_X_ROTATION"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="adjustment">adjustmentROTATION</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentROTATION1</property> </object> <packing> <property name="left_attach">1</property> diff --git a/chart2/uiconfig/ui/tp_3D_SceneIllumination.ui b/chart2/uiconfig/ui/tp_3D_SceneIllumination.ui index e5496795c4b9..8e9cc07afee4 100644 --- a/chart2/uiconfig/ui/tp_3D_SceneIllumination.ui +++ b/chart2/uiconfig/ui/tp_3D_SceneIllumination.ui @@ -1,64 +1,56 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> <interface domain="chart"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkImage" id="IMG_AMBIENT_COLOR"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">svx/res/colordlg.png</property> + <property name="icon_name">svx/res/colordlg.png</property> </object> <object class="GtkImage" id="IMG_LIGHTSOURCE_COLOR"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">svx/res/colordlg.png</property> + <property name="icon_name">svx/res/colordlg.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="yalign">0.44999998807907104</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="yalign">0.50999999046325684</property> - <property name="ypad">1</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_5"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="yalign">0.49000000953674316</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_6"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="yalign">0.50999999046325684</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_7"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0.50999999046325684</property> - <property name="yalign">0.49000000953674316</property> - <property name="xpad">1</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkImage" id="IMG_LIGHT_8"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">svx/res/lighton.png</property> + <property name="icon_name">svx/res/lighton.png</property> </object> <object class="GtkBox" id="tp_3D_SceneIllumination"> <property name="visible">True</property> @@ -96,131 +88,123 @@ <property name="row_spacing">6</property> <property name="column_spacing">12</property> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_1"> + <object class="GtkToggleButton" id="BTN_LIGHT_1"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_1|tooltip_text">Light source 1</property> <property name="image">IMG_LIGHT_1</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_2"> + <object class="GtkToggleButton" id="BTN_LIGHT_2"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_2|tooltip_text">Light source 2</property> <property name="image">IMG_LIGHT_2</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_3"> + <object class="GtkToggleButton" id="BTN_LIGHT_3"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_3|tooltip_text">Light source 3</property> <property name="image">IMG_LIGHT_3</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">2</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_4"> + <object class="GtkToggleButton" id="BTN_LIGHT_4"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_4|tooltip_text">Light source 4</property> <property name="image">IMG_LIGHT_4</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">3</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_5"> + <object class="GtkToggleButton" id="BTN_LIGHT_5"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_5|tooltip_text">Light source 5</property> <property name="image">IMG_LIGHT_5</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_6"> + <object class="GtkToggleButton" id="BTN_LIGHT_6"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_6|tooltip_text">Light source 6</property> <property name="image">IMG_LIGHT_6</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_7"> + <object class="GtkToggleButton" id="BTN_LIGHT_7"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_7|tooltip_text">Light source 7</property> <property name="image">IMG_LIGHT_7</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">2</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="chartcontrollerlo-LightButton" id="BTN_LIGHT_8"> + <object class="GtkToggleButton" id="BTN_LIGHT_8"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|BTN_LIGHT_8|tooltip_text">Light source 8</property> <property name="image">IMG_LIGHT_8</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">3</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -236,9 +220,16 @@ <property name="can_focus">False</property> <property name="spacing">12</property> <child> - <object class="svxcorelo-SvxColorListBox" id="LB_LIGHTSOURCE"> + <object class="GtkMenuButton" id="LB_LIGHTSOURCE"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <property name="label" translatable="no"></property> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">False</property> @@ -247,7 +238,7 @@ </packing> </child> <child> - <object class="GtkButton" id="BTN_LIGHTSOURCE_COLOR"> + <object class="GtkToggleButton" id="BTN_LIGHTSOURCE_COLOR"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -276,10 +267,10 @@ <object class="GtkLabel" id="FT_LIGHTSOURCE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="tp_3D_SceneIllumination|FT_LIGHTSOURCE">_Light source</property> <property name="use_underline">True</property> <property name="mnemonic_widget">BTN_LIGHT_1</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -310,9 +301,16 @@ <property name="can_focus">False</property> <property name="spacing">12</property> <child> - <object class="svxcorelo-SvxColorListBox" id="LB_AMBIENTLIGHT"> + <object class="GtkMenuButton" id="LB_AMBIENTLIGHT"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <property name="label" translatable="no"></property> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">False</property> @@ -321,7 +319,7 @@ </packing> </child> <child> - <object class="GtkButton" id="BTN_AMBIENT_COLOR"> + <object class="GtkToggleButton" id="BTN_AMBIENT_COLOR"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -343,10 +341,10 @@ <object class="GtkLabel" id="FT_AMBIENTLIGHT"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="tp_3D_SceneIllumination|FT_AMBIENTLIGHT">_Ambient light</property> <property name="use_underline">True</property> <property name="mnemonic_widget">LB_AMBIENTLIGHT</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -367,15 +365,77 @@ </packing> </child> <child> - <object class="svxlo-SvxLightCtl3D" id="CTL_LIGHT_PREVIEW"> + <object class="GtkScrolledWindow" id="scrolledwindow"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|CTL_LIGHT_PREVIEW|tooltip_text">Light Preview</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> + <property name="can_focus">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="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="CTL_LIGHT_PREVIEW"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property> + <property name="tooltip_text" translatable="yes" context="tp_3D_SceneIllumination|CTL_LIGHT_PREVIEW|tooltip_text">Light Preview</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="corner"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkScale" id="hori"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="round_digits">1</property> + <property name="draw_value">False</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkScale" id="vert"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="orientation">vertical</property> + <property name="round_digits">1</property> + <property name="draw_value">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> + </child> + </object> + </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 894734b0b13b..5063da3a2b15 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -191,9 +191,6 @@ <glade-widget-class title="Address Preview" name="swlo-SwAddressPreview" generic-name="Address Preview" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> - <glade-widget-class title="Chart Light Button" name="chartcontrollerlo-LightButton" - generic-name="ChartLightButton" parent="GtkButton" - icon-name="widget-gtk-button"/> <glade-widget-class title="Extended Macro Library" name="basctllo-ExtTreeListBox" generic-name="Extended Macro Library List" parent="GtkTreeView" icon-name="widget-gtk-treeview"/> diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx index a9b38b7612ba..ed4241fc3ad7 100644 --- a/include/svx/colorbox.hxx +++ b/include/svx/colorbox.hxx @@ -123,6 +123,7 @@ public: Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; } NamedColor const & GetSelectedEntry() const { return m_aSelectedColor; } + void SelectEntry(const NamedColor& rColor); void SelectEntry(const Color& rColor); void SetNoSelection() { getColorWindow()->SetNoSelection(); } diff --git a/include/svx/dlgctl3d.hxx b/include/svx/dlgctl3d.hxx index 82f544031a55..bc105f18ed89 100644 --- a/include/svx/dlgctl3d.hxx +++ b/include/svx/dlgctl3d.hxx @@ -23,6 +23,8 @@ #include <vcl/ctrl.hxx> #include <vcl/scrbar.hxx> #include <vcl/button.hxx> +#include <vcl/customweld.hxx> +#include <vcl/weld.hxx> #include <svl/itemset.hxx> #include <svx/svxdllapi.h> #include <basegfx/vector/b3dvector.hxx> @@ -64,6 +66,34 @@ public: virtual void Set3DAttributes(const SfxItemSet& rAttr); }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC PreviewControl3D : public weld::CustomWidgetController +{ +protected: + std::unique_ptr<FmFormModel> mpModel; + FmFormPage* mpFmPage; + std::unique_ptr<E3dView> mp3DView; + E3dScene* mpScene; + E3dObject* mp3DObj; + SvxPreviewObjectType mnObjectType; + + void Construct(); + +public: + PreviewControl3D(); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual ~PreviewControl3D() override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Resize() override; + + virtual void SetObjectType(SvxPreviewObjectType nType); + SvxPreviewObjectType GetObjectType() const { return mnObjectType; } + SfxItemSet const & Get3DAttributes() const; + virtual void Set3DAttributes(const SfxItemSet& rAttr); +}; + + class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl { // Callback for interactive changes @@ -134,6 +164,80 @@ public: basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const; }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC LightControl3D : public PreviewControl3D +{ + // Callback for interactive changes + Link<LightControl3D*,void> maChangeCallback; + Link<LightControl3D*,void> maSelectionChangeCallback; + + // lights + sal_uInt32 maSelectedLight; + + // extra objects for light control + E3dObject* mpExpansionObject; + E3dObject* mpLampBottomObject; + E3dObject* mpLampShaftObject; + std::vector< E3dObject* > maLightObjects; + + // 3d rotations of object + double mfRotateX; + double mfRotateY; + double mfRotateZ; + + // interaction parameters + Point maActionStartPoint; + double mfSaveActionStartHor; + double mfSaveActionStartVer; + double mfSaveActionStartRotZ; + + bool mbMouseMoved : 1; + bool mbMouseCaptured : 1; + bool mbGeometrySelected : 1; + + void Construct2(); + void ConstructLightObjects(); + void AdaptToSelectedLight(); + void TrySelection(Point aPosPixel); + +public: + LightControl3D(); + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual tools::Rectangle GetFocusRect() override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + virtual bool MouseMove( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void Resize() override; + + virtual void SetObjectType(SvxPreviewObjectType nType) override; + + // register user callback + void SetChangeCallback(Link<LightControl3D*,void> aNew) { maChangeCallback = aNew; } + void SetSelectionChangeCallback(Link<LightControl3D*,void> aNew) { maSelectionChangeCallback = aNew; } + + // selection checks + bool IsSelectionValid(); + bool IsGeometrySelected() { return mbGeometrySelected; } + + // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees + void GetPosition(double& rHor, double& rVer); + void SetPosition(double fHor, double fVer); + + // get/set rotation of 3D object + void SetRotation(double fRotX, double fRotY, double fRotZ); + void GetRotation(double& rRotX, double& rRotY, double& rRotZ); + + void SelectLight(sal_uInt32 nLightNumber); + virtual void Set3DAttributes(const SfxItemSet& rAttr) override; + sal_uInt32 GetSelectedLight() { return maSelectedLight; } + + // light data access + bool GetLightOnOff(sal_uInt32 nNum) const; + Color GetLightColor(sal_uInt32 nNum) const; + basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const; +}; + class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLightCtl3D final : public Control { // local controls @@ -184,6 +288,49 @@ private: void move( double fDeltaHor, double fDeltaVer ); }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC LightCtl3D +{ + // local controls + LightControl3D& mrLightControl; + weld::Scale& mrHorScroller; + weld::Scale& mrVerScroller; + weld::Button& mrSwitcher; + + // callback for interactive changes + Link<LightCtl3D*,void> maUserInteractiveChangeCallback; + Link<LightCtl3D*,void> maUserSelectionChangeCallback; + +public: + LightCtl3D(LightControl3D& rLightControl, weld::Scale& rHori, + weld::Scale& rVert, weld::Button& rButton); + ~LightCtl3D(); + + // check the selection for validity + void CheckSelection(); + + // bring further settings to the outside world + LightControl3D& GetSvx3DLightControl() { return mrLightControl; } + + // register user callback + void SetUserInteractiveChangeCallback(Link<LightCtl3D*,void> aNew) { maUserInteractiveChangeCallback = aNew; } + void SetUserSelectionChangeCallback(Link<LightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; } + +private: + + DECL_LINK(InternalInteractiveChange, LightControl3D*, void); + DECL_LINK(InternalSelectionChange, LightControl3D*, void); + DECL_LINK(ScrollBarMove, weld::Scale&, void); + DECL_LINK(ButtonPress, weld::Button&, void); + DECL_LINK(KeyInput, const KeyEvent&, bool); + DECL_LINK(FocusIn, weld::Widget&, void); + + // initialize local parameters + void Init(); + + void move( double fDeltaHor, double fDeltaVer ); +}; + + #endif // _SCH_DLGCTL3D_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/uiconfig/ui/alienwarndialog.ui b/sfx2/uiconfig/ui/alienwarndialog.ui index 8df45d0f12c0..0f014bc0233c 100644 --- a/sfx2/uiconfig/ui/alienwarndialog.ui +++ b/sfx2/uiconfig/ui/alienwarndialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.2 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sfx"> <requires lib="gtk+" version="3.18"/> <object class="GtkMessageDialog" id="AlienWarnDialog"> diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index e6b8e91a84ea..65930e3e8226 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -461,7 +461,6 @@ custom_widgets = [ 'FontStyleBox', 'IndexBox', 'IndexBox', - 'LightButton', 'ManagedMenuButton', 'MultiLineEditSyntaxHighlight', 'OFileURLControl', diff --git a/solenv/gbuild/UIConfig.mk b/solenv/gbuild/UIConfig.mk index 90982513a5cd..e7fa50a745b0 100644 --- a/solenv/gbuild/UIConfig.mk +++ b/solenv/gbuild/UIConfig.mk @@ -140,7 +140,7 @@ endif # These are storage, containers, or preview gb_UIConfig_gla11y_PARAMETERS += --widgets-suffixignored +ValueSet,HBox,VBox,ToolBox,Preview,PreviewWin,PreviewWindow,PrevWindow # These are buttons, thus already contain their label (but an image is not enough) -gb_UIConfig_gla11y_PARAMETERS += --widgets-button +chartcontrollerlo-LightButton,svtlo-ManagedMenuButton +gb_UIConfig_gla11y_PARAMETERS += --widgets-button +svtlo-ManagedMenuButton # All new warnings should be fatal except a few kinds which could be only doubtful gb_UIConfig_gla11y_PARAMETERS += --fatal-all --not-fatal-type duplicate-mnemonic --not-fatal-type labelled-by-and-mnemonic --not-fatal-type orphan-label diff --git a/solenv/sanitizers/ui/modules/schart.suppr b/solenv/sanitizers/ui/modules/schart.suppr index d26296f8dc43..d607e22a0bc3 100644 --- a/solenv/sanitizers/ui/modules/schart.suppr +++ b/solenv/sanitizers/ui/modules/schart.suppr @@ -25,6 +25,10 @@ chart2/uiconfig/ui/titlerotationtabpage.ui://GtkSpinButton[@id='OrientDegree'] n chart2/uiconfig/ui/titlerotationtabpage.ui://GtkLabel[@id='degreeL'] orphan-label chart2/uiconfig/ui/titlerotationtabpage.ui://GtkLabel[@id='labelABCD'] orphan-label chart2/uiconfig/ui/titlerotationtabpage.ui://GtkLabel[@id='textdirL'] orphan-label +chart2/uiconfig/ui/tp_3D_SceneIllumination.ui://GtkMenuButton[@id='LB_LIGHTSOURCE'] button-no-label +chart2/uiconfig/ui/tp_3D_SceneIllumination.ui://GtkButton[@id='corner'] button-no-label +chart2/uiconfig/ui/tp_3D_SceneIllumination.ui://GtkScale[@id='hori'] no-labelled-by +chart2/uiconfig/ui/tp_3D_SceneIllumination.ui://GtkScale[@id='vert'] no-labelled-by chart2/uiconfig/ui/tp_axisLabel.ui://GtkSpinButton[@id='OrientDegree'] no-labelled-by chart2/uiconfig/ui/tp_axisLabel.ui://GtkLabel[@id='degreeL'] orphan-label chart2/uiconfig/ui/tp_axisLabel.ui://GtkLabel[@id='labelABCD'] orphan-label diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx index c7f24743dd29..209729fd9ce3 100644 --- a/svx/source/dialog/dlgctl3d.cxx +++ b/svx/source/dialog/dlgctl3d.cxx @@ -243,6 +243,196 @@ void Svx3DPreviewControl::Set3DAttributes( const SfxItemSet& rAttr ) Resize(); } +PreviewControl3D::PreviewControl3D() + : mpFmPage(nullptr) + , mpScene(nullptr) + , mp3DObj(nullptr) + , mnObjectType(SvxPreviewObjectType::SPHERE) +{ +} + +void PreviewControl3D::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(80, 100), MapMode(MapUnit::MapAppFont))); + pDrawingArea->set_size_request(aSize.Width(), aSize.Height()); + CustomWidgetController::SetDrawingArea(pDrawingArea); + SetOutputSizePixel(aSize); + + Construct(); +} + +PreviewControl3D::~PreviewControl3D() +{ + mp3DView.reset(); + mpModel.reset(); +} + +void PreviewControl3D::Construct() +{ + // Do never mirror the preview window. This explicitly includes right + // to left writing environments. + EnableRTL (false); + OutputDevice& rDevice = GetDrawingArea()->get_ref_device(); + rDevice.SetMapMode(MapMode(MapUnit::Map100thMM)); + + // Model + mpModel.reset(new FmFormModel()); + mpModel->GetItemPool().FreezeIdRanges(); + + // Page + mpFmPage = new FmFormPage( *mpModel ); + mpModel->InsertPage( mpFmPage, 0 ); + + // 3D View + mp3DView.reset(new E3dView(*mpModel, &rDevice)); + mp3DView->SetBufferedOutputAllowed(true); + mp3DView->SetBufferedOverlayAllowed(true); + + // 3D Scene + mpScene = new E3dScene(*mpModel); + + // initially create object + SetObjectType(SvxPreviewObjectType::SPHERE); + + // camera and perspective + Camera3D rCamera = mpScene->GetCamera(); + const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume(); + double fW = rVolume.getWidth(); + double fH = rVolume.getHeight(); + double fCamZ = rVolume.getMaxZ() + ((fW + fH) / 2.0); + + rCamera.SetAutoAdjustProjection(false); + rCamera.SetViewWindow(- fW / 2, - fH / 2, fW, fH); + basegfx::B3DPoint aLookAt; + double fDefaultCamPosZ = mp3DView->GetDefaultCamPosZ(); + basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ); + rCamera.SetPosAndLookAt(aCamPos, aLookAt); + double fDefaultCamFocal = mp3DView->GetDefaultCamFocal(); + rCamera.SetFocalLength(fDefaultCamFocal); + + mpScene->SetCamera( rCamera ); + mpFmPage->InsertObject( mpScene ); + + basegfx::B3DHomMatrix aRotation; + aRotation.rotate(DEG2RAD( 25 ), 0.0, 0.0); + aRotation.rotate(0.0, DEG2RAD( 40 ), 0.0); + mpScene->SetTransform(aRotation * mpScene->GetTransform()); + + // invalidate SnapRects of objects + mpScene->SetRectsDirty(); + + SfxItemSet aSet( mpModel->GetItemPool(), + svl::Items<XATTR_LINESTYLE, XATTR_LINESTYLE, + XATTR_FILL_FIRST, XATTR_FILLBITMAP>{} ); + aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) ); + aSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); + aSet.Put( XFillColorItem( "", COL_WHITE ) ); + + mpScene->SetMergedItemSet(aSet); + + // PageView + SdrPageView* pPageView = mp3DView->ShowSdrPage( mpFmPage ); + mp3DView->hideMarkHandles(); + + // mark scene + mp3DView->MarkObj( mpScene, pPageView ); +} + +void PreviewControl3D::Resize() +{ + // size of page + Size aSize(GetOutputSizePixel()); + aSize = GetDrawingArea()->get_ref_device().PixelToLogic(aSize); + mpFmPage->SetSize(aSize); + + // set size + Size aObjSize( aSize.Width()*5/6, aSize.Height()*5/6 ); + Point aObjPoint( (aSize.Width() - aObjSize.Width()) / 2, + (aSize.Height() - aObjSize.Height()) / 2); + tools::Rectangle aRect( aObjPoint, aObjSize); + mpScene->SetSnapRect( aRect ); +} + +void PreviewControl3D::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) +{ + mp3DView->CompleteRedraw(&rRenderContext, vcl::Region(rRect)); +} + +bool PreviewControl3D::MouseButtonDown(const MouseEvent& rMEvt) +{ + if (rMEvt.IsShift() && rMEvt.IsMod1()) + { + if(SvxPreviewObjectType::SPHERE == GetObjectType()) + { + SetObjectType(SvxPreviewObjectType::CUBE); + } + else + { + SetObjectType(SvxPreviewObjectType::SPHERE); + } + } + return false; +} + +void PreviewControl3D::SetObjectType(SvxPreviewObjectType nType) +{ + if( mnObjectType != nType || !mp3DObj) + { + SfxItemSet aSet(mpModel->GetItemPool(), svl::Items<SDRATTR_START, SDRATTR_END>{}); + mnObjectType = nType; + + if( mp3DObj ) + { + aSet.Put(mp3DObj->GetMergedItemSet()); + mpScene->RemoveObject( mp3DObj->GetOrdNum() ); + // always use SdrObject::Free(...) for SdrObjects (!) + SdrObject* pTemp(mp3DObj); + SdrObject::Free(pTemp); + } + + switch( nType ) + { + case SvxPreviewObjectType::SPHERE: + { + mp3DObj = new E3dSphereObj( + *mpModel, + mp3DView->Get3DDefaultAttributes(), + basegfx::B3DPoint( 0, 0, 0 ), + basegfx::B3DVector( 5000, 5000, 5000 )); + } + break; + + case SvxPreviewObjectType::CUBE: + { + mp3DObj = new E3dCubeObj( + *mpModel, + mp3DView->Get3DDefaultAttributes(), + basegfx::B3DPoint( -2500, -2500, -2500 ), + basegfx::B3DVector( 5000, 5000, 5000 )); + } + break; + } + + if (mp3DObj) + { + mpScene->InsertObject( mp3DObj ); + mp3DObj->SetMergedItemSet(aSet); + } + + Invalidate(); + } +} + +SfxItemSet const & PreviewControl3D::Get3DAttributes() const +{ + return mp3DObj->GetMergedItemSet(); +} + +void PreviewControl3D::Set3DAttributes( const SfxItemSet& rAttr ) +{ + mp3DObj->SetMergedItemSet(rAttr, true); + Resize(); +} #define RADIUS_LAMP_PREVIEW_SIZE (4500.0) #define RADIUS_LAMP_SMALL (600.0) @@ -929,6 +1119,677 @@ basegfx::B3DVector Svx3DLightControl::GetLightDirection(sal_uInt32 nNum) const return basegfx::B3DVector(); } +LightControl3D::LightControl3D() +: maChangeCallback(), + maSelectionChangeCallback(), + maSelectedLight(NO_LIGHT_SELECTED), + mpExpansionObject(nullptr), + mpLampBottomObject(nullptr), + mpLampShaftObject(nullptr), + maLightObjects(MAX_NUMBER_LIGHTS, nullptr), + mfRotateX(-20.0), + mfRotateY(45.0), + mfRotateZ(0.0), + maActionStartPoint(), + mfSaveActionStartHor(0.0), + mfSaveActionStartVer(0.0), + mfSaveActionStartRotZ(0.0), + mbMouseMoved(false), + mbMouseCaptured(false), + mbGeometrySelected(false) +{ +} + +void LightControl3D::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + PreviewControl3D::SetDrawingArea(pDrawingArea); + Construct2(); +} + +void LightControl3D::Construct2() +{ + { + // hide all page stuff, use control background (normally gray) + const Color aDialogColor(Application::GetSettings().GetStyleSettings().GetDialogColor()); + mp3DView->SetPageVisible(false); + mp3DView->SetApplicationBackgroundColor(aDialogColor); + mp3DView->SetApplicationDocumentColor(aDialogColor); + } + + { + // create invisible expansion object + const double fMaxExpansion(RADIUS_LAMP_BIG + RADIUS_LAMP_PREVIEW_SIZE); + mpExpansionObject = new E3dCubeObj( + *mpModel, + mp3DView->Get3DDefaultAttributes(), + basegfx::B3DPoint(-fMaxExpansion, -fMaxExpansion, -fMaxExpansion), + basegfx::B3DVector(2.0 * fMaxExpansion, 2.0 * fMaxExpansion, 2.0 * fMaxExpansion)); + mpScene->InsertObject( mpExpansionObject ); + SfxItemSet aSet(mpModel->GetItemPool()); + aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) ); + aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + mpExpansionObject->SetMergedItemSet(aSet); + } + + { + // create lamp control object (Yellow lined object) + // base circle + const basegfx::B2DPolygon a2DCircle(basegfx::utils::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), RADIUS_LAMP_PREVIEW_SIZE)); + basegfx::B3DPolygon a3DCircle(basegfx::utils::createB3DPolygonFromB2DPolygon(a2DCircle)); + basegfx::B3DHomMatrix aTransform; + + aTransform.rotate(F_PI2, 0.0, 0.0); + aTransform.translate(0.0, -RADIUS_LAMP_PREVIEW_SIZE, 0.0); + a3DCircle.transform(aTransform); + + // create object for it + mpLampBottomObject = new E3dPolygonObj( + *mpModel, + basegfx::B3DPolyPolygon(a3DCircle)); + mpScene->InsertObject( mpLampBottomObject ); + + // half circle with stand + basegfx::B2DPolygon a2DHalfCircle; + a2DHalfCircle.append(basegfx::B2DPoint(RADIUS_LAMP_PREVIEW_SIZE, 0.0)); + a2DHalfCircle.append(basegfx::B2DPoint(RADIUS_LAMP_PREVIEW_SIZE, -RADIUS_LAMP_PREVIEW_SIZE)); + a2DHalfCircle.append(basegfx::utils::createPolygonFromEllipseSegment( + basegfx::B2DPoint(0.0, 0.0), RADIUS_LAMP_PREVIEW_SIZE, RADIUS_LAMP_PREVIEW_SIZE, F_2PI - F_PI2, F_PI2)); + basegfx::B3DPolygon a3DHalfCircle(basegfx::utils::createB3DPolygonFromB2DPolygon(a2DHalfCircle)); + + // create object for it + mpLampShaftObject = new E3dPolygonObj( + *mpModel, + basegfx::B3DPolyPolygon(a3DHalfCircle)); + mpScene->InsertObject( mpLampShaftObject ); + + // initially invisible + SfxItemSet aSet(mpModel->GetItemPool()); + aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) ); + aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + + mpLampBottomObject->SetMergedItemSet(aSet); + mpLampShaftObject->SetMergedItemSet(aSet); + } + + { + // change camera settings + Camera3D rCamera = mpScene->GetCamera(); + const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume(); + double fW = rVolume.getWidth(); + double fH = rVolume.getHeight(); + double fCamZ = rVolume.getMaxZ() + ((fW + fH) / 2.0); + + rCamera.SetAutoAdjustProjection(false); + rCamera.SetViewWindow(- fW / 2, - fH / 2, fW, fH); + basegfx::B3DPoint aLookAt; + double fDefaultCamPosZ = mp3DView->GetDefaultCamPosZ(); + basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ); + rCamera.SetPosAndLookAt(aCamPos, aLookAt); + double fDefaultCamFocal = mp3DView->GetDefaultCamFocal(); + rCamera.SetFocalLength(fDefaultCamFocal); + + mpScene->SetCamera( rCamera ); + + basegfx::B3DHomMatrix aNeutral; + mpScene->SetTransform(aNeutral); + } + + // invalidate SnapRects of objects + mpScene->SetRectsDirty(); +} + +void LightControl3D::ConstructLightObjects() +{ + for(sal_uInt32 a(0); a < MAX_NUMBER_LIGHTS; a++) + { + // get rid of possible existing light object + if(maLightObjects[a]) + { + mpScene->RemoveObject(maLightObjects[a]->GetOrdNum()); + // always use SdrObject::Free(...) for SdrObjects (!) + SdrObject* pTemp(maLightObjects[a]); + SdrObject::Free(pTemp); + maLightObjects[a] = nullptr; + } + + if(GetLightOnOff(a)) + { + const bool bIsSelectedLight(a == maSelectedLight); + basegfx::B3DVector aDirection(GetLightDirection(a)); + aDirection.normalize(); + aDirection *= RADIUS_LAMP_PREVIEW_SIZE; + + const double fLampSize(bIsSelectedLight ? RADIUS_LAMP_BIG : RADIUS_LAMP_SMALL); + E3dObject* pNewLight = new E3dSphereObj( + *mpModel, + mp3DView->Get3DDefaultAttributes(), + basegfx::B3DPoint( 0, 0, 0 ), + basegfx::B3DVector( fLampSize, fLampSize, fLampSize)); + mpScene->InsertObject(pNewLight); + + basegfx::B3DHomMatrix aTransform; + aTransform.translate(aDirection.getX(), aDirection.getY(), aDirection.getZ()); + pNewLight->SetTransform(aTransform); + + SfxItemSet aSet(mpModel->GetItemPool()); + aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) ); + aSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); + aSet.Put( XFillColorItem(OUString(), GetLightColor(a))); + pNewLight->SetMergedItemSet(aSet); + + maLightObjects[a] = pNewLight; + } + } +} + +void LightControl3D::AdaptToSelectedLight() +{ + if(NO_LIGHT_SELECTED == maSelectedLight) + { + // make mpLampBottomObject/mpLampShaftObject invisible + SfxItemSet aSet(mpModel->GetItemPool()); + aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) ); + aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + mpLampBottomObject->SetMergedItemSet(aSet); + mpLampShaftObject->SetMergedItemSet(aSet); + } + else + { + basegfx::B3DVector aDirection(GetLightDirection(maSelectedLight)); + aDirection.normalize(); + + // make mpLampBottomObject/mpLampShaftObject visible (yellow hairline) + SfxItemSet aSet(mpModel->GetItemPool()); + aSet.Put( XLineStyleItem( drawing::LineStyle_SOLID ) ); + aSet.Put( XLineColorItem(OUString(), COL_YELLOW)); + aSet.Put( XLineWidthItem(0)); + aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + mpLampBottomObject->SetMergedItemSet(aSet); + mpLampShaftObject->SetMergedItemSet(aSet); + + // adapt transformation of mpLampShaftObject + basegfx::B3DHomMatrix aTransform; + double fRotateY(0.0); + + if(!basegfx::fTools::equalZero(aDirection.getZ()) || !basegfx::fTools::equalZero(aDirection.getX())) + { + fRotateY = atan2(-aDirection.getZ(), aDirection.getX()); + } + + aTransform.rotate(0.0, fRotateY, 0.0); + mpLampShaftObject->SetTransform(aTransform); + + // adapt transformation of selected light + E3dObject* pSelectedLight = maLightObjects[sal_Int32(maSelectedLight)]; + + if(pSelectedLight) + { + aTransform.identity(); + aTransform.translate( + aDirection.getX() * RADIUS_LAMP_PREVIEW_SIZE, + aDirection.getY() * RADIUS_LAMP_PREVIEW_SIZE, + aDirection.getZ() * RADIUS_LAMP_PREVIEW_SIZE); + pSelectedLight->SetTransform(aTransform); + } + } +} + +void LightControl3D::TrySelection(Point aPosPixel) +{ + if(mpScene) + { + const Point aPosLogic(GetDrawingArea()->get_ref_device().PixelToLogic(aPosPixel)); + const basegfx::B2DPoint aPoint(aPosLogic.X(), aPosLogic.Y()); + std::vector< const E3dCompoundObject* > aResult; + getAllHit3DObjectsSortedFrontToBack(aPoint, *mpScene, aResult); + + if(!aResult.empty()) + { + // exclude expansion object which will be part of + // the hits. It's invisible, but for HitTest, it's included + const E3dCompoundObject* pResult = nullptr; + + for(auto const & b: aResult) + { + if(b && b != mpExpansionObject) + { + pResult = b; + break; + } + } + + if(pResult == mp3DObj) + { + if(!mbGeometrySelected) + { + mbGeometrySelected = true; + maSelectedLight = NO_LIGHT_SELECTED; + ConstructLightObjects(); + AdaptToSelectedLight(); + Invalidate(); + + if(maSelectionChangeCallback.IsSet()) + { + maSelectionChangeCallback.Call(this); + } + } + } + else + { + sal_uInt32 aNewSelectedLight(NO_LIGHT_SELECTED); + + for(sal_uInt32 a(0); a < MAX_NUMBER_LIGHTS; a++) + { + if(maLightObjects[a] && maLightObjects[a] == pResult) + { + aNewSelectedLight = a; + } + } + + if(aNewSelectedLight != maSelectedLight) + { + SelectLight(aNewSelectedLight); + + if(maSelectionChangeCallback.IsSet()) + { + maSelectionChangeCallback.Call(this); + } + } + } + } + } +} + +void LightControl3D::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) +{ + PreviewControl3D::Paint(rRenderContext, rRect); +} + +tools::Rectangle LightControl3D::GetFocusRect() +{ + if (!HasFocus()) + return tools::Rectangle(); + Size aFocusSize = GetOutputSizePixel(); + aFocusSize.AdjustWidth( -4 ); + aFocusSize.AdjustHeight( -4 ); + return tools::Rectangle(Point(2, 2), aFocusSize); +} + +bool LightControl3D::MouseButtonDown( const MouseEvent& rMEvt ) +{ + bool bCallParent(true); + + // switch state + if(rMEvt.IsLeft()) + { + if(IsSelectionValid() || mbGeometrySelected) + { + mbMouseMoved = false; + bCallParent = false; + maActionStartPoint = rMEvt.GetPosPixel(); + CaptureMouse(); + mbMouseCaptured = true; + } + else + { + // Single click without moving much trying to do a selection + TrySelection(rMEvt.GetPosPixel()); + bCallParent = false; + } + } + + // call parent + return !bCallParent; +} + +bool LightControl3D::MouseMove(const MouseEvent& rMEvt) +{ + if (!mbMouseCaptured) + return false; + + Point aDeltaPos = rMEvt.GetPosPixel() - maActionStartPoint; + + if(!mbMouseMoved) + { + if(sal_Int32(aDeltaPos.X() * aDeltaPos.X() + aDeltaPos.Y() * aDeltaPos.Y()) > g_nInteractionStartDistance) + { + if(mbGeometrySelected) + { + GetRotation(mfSaveActionStartVer, mfSaveActionStartHor, mfSaveActionStartRotZ); + } + else + { + // interaction start, save values + GetPosition(mfSaveActionStartHor, mfSaveActionStartVer); + } + + mbMouseMoved = true; + } + } + + if(mbMouseMoved) + { + if(mbGeometrySelected) + { + double fNewRotX = mfSaveActionStartVer - basegfx::deg2rad(aDeltaPos.Y()); + double fNewRotY = mfSaveActionStartHor + basegfx::deg2rad(aDeltaPos.X()); + + // cut horizontal + while(fNewRotY < 0.0) + { + fNewRotY += F_2PI; + } + + while(fNewRotY >= F_2PI) + { + fNewRotY -= F_2PI; + } + + // cut vertical + if(fNewRotX < -F_PI2) + { + fNewRotX = -F_PI2; + } + + if(fNewRotX > F_PI2) + { + fNewRotX = F_PI2; + } + + SetRotation(fNewRotX, fNewRotY, mfSaveActionStartRotZ); + + if(maChangeCallback.IsSet()) + { + maChangeCallback.Call(this); + } + } + else + { + // interaction in progress + double fNewPosHor = mfSaveActionStartHor + static_cast<double>(aDeltaPos.X()); + double fNewPosVer = mfSaveActionStartVer - static_cast<double>(aDeltaPos.Y()); + + // cut horizontal + fNewPosHor = NormAngle360(fNewPosHor); + + // cut vertical + if(fNewPosVer < -90.0) + { + fNewPosVer = -90.0; + } + + if(fNewPosVer > 90.0) + { + fNewPosVer = 90.0; + } + + SetPosition(fNewPosHor, fNewPosVer); + + if(maChangeCallback.IsSet()) + { + maChangeCallback.Call(this); + } + } + } + return true; +} + +bool LightControl3D::MouseButtonUp(const MouseEvent& rMEvt) +{ + if (!mbMouseCaptured) + return false; + ReleaseMouse(); + mbMouseCaptured = false; + + if (mbMouseMoved) + { + // was change interactively + } + else + { + // simple click without much movement, try selection + TrySelection(rMEvt.GetPosPixel()); + } + + return true; +} + +void LightControl3D::Resize() +{ + // set size of page + const Size aSize(GetDrawingArea()->get_ref_device().PixelToLogic(GetOutputSizePixel())); + mpFmPage->SetSize(aSize); + + // set position and size of scene + mpScene->SetSnapRect(tools::Rectangle(Point(0, 0), aSize)); +} + +void LightControl3D::SetObjectType(SvxPreviewObjectType nType) +{ + // call parent + PreviewControl3D::SetObjectType(nType); + + // apply object rotation + if(mp3DObj) + { + basegfx::B3DHomMatrix aObjectRotation; + aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ); + mp3DObj->SetTransform(aObjectRotation); + } +} + +bool LightControl3D::IsSelectionValid() +{ + return (NO_LIGHT_SELECTED != maSelectedLight) && GetLightOnOff(maSelectedLight); +} + +void LightControl3D::GetPosition(double& rHor, double& rVer) +{ + if(IsSelectionValid()) + { + basegfx::B3DVector aDirection(GetLightDirection(maSelectedLight)); + aDirection.normalize(); + rHor = basegfx::rad2deg(atan2(-aDirection.getX(), -aDirection.getZ()) + F_PI); // 0..360.0 + rVer = basegfx::rad2deg(atan2(aDirection.getY(), aDirection.getXZLength())); // -90.0..90.0 + } + if(IsGeometrySelected()) + { + rHor = basegfx::rad2deg(mfRotateY); // 0..360.0 + rVer = basegfx::rad2deg(mfRotateX); // -90.0..90.0 + } +} + +void LightControl3D::SetPosition(double fHor, double fVer) +{ + if(IsSelectionValid()) + { + // set selected light's direction + fHor = basegfx::deg2rad(fHor) - F_PI; // -PI..PI + fVer = basegfx::deg2rad(fVer); // -PI2..PI2 + basegfx::B3DVector aDirection(cos(fVer) * -sin(fHor), sin(fVer), cos(fVer) * -cos(fHor)); + aDirection.normalize(); + + if(!aDirection.equal(GetLightDirection(maSelectedLight))) + { + // set changed light direction at SdrScene + SfxItemSet aSet(mpModel->GetItemPool()); + + switch(maSelectedLight) + { + case 0: aSet.Put(makeSvx3DLightDirection1Item(aDirection)); break; + case 1: aSet.Put(makeSvx3DLightDirection2Item(aDirection)); break; + case 2: aSet.Put(makeSvx3DLightDirection3Item(aDirection)); break; + case 3: aSet.Put(makeSvx3DLightDirection4Item(aDirection)); break; + case 4: aSet.Put(makeSvx3DLightDirection5Item(aDirection)); break; + case 5: aSet.Put(makeSvx3DLightDirection6Item(aDirection)); break; + case 6: aSet.Put(makeSvx3DLightDirection7Item(aDirection)); break; + default: + case 7: aSet.Put(makeSvx3DLightDirection8Item(aDirection)); break; + } + + mpScene->SetMergedItemSet(aSet); + + // correct 3D light's and LampFrame's geometries + AdaptToSelectedLight(); + Invalidate(); + } + } + if(IsGeometrySelected()) + { + if(mfRotateX != fVer || mfRotateY != fHor) + { + mfRotateX = basegfx::deg2rad(fVer); + mfRotateY = basegfx::deg2rad(fHor); + + if(mp3DObj) + { + basegfx::B3DHomMatrix aObjectRotation; + aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ); + mp3DObj->SetTransform(aObjectRotation); + + Invalidate(); + } + } + } +} + +void LightControl3D::SetRotation(double fRotX, double fRotY, double fRotZ) +{ + if(IsGeometrySelected()) + { + if(fRotX != mfRotateX || fRotY != mfRotateY || fRotZ != mfRotateZ) + { + mfRotateX = fRotX; + mfRotateY = fRotY; + mfRotateZ = fRotZ; + + if(mp3DObj) + { + basegfx::B3DHomMatrix aObjectRotation; + aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ); + mp3DObj->SetTransform(aObjectRotation); + + Invalidate(); + } + } + } +} + +void LightControl3D::GetRotation(double& rRotX, double& rRotY, double& rRotZ) +{ + rRotX = mfRotateX; + rRotY = mfRotateY; + rRotZ = mfRotateZ; +} + +void LightControl3D::Set3DAttributes( const SfxItemSet& rAttr ) +{ + // call parent + PreviewControl3D::Set3DAttributes(rAttr); + + if(maSelectedLight != NO_LIGHT_SELECTED && !GetLightOnOff(maSelectedLight)) + { + // selected light is no more active, select new one + maSelectedLight = NO_LIGHT_SELECTED; + } + + // local updates + ConstructLightObjects(); + AdaptToSelectedLight(); + Invalidate(); +} + +void LightControl3D::SelectLight(sal_uInt32 nLightNumber) +{ + if(nLightNumber > 7) + { + nLightNumber = NO_LIGHT_SELECTED; + } + + if(NO_LIGHT_SELECTED != nLightNumber) + { + if(!GetLightOnOff(nLightNumber)) + { + nLightNumber = NO_LIGHT_SELECTED; + } + } + + if(nLightNumber != maSelectedLight) + { + maSelectedLight = nLightNumber; + mbGeometrySelected = false; + ConstructLightObjects(); + AdaptToSelectedLight(); + Invalidate(); + } +} + +bool LightControl3D::GetLightOnOff(sal_uInt32 nNum) const +{ + if(nNum <= 7) + { + const SfxItemSet aLightItemSet(Get3DAttributes()); + + switch(nNum) + { + case 0 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_1).GetValue(); + case 1 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_2).GetValue(); + case 2 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_3).GetValue(); + case 3 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_4).GetValue(); + case 4 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_5).GetValue(); + case 5 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_6).GetValue(); + case 6 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_7).GetValue(); + case 7 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_8).GetValue(); + } + } + + return false; +} + +Color LightControl3D::GetLightColor(sal_uInt32 nNum) const +{ + if(nNum <= 7) + { + const SfxItemSet aLightItemSet(Get3DAttributes()); + + switch(nNum) + { + case 0 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1).GetValue(); + case 1 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2).GetValue(); + case 2 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3).GetValue(); + case 3 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4).GetValue(); + case 4 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5).GetValue(); + case 5 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6).GetValue(); + case 6 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7).GetValue(); + case 7 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8).GetValue(); + } + } + + return COL_BLACK; +} + +basegfx::B3DVector LightControl3D::GetLightDirection(sal_uInt32 nNum) const +{ + if(nNum <= 7) + { + const SfxItemSet aLightItemSet(Get3DAttributes()); + + switch(nNum) + { + case 0 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1).GetValue(); + case 1 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2).GetValue(); + case 2 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3).GetValue(); + case 3 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4).GetValue(); + case 4 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5).GetValue(); + case 5 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6).GetValue(); + case 6 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7).GetValue(); + case 7 : return aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8).GetValue(); + } + } + + return basegfx::B3DVector(); +} + SvxLightCtl3D::SvxLightCtl3D( vcl::Window* pParent) : Control(pParent, WB_BORDER | WB_TABSTOP), maLightControl(VclPtr<Svx3DLightControl>::Create(this, 0)), @@ -1263,4 +2124,266 @@ IMPL_LINK_NOARG(SvxLightCtl3D, InternalSelectionChange, Svx3DLightControl*, void } } +LightCtl3D::LightCtl3D(LightControl3D& rLightControl, weld::Scale& rHori, + weld::Scale& rVert, weld::Button& rSwitcher) + : mrLightControl(rLightControl) + , mrHorScroller(rHori) + , mrVerScroller(rVert) + , mrSwitcher(rSwitcher) +{ + // init members + Init(); +} + +void LightCtl3D::Init() +{ + Size aSize(mrLightControl.GetDrawingArea()->get_ref_device().LogicToPixel(Size(80, 100), MapMode(MapUnit::MapAppFont))); + mrLightControl.set_size_request(aSize.Width(), aSize.Height()); + + // #i58240# set HelpIDs for scrollbars and switcher + mrHorScroller.set_help_id(HID_CTRL3D_HSCROLL); + mrVerScroller.set_help_id(HID_CTRL3D_VSCROLL); + mrSwitcher.set_help_id(HID_CTRL3D_SWITCHER); + mrSwitcher.set_accessible_name(SvxResId(STR_SWITCH)); + + // Light preview + mrLightControl.Show(); + mrLightControl.SetChangeCallback( LINK(this, LightCtl3D, InternalInteractiveChange) ); + mrLightControl.SetSelectionChangeCallback( LINK(this, LightCtl3D, InternalSelectionChange) ); + + // Horiz Scrollbar + mrHorScroller.show(); + mrHorScroller.set_range(0, 36000); + mrHorScroller.connect_value_changed( LINK(this, LightCtl3D, ScrollBarMove) ); + + // Vert Scrollbar + mrVerScroller.show(); + mrVerScroller.set_range(0, 18000); + mrVerScroller.connect_value_changed( LINK(this, LightCtl3D, ScrollBarMove) ); + + // Switch Button + mrSwitcher.show(); + mrSwitcher.connect_clicked( LINK(this, LightCtl3D, ButtonPress) ); + + weld::DrawingArea* pArea = mrLightControl.GetDrawingArea(); + pArea->connect_key_press(Link<const KeyEvent&, bool>()); //acknowledge we first remove the old one + pArea->connect_key_press(LINK(this, LightCtl3D, KeyInput)); + + pArea->connect_focus_in(Link<weld::Widget&, void>()); //acknowledge we first remove the old one + pArea->connect_focus_in(LINK(this, LightCtl3D, FocusIn)); + + // check selection + CheckSelection(); +} + +LightCtl3D::~LightCtl3D() +{ +} + +void LightCtl3D::CheckSelection() +{ + const bool bSelectionValid(mrLightControl.IsSelectionValid() || mrLightControl.IsGeometrySelected()); + mrHorScroller.set_sensitive(bSelectionValid); + mrVerScroller.set_sensitive(bSelectionValid); + + if (bSelectionValid) + { + double fHor(0.0), fVer(0.0); + mrLightControl.GetPosition(fHor, fVer); + mrHorScroller.set_value( sal_Int32(fHor * 100.0) ); + mrVerScroller.set_value( 18000 - sal_Int32((fVer + 90.0) * 100.0) ); + } +} + +void LightCtl3D::move( double fDeltaHor, double fDeltaVer ) +{ + double fHor(0.0), fVer(0.0); + + mrLightControl.GetPosition(fHor, fVer); + fHor += fDeltaHor; + fVer += fDeltaVer; + + if( fVer > 90.0 ) + return; + + if ( fVer < -90.0 ) + return; + + mrLightControl.SetPosition(fHor, fVer); + mrHorScroller.set_value( sal_Int32(fHor * 100.0) ); + mrVerScroller.set_value( 18000 - sal_Int32((fVer + 90.0) * 100.0) ); + + if(maUserInteractiveChangeCallback.IsSet()) + { + maUserInteractiveChangeCallback.Call(this); + } +} + +IMPL_LINK(LightCtl3D, KeyInput, const KeyEvent&, rKEvt, bool) +{ + const vcl::KeyCode aCode(rKEvt.GetKeyCode()); + + if (aCode.GetModifier()) + return false; + + bool bHandled = true; + + switch ( aCode.GetCode() ) + { + case KEY_SPACE: + { + break; + } + case KEY_LEFT: + { + move( -4.0, 0.0 ); // #i58242# changed move direction in X + break; + } + case KEY_RIGHT: + { + move( 4.0, 0.0 ); // #i58242# changed move direction in X + break; + } + case KEY_UP: + { + move( 0.0, 4.0 ); + break; + } + case KEY_DOWN: + { + move( 0.0, -4.0 ); + break; + } + case KEY_PAGEUP: + { + sal_Int32 nLight(mrLightControl.GetSelectedLight() - 1); + + while((nLight >= 0) && !mrLightControl.GetLightOnOff(nLight)) + { + nLight--; + } + + if(nLight < 0) + { + nLight = 7; + + while((nLight >= 0) && !mrLightControl.GetLightOnOff(nLight)) + { + nLight--; + } + } + + if(nLight >= 0) + { + mrLightControl.SelectLight(nLight); + CheckSelection(); + + if(maUserSelectionChangeCallback.IsSet()) + { + maUserSelectionChangeCallback.Call(this); + } + } + + break; + } + case KEY_PAGEDOWN: + { + sal_Int32 nLight(mrLightControl.GetSelectedLight() - 1); + + while(nLight <= 7 && !mrLightControl.GetLightOnOff(nLight)) + { + nLight++; + } + + if(nLight > 7) + { + nLight = 0; + + while(nLight <= 7 && !mrLightControl.GetLightOnOff(nLight)) + { + nLight++; + } + } + + if(nLight <= 7) + { + mrLightControl.SelectLight(nLight); + CheckSelection(); + + if(maUserSelectionChangeCallback.IsSet()) + { + maUserSelectionChangeCallback.Call(this); + } + } + + break; + } + default: + { + bHandled = false; + break; + } + } + return bHandled; +} + +IMPL_LINK_NOARG(LightCtl3D, FocusIn, weld::Widget&, void) +{ + if (mrLightControl.IsEnabled()) + { + CheckSelection(); + } +} + +IMPL_LINK_NOARG(LightCtl3D, ScrollBarMove, weld::Scale&, void) +{ + const sal_Int32 nHor(mrHorScroller.get_value()); + const sal_Int32 nVer(mrVerScroller.get_value()); + + mrLightControl.SetPosition( + static_cast<double>(nHor) / 100.0, + static_cast<double>((18000 - nVer) - 9000) / 100.0); + + if (maUserInteractiveChangeCallback.IsSet()) + { + maUserInteractiveChangeCallback.Call(this); + } +} + +IMPL_LINK_NOARG(LightCtl3D, ButtonPress, weld::Button&, void) +{ + if(SvxPreviewObjectType::SPHERE == GetSvx3DLightControl().GetObjectType()) + { + GetSvx3DLightControl().SetObjectType(SvxPreviewObjectType::CUBE); + } + else + { + GetSvx3DLightControl().SetObjectType(SvxPreviewObjectType::SPHERE); + } +} + +IMPL_LINK_NOARG(LightCtl3D, InternalInteractiveChange, LightControl3D*, void) +{ + double fHor(0.0), fVer(0.0); + + mrLightControl.GetPosition(fHor, fVer); + mrHorScroller.set_value( sal_Int32(fHor * 100.0) ); + mrVerScroller.set_value( 18000 - sal_Int32((fVer + 90.0) * 100.0) ); + + if(maUserInteractiveChangeCallback.IsSet()) + { + maUserInteractiveChangeCallback.Call(this); + } +} + +IMPL_LINK_NOARG(LightCtl3D, InternalSelectionChange, LightControl3D*, void) +{ + CheckSelection(); + + if(maUserSelectionChangeCallback.IsSet()) + { + maUserSelectionChangeCallback.Call(this); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index eb8faa271962..d9d9bf0d8248 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -4083,6 +4083,19 @@ void ColorListBox::createColorWindow() m_xColorWindow->SelectEntry(m_aSelectedColor); } +void ColorListBox::SelectEntry(const NamedColor& rColor) +{ + if (rColor.second.trim().isEmpty()) + { + SelectEntry(rColor.first); + return; + } + ColorWindow* pColorWindow = getColorWindow(); + pColorWindow->SelectEntry(rColor); + m_aSelectedColor = pColorWindow->GetSelectEntryColor(); + ShowPreview(m_aSelectedColor); +} + void ColorListBox::SelectEntry(const Color& rColor) { ColorWindow* pColorWindow = getColorWindow(); |