summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-27 13:22:01 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-27 20:27:18 +0100
commit4c1a8f233f1a496a8401fd255d954745baef33c0 (patch)
treed6e4ab8ff16c5e5c6d07f2228f39fd9050a6bdec /svx
parent41e024578469d9c452300447610a3e9c6e50e211 (diff)
weld ExtrusionLightingWindow
Change-Id: I3078ca8315f84f03431a07630987687144857818 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87527 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/UIConfig_svx.mk1
-rw-r--r--svx/inc/bitmaps.hlst3
-rw-r--r--svx/source/tbxctrls/extrusioncontrols.cxx161
-rw-r--r--svx/source/tbxctrls/extrusioncontrols.hxx25
-rw-r--r--svx/uiconfig/ui/lightingwindow.ui121
5 files changed, 208 insertions, 103 deletions
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index afad7bb8f9ba..a7f943c2548c 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -69,6 +69,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
svx/uiconfig/ui/imapmenu \
svx/uiconfig/ui/interimdockparent \
svx/uiconfig/ui/interimparent \
+ svx/uiconfig/ui/lightingwindow \
svx/uiconfig/ui/linkwarndialog \
svx/uiconfig/ui/measurewidthbar \
svx/uiconfig/ui/mediaplayback \
diff --git a/svx/inc/bitmaps.hlst b/svx/inc/bitmaps.hlst
index 94bd0d116b17..648d86d356ff 100644
--- a/svx/inc/bitmaps.hlst
+++ b/svx/inc/bitmaps.hlst
@@ -74,9 +74,6 @@
#define RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_LEFT "svx/res/lightfrombottomleft_22.png"
#define RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM "svx/res/lightfrombottom_22.png"
#define RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_RIGHT "svx/res/lightfrombottomright_22.png"
-#define RID_SVXBMP_LIGHTING_BRIGHT "svx/res/brightlit_16.png"
-#define RID_SVXBMP_LIGHTING_NORMAL "svx/res/normallit_16.png"
-#define RID_SVXBMP_LIGHTING_DIM "svx/res/dimlit_16.png"
#define RID_SVXBMP_WIRE_FRAME "svx/res/wireframe_16.png"
#define RID_SVXBMP_MATTE "svx/res/matte_16.png"
#define RID_SVXBMP_PLASTIC "svx/res/plastic_16.png"
diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx
index 3bdfba02bd63..76fcb3a5e048 100644
--- a/svx/source/tbxctrls/extrusioncontrols.cxx
+++ b/svx/source/tbxctrls/extrusioncontrols.cxx
@@ -557,16 +557,20 @@ com_sun_star_comp_svx_ExtrusionDepthController_get_implementation(
static const char g_sExtrusionLightingDirection[] = ".uno:ExtrusionLightingDirection";
static const char g_sExtrusionLightingIntensity[] = ".uno:ExtrusionLightingIntensity";
-ExtrusionLightingWindow::ExtrusionLightingWindow(svt::ToolboxController& rController,
- vcl::Window* pParentWindow)
- : ToolbarMenu(rController.getFrameInterface(), pParentWindow, WB_STDPOPUP)
- , mrController(rController)
- , maImgBright(StockImage::Yes, RID_SVXBMP_LIGHTING_BRIGHT)
- , maImgNormal(StockImage::Yes, RID_SVXBMP_LIGHTING_NORMAL)
- , maImgDim(StockImage::Yes, RID_SVXBMP_LIGHTING_DIM)
+ExtrusionLightingWindow::ExtrusionLightingWindow(svt::PopupWindowController* pControl,
+ weld::Widget* pParent)
+ : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/lightingwindow.ui", "LightingWindow")
+ , mxControl(pControl)
+ , mxLightingSet(new SvtValueSet(nullptr))
+ , mxLightingSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxLightingSet))
+ , mxBright(m_xBuilder->weld_radio_button("bright"))
+ , mxNormal(m_xBuilder->weld_radio_button("normal"))
+ , mxDim(m_xBuilder->weld_radio_button("dim"))
, mnDirection(FROM_FRONT)
, mbDirectionEnabled(false)
{
+ mxLightingSet->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT);
+
for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
{
if( i != FROM_FRONT )
@@ -577,58 +581,52 @@ ExtrusionLightingWindow::ExtrusionLightingWindow(svt::ToolboxController& rContro
maImgLightingPreview[i] = Image(StockImage::Yes, aLightPreviewBmps[i]);
}
- SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectToolbarMenuHdl ) );
+ mxLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING );
- mpLightingSet = createEmptyValueSetControl();
- mpLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING );
-
- mpLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) );
- mpLightingSet->SetColCount( 3 );
- mpLightingSet->EnableFullItemMode( false );
+ mxLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) );
+ mxLightingSet->SetColCount( 3 );
+ mxLightingSet->EnableFullItemMode( false );
for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
{
if( i != FROM_FRONT )
{
- mpLightingSet->InsertItem( i+1, maImgLightingOff[i] );
+ mxLightingSet->InsertItem( i+1, maImgLightingOff[i] );
}
else
{
- mpLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] );
+ mxLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] );
}
}
- mpLightingSet->SetOutputSizePixel( Size( 72, 72 ) );
+ Size aSize(72, 72);
+ mxLightingSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
+ mxLightingSet->SetOutputSizePixel(aSize);
- appendEntry(3, mpLightingSet);
- appendSeparator();
- appendEntry(0, SvxResId(RID_SVXSTR_BRIGHT), maImgBright);
- appendEntry(1, SvxResId(RID_SVXSTR_NORMAL), maImgNormal);
- appendEntry(2, SvxResId(RID_SVXSTR_DIM), maImgDim);
-
- SetOutputSizePixel( getMenuSize() );
+ mxBright->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
+ mxNormal->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
+ mxDim->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
AddStatusListener( g_sExtrusionLightingDirection );
AddStatusListener( g_sExtrusionLightingIntensity );
}
-ExtrusionLightingWindow::~ExtrusionLightingWindow()
+void ExtrusionLightingWindow::GrabFocus()
{
- disposeOnce();
+ mxLightingSet->GrabFocus();
}
-void ExtrusionLightingWindow::dispose()
+ExtrusionLightingWindow::~ExtrusionLightingWindow()
{
- mpLightingSet.clear();
- ToolbarMenu::dispose();
}
void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
{
- for (int i = 0; i < 3; ++i)
- {
- checkEntry( i, (i == nLevel) && bEnabled );
- enableEntry( i, bEnabled );
- }
+ mxBright->set_sensitive(bEnabled);
+ mxBright->set_active(nLevel == 0 && bEnabled);
+ mxNormal->set_sensitive(bEnabled);
+ mxNormal->set_active(nLevel == 1 && bEnabled);
+ mxDim->set_sensitive(bEnabled);
+ mxDim->set_active(nLevel == 2 && bEnabled);
}
void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
@@ -644,21 +642,23 @@ void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
{
if( nItemId == FROM_FRONT )
{
- mpLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
+ mxLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
}
else
{
- mpLightingSet->SetItemImage(
+ mxLightingSet->SetItemImage(
nItemId + 1,
static_cast<sal_uInt16>(nDirection) == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId]
);
}
}
- enableEntry( 3, bEnabled );
+ if (bEnabled)
+ mxLightingSet->Enable();
+ else
+ mxLightingSet->Disable();
}
-
void ExtrusionLightingWindow::statusChanged(
const css::frame::FeatureStateEvent& Event
)
@@ -691,69 +691,47 @@ void ExtrusionLightingWindow::statusChanged(
}
}
-
-void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt )
+IMPL_LINK_NOARG(ExtrusionLightingWindow, SelectValueSetHdl, SvtValueSet*, void)
{
- ToolbarMenu::DataChanged( rDCEvt );
+ sal_Int32 nDirection = mxLightingSet->GetSelectedItemId();
- if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
+ if( (nDirection > 0) && (nDirection < 10) )
{
- implSetDirection( mnDirection, mbDirectionEnabled );
- setEntryImage( 0, maImgBright );
- setEntryImage( 1, maImgNormal );
- setEntryImage( 2, maImgDim );
- }
-}
+ nDirection--;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = OUString(g_sExtrusionLightingDirection).copy(5);
+ aArgs[0].Value <<= nDirection;
-IMPL_LINK( ExtrusionLightingWindow, SelectValueSetHdl, ValueSet*, pControl, void )
-{
- SelectHdl(pControl);
-}
-IMPL_LINK( ExtrusionLightingWindow, SelectToolbarMenuHdl, ToolbarMenu*, pControl, void )
-{
- SelectHdl(pControl);
-}
-void ExtrusionLightingWindow::SelectHdl(void const * pControl)
-{
- if ( IsInPopupMode() )
- EndPopupMode();
+ mxControl->dispatchCommand( g_sExtrusionLightingDirection, aArgs );
- if( pControl == this )
- {
- int nLevel = getSelectedEntryId();
- if( nLevel >= 0 && nLevel != 3 )
- {
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[0].Name = OUString(g_sExtrusionLightingIntensity).copy(5);
- aArgs[0].Value <<= static_cast<sal_Int32>(nLevel);
+ implSetDirection( nDirection, true );
+ }
- mrController.dispatchCommand( g_sExtrusionLightingIntensity, aArgs );
+ mxControl->EndPopupMode();
+}
- implSetIntensity( nLevel, true );
- }
- }
+IMPL_LINK_NOARG(ExtrusionLightingWindow, SelectToolbarMenuHdl, weld::Button&, void)
+{
+ int nLevel;
+ if (mxBright->get_active())
+ nLevel = 0;
+ else if (mxNormal->get_active())
+ nLevel = 1;
else
- {
- sal_Int32 nDirection = mpLightingSet->GetSelectedItemId();
-
- if( (nDirection > 0) && (nDirection < 10) )
- {
- nDirection--;
+ nLevel = 2;
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[0].Name = OUString(g_sExtrusionLightingDirection).copy(5);
- aArgs[0].Value <<= nDirection;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = OUString(g_sExtrusionLightingIntensity).copy(5);
+ aArgs[0].Value <<= static_cast<sal_Int32>(nLevel);
- mrController.dispatchCommand( g_sExtrusionLightingDirection, aArgs );
+ mxControl->dispatchCommand( g_sExtrusionLightingIntensity, aArgs );
- implSetDirection( nDirection, true );
- }
+ implSetIntensity( nLevel, true );
- }
+ mxControl->EndPopupMode();
}
-
ExtrusionLightingControl::ExtrusionLightingControl(
const Reference< XComponentContext >& rxContext
) : svt::PopupWindowController( rxContext,
@@ -763,10 +741,19 @@ ExtrusionLightingControl::ExtrusionLightingControl(
{
}
+std::unique_ptr<WeldToolbarPopup> ExtrusionLightingControl::weldPopupWindow()
+{
+ return std::make_unique<ExtrusionLightingWindow>(this, m_pToolbar);
+}
VclPtr<vcl::Window> ExtrusionLightingControl::createVclPopupWindow( vcl::Window* pParent )
{
- return VclPtr<ExtrusionLightingWindow>::Create( *this, pParent );
+ mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
+ std::make_unique<ExtrusionLightingWindow>(this, pParent->GetFrameWeld()));
+
+ mxInterimPopover->Show();
+
+ return mxInterimPopover;
}
// XInitialization
diff --git a/svx/source/tbxctrls/extrusioncontrols.hxx b/svx/source/tbxctrls/extrusioncontrols.hxx
index 4dceea5e9848..af46a1ee395e 100644
--- a/svx/source/tbxctrls/extrusioncontrols.hxx
+++ b/svx/source/tbxctrls/extrusioncontrols.hxx
@@ -123,44 +123,43 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
};
-class ExtrusionLightingWindow : public svtools::ToolbarMenu
+class ExtrusionLightingWindow final : public WeldToolbarPopup
{
private:
- svt::ToolboxController& mrController;
- VclPtr<ValueSet> mpLightingSet;
+ rtl::Reference<svt::PopupWindowController> mxControl;
+ std::unique_ptr<SvtValueSet> mxLightingSet;
+ std::unique_ptr<weld::CustomWeld> mxLightingSetWin;
+ std::unique_ptr<weld::RadioButton> mxBright;
+ std::unique_ptr<weld::RadioButton> mxNormal;
+ std::unique_ptr<weld::RadioButton> mxDim;
Image maImgLightingOff[9];
Image maImgLightingOn[9];
Image maImgLightingPreview[9];
- Image const maImgBright;
- Image const maImgNormal;
- Image const maImgDim;
-
int mnDirection;
bool mbDirectionEnabled;
void implSetIntensity( int nLevel, bool bEnabled );
void implSetDirection( int nDirection, bool bEnabled );
- DECL_LINK( SelectToolbarMenuHdl, ToolbarMenu*, void );
- DECL_LINK( SelectValueSetHdl, ValueSet*, void );
+ DECL_LINK( SelectToolbarMenuHdl, weld::Button&, void );
+ DECL_LINK( SelectValueSetHdl, SvtValueSet*, void );
void SelectHdl(void const *);
public:
- ExtrusionLightingWindow( svt::ToolboxController& rController, vcl::Window* pParentWindow );
+ ExtrusionLightingWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow);
+ virtual void GrabFocus() override;
virtual ~ExtrusionLightingWindow() override;
- virtual void dispose() override;
virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
- virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
};
-
class ExtrusionLightingControl : public svt::PopupWindowController
{
public:
explicit ExtrusionLightingControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+ virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
// XInitialization
diff --git a/svx/uiconfig/ui/lightingwindow.ui b/svx/uiconfig/ui/lightingwindow.ui
new file mode 100644
index 000000000000..82c188653375
--- /dev/null
+++ b/svx/uiconfig/ui/lightingwindow.ui
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="svx">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">svx/res/brightlit_16.png</property>
+ </object>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">svx/res/normallit_16.png</property>
+ </object>
+ <object class="GtkPopover" id="LightingWindow">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="border_width">4</property>
+ <child>
+ <object class="GtkBox" id="container">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="valuesetwin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkDrawingArea" id="valueset">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="bright">
+ <property name="label" translatable="yes" context="lightingwindow|RID_SVXSTR_BRIGHT">_Bright</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="image">image1</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="always_show_image">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="normal">
+ <property name="label" translatable="yes" context="lightingwindow|RID_SVXSTR_NORMAL">_Normal</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="image">image2</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="always_show_image">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">bright</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="dim">
+ <property name="label" translatable="yes" context="lightingwindow|RID_SVXSTR_DIM">_Dim</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="image">image3</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="always_show_image">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">bright</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">svx/res/dimlit_16.png</property>
+ </object>
+</interface>