svx: Port ExtrusionDirectionWindow from ValueSet to weld::IconView
Port the widget to select the extrusion direction from using a ValueSet widget to using weld::IconView. This helps to be more consistent with other platform/toolkit widgets and reduces custom widget logic. Adjust indices used to account for the fact that weld::IconView indices are 0-based while the ValueSet ones are 1-based. The popup can be triggered like this: * open attachment 175894 from tdf#145296 * make sure the "3D-Settings" toolbar is enabled in "View" -> "Toolbars" -> "3D-Settings" * select the extruded shape * press the "Direction" button in the "3D-Settings" toolbar Change-Id: I045bd1d605b0f5bb5c4ad7eeb3247e50356b39b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211907 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
This commit is contained in:
@@ -120,37 +120,29 @@ ExtrusionDirectionWindow::ExtrusionDirectionWindow(
|
||||
weld::Widget* pParent)
|
||||
: WeldToolbarPopup(pControl->getFrameInterface(), pParent, u"svx/ui/directionwindow.ui"_ustr, u"DirectionWindow"_ustr)
|
||||
, mxControl(pControl)
|
||||
, mxDirectionSet(new ValueSet(nullptr))
|
||||
, mxDirectionSetWin(new weld::CustomWeld(*m_xBuilder, u"valueset"_ustr, *mxDirectionSet))
|
||||
, mxDirectionIconView(m_xBuilder->weld_icon_view(u"iconview"_ustr))
|
||||
, mxPerspective(m_xBuilder->weld_radio_button(u"perspective"_ustr))
|
||||
, mxParallel(m_xBuilder->weld_radio_button(u"parallel"_ustr))
|
||||
{
|
||||
mxDirectionSet->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT);
|
||||
|
||||
mxDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectValueSetHdl ) );
|
||||
mxDirectionSet->SetColCount( 3 );
|
||||
mxDirectionSet->EnableFullItemMode( false );
|
||||
mxDirectionIconView->connect_item_activated(
|
||||
LINK(this, ExtrusionDirectionWindow, IconViewItemActivatedHdl));
|
||||
|
||||
for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i)
|
||||
{
|
||||
const Image aImgDirection(StockImage::Yes, aDirectionBmps[i]);
|
||||
mxDirectionSet->InsertItem(i + 1, aImgDirection, SvxResId(aDirectionStrs[i]));
|
||||
const Bitmap aImgDirection = Image(StockImage::Yes, aDirectionBmps[i]).GetBitmap();
|
||||
mxDirectionIconView->insert(i, nullptr, nullptr, &aImgDirection, nullptr);
|
||||
const OUString sName = SvxResId(aDirectionStrs[i]);
|
||||
mxDirectionIconView->set_item_accessible_name(i, sName);
|
||||
mxDirectionIconView->set_item_tooltip_text(i, sName);
|
||||
}
|
||||
|
||||
Size aSize(72, 72);
|
||||
mxDirectionSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
|
||||
mxDirectionSet->SetOutputSizePixel(aSize);
|
||||
|
||||
mxPerspective->connect_toggled(LINK(this, ExtrusionDirectionWindow, SelectToolbarMenuHdl));
|
||||
|
||||
AddStatusListener( g_sExtrusionDirection );
|
||||
AddStatusListener( g_sExtrusionProjection );
|
||||
}
|
||||
|
||||
void ExtrusionDirectionWindow::GrabFocus()
|
||||
{
|
||||
mxDirectionSet->GrabFocus();
|
||||
}
|
||||
void ExtrusionDirectionWindow::GrabFocus() { mxDirectionIconView->grab_focus(); }
|
||||
|
||||
ExtrusionDirectionWindow::~ExtrusionDirectionWindow()
|
||||
{
|
||||
@@ -167,17 +159,14 @@ void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled
|
||||
|
||||
if( nItemId <= DIRECTION_SE )
|
||||
{
|
||||
mxDirectionSet->SelectItem( nItemId+1 );
|
||||
mxDirectionIconView->select(nItemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
mxDirectionSet->SetNoSelection();
|
||||
mxDirectionIconView->unselect_all();
|
||||
}
|
||||
|
||||
if (bEnabled)
|
||||
mxDirectionSet->Enable();
|
||||
else
|
||||
mxDirectionSet->Disable();
|
||||
mxDirectionIconView->set_sensitive(bEnabled);
|
||||
}
|
||||
|
||||
void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
|
||||
@@ -220,15 +209,17 @@ void ExtrusionDirectionWindow::statusChanged(
|
||||
}
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(ExtrusionDirectionWindow, SelectValueSetHdl, ValueSet*, void)
|
||||
IMPL_LINK(ExtrusionDirectionWindow, IconViewItemActivatedHdl, const weld::TreeIter&, rIter, bool)
|
||||
{
|
||||
Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
|
||||
g_sExtrusionDirection.copy(5),
|
||||
gSkewList[mxDirectionSet->GetSelectedItemId()-1]) };
|
||||
gSkewList[mxDirectionIconView->get_iter_index_in_parent(rIter)]) };
|
||||
|
||||
mxControl->dispatchCommand( g_sExtrusionDirection, aArgs );
|
||||
|
||||
mxControl->EndPopupMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(ExtrusionDirectionWindow, SelectToolbarMenuHdl, weld::Toggleable&, void)
|
||||
|
||||
@@ -21,11 +21,10 @@
|
||||
|
||||
#include <svtools/toolbarmenu.hxx>
|
||||
#include <svtools/popupwindowcontroller.hxx>
|
||||
#include <svtools/valueset.hxx>
|
||||
#include <tools/fldunit.hxx>
|
||||
#include <vcl/image.hxx>
|
||||
#include <vcl/weld/IconView.hxx>
|
||||
#include <vcl/weld/RadioButton.hxx>
|
||||
#include <vcl/weld/customweld.hxx>
|
||||
|
||||
// enum to index light images
|
||||
#define FROM_TOP_LEFT 0
|
||||
@@ -61,13 +60,12 @@ public:
|
||||
|
||||
private:
|
||||
rtl::Reference<svt::PopupWindowController> mxControl;
|
||||
std::unique_ptr<ValueSet> mxDirectionSet;
|
||||
std::unique_ptr<weld::CustomWeld> mxDirectionSetWin;
|
||||
std::unique_ptr<weld::IconView> mxDirectionIconView;
|
||||
std::unique_ptr<weld::RadioButton> mxPerspective;
|
||||
std::unique_ptr<weld::RadioButton> mxParallel;
|
||||
|
||||
DECL_LINK( SelectToolbarMenuHdl, weld::Toggleable&, void );
|
||||
DECL_LINK( SelectValueSetHdl, ValueSet*, void );
|
||||
DECL_LINK(IconViewItemActivatedHdl, const weld::TreeIter&, bool);
|
||||
|
||||
void implSetDirection( sal_Int32 nSkew, bool bEnabled );
|
||||
void implSetProjection( sal_Int32 nProjection, bool bEnabled );
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface domain="svx">
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkTreeStore" id="iconview_model">
|
||||
<columns>
|
||||
<!-- column-name pixbuf -->
|
||||
<column type="GdkPixbuf"/>
|
||||
<!-- column-name id -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name tooltip -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
@@ -24,29 +34,18 @@
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="valuesetwin">
|
||||
<object class="GtkIconView" id="iconview">
|
||||
<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>
|
||||
<property name="margin">6</property>
|
||||
<property name="model">iconview_model</property>
|
||||
<property name="columns">3</property>
|
||||
<property name="row-spacing">0</property>
|
||||
<property name="column-spacing">0</property>
|
||||
<property name="pixbuf-column">0</property>
|
||||
<property name="tooltip-column">2</property>
|
||||
<property name="item-padding">3</property>
|
||||
<property name="activate-on-single-click">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
||||
Reference in New Issue
Block a user