diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-10-13 13:16:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-10-13 14:16:54 +0100 |
commit | b859d84e471fdb70b61607d2d919a7907d074bd0 (patch) | |
tree | e379df9933a981feb588f9f53ed16d8197192204 /cui | |
parent | ec66ad595393312525937b628297cb3494776e1f (diff) |
implement dialog control over enhanced shape control points
use case is a desire to enable viewing and setting rounded rectangle radiuses
to an exact known value
Change-Id: I7e6a4db0699076950adf5869a61825159766c46a
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/transfrm.hxx | 6 | ||||
-rw-r--r-- | cui/source/tabpages/transfrm.cxx | 137 | ||||
-rw-r--r-- | cui/uiconfig/ui/slantcornertabpage.ui | 335 |
3 files changed, 428 insertions, 50 deletions
diff --git a/cui/source/inc/transfrm.hxx b/cui/source/inc/transfrm.hxx index e5892be1c21f..f79897f94e28 100644 --- a/cui/source/inc/transfrm.hxx +++ b/cui/source/inc/transfrm.hxx @@ -237,6 +237,12 @@ private: VclPtr<VclFrame> m_pFlAngle; VclPtr<MetricField> m_pMtrAngle; + VclPtr<VclFrame> m_aControlGroups[2]; + VclPtr<VclContainer> m_aControlGroupX[2]; + VclPtr<MetricField> m_aControlX[2]; + VclPtr<VclContainer> m_aControlGroupY[2]; + VclPtr<MetricField> m_aControlY[2]; + const SfxItemSet& rOutAttrs; const SdrView* pView; diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index 9bfb6e875329..9cb7cc69b5fc 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -18,6 +18,8 @@ */ #include <sfx2/app.hxx> +#include <svx/EnhancedCustomShape2d.hxx> +#include <svx/svdundo.hxx> #include <svx/svdview.hxx> #include <svx/svdobj.hxx> #include <svx/svdpagv.hxx> @@ -430,6 +432,15 @@ SvxSlantTabPage::SvxSlantTabPage(vcl::Window* pParent, const SfxItemSet& rInAttr get(m_pFlAngle, "FL_SLANT"); get(m_pMtrAngle, "MTR_FLD_ANGLE"); + for (int i = 0; i < 2; ++i) + { + get(m_aControlGroups[i], "controlgroups" + OString::number(i+1)); + get(m_aControlGroupX[i], "controlgroupx" + OString::number(i+1)); + get(m_aControlX[i], "controlx" + OString::number(i+1)); + get(m_aControlGroupY[i], "controlgroupy" + OString::number(i+1)); + get(m_aControlY[i], "controly" + OString::number(i+1)); + } + // this page needs ExchangeSupport SetExchangeSupport(); @@ -450,6 +461,14 @@ void SvxSlantTabPage::dispose() m_pMtrRadius.clear(); m_pFlAngle.clear(); m_pMtrAngle.clear(); + for (int i = 0; i < 2; ++i) + { + m_aControlGroups[i].clear(); + m_aControlGroupX[i].clear(); + m_aControlX[i].clear(); + m_aControlGroupY[i].clear(); + m_aControlY[i].clear(); + } SvxTabPage::dispose(); } @@ -505,10 +524,56 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) rAttrs->Put( SfxBoolItem( SID_ATTR_TRANSFORM_SHEAR_VERTICAL, false ) ); } - return bModified; -} + bool bControlPointsChanged = false; + for (int i = 0; i < 2; ++i) + { + bControlPointsChanged |= (m_aControlX[i]->IsValueChangedFromSaved() || + m_aControlY[i]->IsValueChangedFromSaved()); + } + + if (!bControlPointsChanged) + return bModified; + + SdrObject* pObj = pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); + SdrModel* pModel = pObj->GetModel(); + SdrUndoAction* pUndo = pModel->IsUndoEnabled() ? + pModel->GetSdrUndoFactory().CreateUndoAttrObject(*pObj) : + nullptr; + if (pUndo) + pModel->BegUndo(pUndo->GetComment()); + + EnhancedCustomShape2d aShape(pObj); + Rectangle aLogicRect = aShape.GetLogicRect(); + + for (int i = 0; i < 2; ++i) + { + if (m_aControlX[i]->IsValueChangedFromSaved() || m_aControlY[i]->IsValueChangedFromSaved()) + { + Point aNewPosition(GetCoreValue(*m_aControlX[i], ePoolUnit), + GetCoreValue(*m_aControlY[i], ePoolUnit)); + aNewPosition.Move(aLogicRect.Left(), aLogicRect.Top()); + + css::awt::Point aPosition; + aPosition.X = aNewPosition.X(); + aPosition.Y = aNewPosition.Y(); + + aShape.SetHandleControllerPosition(i, aPosition); + } + } + + pObj->SetChanged(); + pObj->BroadcastObjectChange(); + bModified = true; + + if (pUndo) + { + pModel->AddUndo(pUndo); + pModel->EndUndo(); + } + return bModified; +} void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) { @@ -560,17 +625,76 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) } m_pMtrAngle->SaveValue(); -} - + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier(); + if (eKind == OBJ_CUSTOMSHAPE) + { + EnhancedCustomShape2d aShape(pObj); + Point aInitialPosition; + for (int i = 0; i < 2; ++i) + { + if (!aShape.GetHandlePosition(i, aInitialPosition)) + break; + m_aControlGroups[i]->Enable(); + css::awt::Point aPosition; + + aPosition.X = SAL_MAX_INT32; + aPosition.Y = SAL_MAX_INT32; + aShape.SetHandleControllerPosition(i, aPosition); + Point aMaxPosition; + aShape.GetHandlePosition(i, aMaxPosition); + + aPosition.X = SAL_MIN_INT32; + aPosition.Y = SAL_MIN_INT32; + aShape.SetHandleControllerPosition(i, aPosition); + Point aMinPosition; + aShape.GetHandlePosition(i, aMinPosition); + + Rectangle aLogicRect = aShape.GetLogicRect(); + aMaxPosition.Move(-aLogicRect.Left(), -aLogicRect.Top()); + aMinPosition.Move(-aLogicRect.Left(), -aLogicRect.Top()); + + aPosition.X = aInitialPosition.X(); + aPosition.Y = aInitialPosition.Y(); + aInitialPosition.Move(-aLogicRect.Left(), -aLogicRect.Top()); + aShape.SetHandleControllerPosition(i, aPosition); + + SetMetricValue(*m_aControlX[i], aInitialPosition.X(), ePoolUnit); + SetMetricValue(*m_aControlY[i], aInitialPosition.Y(), ePoolUnit); + + if (aMaxPosition.X() == aMinPosition.X()) + m_aControlGroupX[i]->Disable(); + else + { + m_aControlX[i]->SetMin(aMinPosition.X(), FUNIT_MM); + m_aControlX[i]->SetMax(aMaxPosition.X(), FUNIT_MM); + } + if (aMaxPosition.Y() == aMinPosition.Y()) + m_aControlGroupY[i]->Disable(); + else + { + m_aControlY[i]->SetMin(aMinPosition.Y(), FUNIT_MM); + m_aControlY[i]->SetMax(aMaxPosition.Y(), FUNIT_MM); + } + } + } + } + for (int i = 0; i < 2; ++i) + { + m_aControlX[i]->SaveValue(); + m_aControlY[i]->SaveValue(); + } +} VclPtr<SfxTabPage> SvxSlantTabPage::Create( vcl::Window* pWindow, const SfxItemSet* rOutAttrs ) { return VclPtr<SvxSlantTabPage>::Create( pWindow, *rOutAttrs ); } - - void SvxSlantTabPage::ActivatePage( const SfxItemSet& rSet ) { SfxRectangleItem const * pRectItem = NULL; @@ -618,7 +742,6 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(vcl::Window* pParent, const SfxIt , mfOldWidth(0.0) , mfOldHeight(0.0) { - get(m_pFlPosition, "FL_POSITION"); get(m_pMtrPosX, "MTR_FLD_POS_X"); get(m_pMtrPosY, "MTR_FLD_POS_Y"); diff --git a/cui/uiconfig/ui/slantcornertabpage.ui b/cui/uiconfig/ui/slantcornertabpage.ui index 37b7b0eebe75..05262d723353 100644 --- a/cui/uiconfig/ui/slantcornertabpage.ui +++ b/cui/uiconfig/ui/slantcornertabpage.ui @@ -2,23 +2,131 @@ <!-- Generated with glade 3.18.3 --> <interface> <requires lib="gtk+" version="3.0"/> - <object class="GtkAdjustment" id="adjustmentRADIUS"> - <property name="upper">500</property> - <property name="step_increment">10</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustmentSLANT"> - <property name="lower">-89</property> - <property name="upper">89</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkBox" id="SlantAndCornerRadius"> + <object class="GtkGrid" id="SlantAndCornerRadius"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="border_width">6</property> - <property name="orientation">vertical</property> - <property name="spacing">12</property> + <property name="row_spacing">24</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkFrame" id="controlgroups1"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">12</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkBox" id="controlgroupx1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_X:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">controlx1:0.00cm</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="controlx1:0.00cm"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">0.00</property> + <property name="digits">2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="controlgroupy1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Y:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">controly1:0.00cm</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="controly1:0.00cm"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">0.00</property> + <property name="digits">2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Control Point 1</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> <child> <object class="GtkFrame" id="FL_RADIUS"> <property name="visible">True</property> @@ -32,37 +140,36 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="GtkBox" id="box2"> + <object class="GtkGrid" id="grid2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">12</property> + <property name="column_spacing">12</property> <child> <object class="GtkLabel" id="FT_RADIUS"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">_Radius:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">MTR_FLD_RADIUS:0.00cm</property> + <property name="xalign">0</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> </packing> </child> <child> <object class="GtkSpinButton" id="MTR_FLD_RADIUS:0.00cm"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="invisible_char">•</property> + <property name="text" translatable="yes">0.00</property> <property name="adjustment">adjustmentRADIUS</property> <property name="digits">2</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="top_attach">0</property> </packing> </child> </object> @@ -73,8 +180,8 @@ <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Corner Radius</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -82,9 +189,8 @@ </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> </packing> </child> <child> @@ -100,37 +206,36 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="GtkBox" id="box3"> + <object class="GtkGrid" id="grid3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">12</property> + <property name="column_spacing">12</property> <child> <object class="GtkLabel" id="FT_ANGLE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">_Angle:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">MTR_FLD_ANGLE:0.00degrees</property> + <property name="xalign">0</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> </packing> </child> <child> <object class="GtkSpinButton" id="MTR_FLD_ANGLE:0.00degrees"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="invisible_char">•</property> + <property name="text" translatable="yes">0.00</property> <property name="adjustment">adjustmentSLANT</property> <property name="digits">2</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="top_attach">0</property> </packing> </child> </object> @@ -141,8 +246,128 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Slant</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="controlgroups2"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkGrid" id="grid4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">12</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkBox" id="controlgroupx2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_X:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">controlx2:0.00cm</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="controlx2:0.00cm"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">0.00</property> + <property name="digits">2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="controlgroupy2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Y:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">controly2:0.00cm</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="controly2:0.00cm"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">0.00</property> + <property name="digits">2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Control Point 2</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -150,12 +375,36 @@ </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="top_attach">1</property> </packing> </child> </object> + <object class="GtkSizeGroup" id="sizegroup3"> + <widgets> + <widget name="label5"/> + <widget name="label6"/> + <widget name="FT_RADIUS"/> + </widgets> + </object> + <object class="GtkSizeGroup" id="sizegroup4"> + <widgets> + <widget name="FT_ANGLE"/> + <widget name="label4"/> + <widget name="label7"/> + </widgets> + </object> + <object class="GtkAdjustment" id="adjustmentRADIUS"> + <property name="upper">500</property> + <property name="step_increment">10</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentSLANT"> + <property name="lower">-89</property> + <property name="upper">89</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkSizeGroup" id="sizegroup1"> <widgets> <widget name="FT_RADIUS"/> |