diff options
-rw-r--r-- | include/svx/TextCharacterSpacingPopup.hxx | 1 | ||||
-rw-r--r-- | solenv/sanitizers/ui/svx.suppr | 2 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextCharacterSpacingControl.cxx | 98 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextCharacterSpacingControl.hxx | 34 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextCharacterSpacingPopup.cxx | 14 | ||||
-rw-r--r-- | svx/uiconfig/ui/textcharacterspacingcontrol.ui | 110 |
6 files changed, 122 insertions, 137 deletions
diff --git a/include/svx/TextCharacterSpacingPopup.hxx b/include/svx/TextCharacterSpacingPopup.hxx index 1efc2d9a170f..2074e468373d 100644 --- a/include/svx/TextCharacterSpacingPopup.hxx +++ b/include/svx/TextCharacterSpacingPopup.hxx @@ -30,6 +30,7 @@ public: TextCharacterSpacingPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext); virtual ~TextCharacterSpacingPopup() override; + virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override; using svt::ToolboxController::createPopupWindow; virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override; diff --git a/solenv/sanitizers/ui/svx.suppr b/solenv/sanitizers/ui/svx.suppr index 5061b07311e3..b2c056964c43 100644 --- a/solenv/sanitizers/ui/svx.suppr +++ b/solenv/sanitizers/ui/svx.suppr @@ -66,4 +66,4 @@ svx/uiconfig/ui/sidebarshadow.ui://GtkLabel[@id='transparency_label'] orphan-lab svx/uiconfig/ui/sidebarshadow.ui://GtkSpinButton[@id='FIELD_TRANSPARENCY'] no-labelled-by svx/uiconfig/ui/sidebarshadow.ui://GtkScale[@id='transparency_slider'] no-labelled-by svx/uiconfig/ui/sidebarline.ui://GtkMenuToolButton[@id='SelectWidth'] button-no-label -svx/uiconfig/ui/textcharacterspacingcontrol.ui://GtkSpinButton[@id='kerning:0pt'] no-labelled-by +svx/uiconfig/ui/textcharacterspacingcontrol.ui://GtkSpinButton[@id='kerning'] no-labelled-by diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx index 3de287aff0f9..e19044e2eb25 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx +++ b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx @@ -42,41 +42,40 @@ namespace svx { -TextCharacterSpacingControl::TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, vcl::Window* pParent) - : ToolbarPopup(pControl->getFrameInterface(), pParent, "TextCharacterSpacingControl", "svx/ui/textcharacterspacingcontrol.ui") +TextCharacterSpacingControl::TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, weld::Widget* pParent) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/textcharacterspacingcontrol.ui", "TextCharacterSpacingControl") , mnId(SID_ATTR_CHAR_KERNING) , mnCustomKern(0) , mnLastCus(SPACING_NOCUSTOM) + , mxEditKerning(m_xBuilder->weld_metric_spin_button("kerning", FieldUnit::POINT)) + , mxTight(m_xBuilder->weld_button("tight")) + , mxVeryTight(m_xBuilder->weld_button("very_tight")) + , mxNormal(m_xBuilder->weld_button("normal")) + , mxLoose(m_xBuilder->weld_button("loose")) + , mxVeryLoose(m_xBuilder->weld_button("very_loose")) + , mxLastCustom(m_xBuilder->weld_button("last_custom")) + , mxControl(pControl) { - get(maEditKerning, "kerning"); - - get(maNormal, "normal"); - get(maVeryTight, "very_tight"); - get(maTight, "tight"); - get(maVeryLoose, "very_loose"); - get(maLoose, "loose"); - get(maLastCustom, "last_custom"); - - maEditKerning->SetModifyHdl(LINK(this, TextCharacterSpacingControl, KerningModifyHdl)); - maEditKerning->SetHelpId(HID_SPACING_MB_KERN); - - Link<Button*,void> aLink = LINK(this, TextCharacterSpacingControl, PredefinedValuesHdl); - maNormal->SetClickHdl(aLink); - maVeryTight->SetClickHdl(aLink); - maTight->SetClickHdl(aLink); - maVeryLoose->SetClickHdl(aLink); - maLoose->SetClickHdl(aLink); - maLastCustom->SetClickHdl(aLink); + mxEditKerning->connect_value_changed(LINK(this, TextCharacterSpacingControl, KerningModifyHdl)); + mxEditKerning->set_help_id(HID_SPACING_MB_KERN); + + Link<weld::Button&,void> aLink = LINK(this, TextCharacterSpacingControl, PredefinedValuesHdl); + mxNormal->connect_clicked(aLink); + mxVeryTight->connect_clicked(aLink); + mxTight->connect_clicked(aLink); + mxVeryLoose->connect_clicked(aLink); + mxLoose->connect_clicked(aLink); + mxLastCustom->connect_clicked(aLink); Initialize(); } -TextCharacterSpacingControl::~TextCharacterSpacingControl() +void TextCharacterSpacingControl::GrabFocus() { - disposeOnce(); + mxVeryTight->grab_focus(); } -void TextCharacterSpacingControl::dispose() +TextCharacterSpacingControl::~TextCharacterSpacingControl() { if (mnLastCus == SPACING_CLOSE_BY_CUS_EDIT) { @@ -85,17 +84,6 @@ void TextCharacterSpacingControl::dispose() { { "Spacing", css::uno::makeAny(OUString::number(mnCustomKern)) } }; aWinOpt.SetUserData(aSeq); } - - maEditKerning.clear(); - - maNormal.clear(); - maVeryTight.clear(); - maTight.clear(); - maVeryLoose.clear(); - maLoose.clear(); - maLastCustom.clear(); - - ToolbarPopup::dispose(); } void TextCharacterSpacingControl::Initialize() @@ -130,19 +118,19 @@ void TextCharacterSpacingControl::Initialize() { MapUnit eUnit = GetCoreMetric(); MapUnit eOrgUnit = eUnit; - long nBig = maEditKerning->Normalize(nKerning); - nKerning = LogicToLogic(nBig, eOrgUnit, MapUnit::MapPoint); - maEditKerning->SetValue(nKerning); + long nBig = mxEditKerning->normalize(nKerning); + nKerning = OutputDevice::LogicToLogic(nBig, eOrgUnit, MapUnit::MapPoint); + mxEditKerning->set_value(nKerning, FieldUnit::NONE); } else if(SfxItemState::DISABLED == eState) { - maEditKerning->SetText(OUString()); - maEditKerning->Disable(); + mxEditKerning->set_text(OUString()); + mxEditKerning->set_sensitive(false); } else { - maEditKerning->SetText(OUString()); - maEditKerning->Disable(); + mxEditKerning->set_text(OUString()); + mxEditKerning->set_sensitive(false); } } @@ -153,52 +141,52 @@ void TextCharacterSpacingControl::ExecuteCharacterSpacing(long nValue, bool bClo long nSign = (nValue < 0) ? -1 : 1; nValue = nValue * nSign; - long nVal = LogicToLogic(nValue, MapUnit::MapPoint, eUnit); - short nKern = (nValue == 0) ? 0 : static_cast<short>(maEditKerning->Denormalize(nVal)); + long nVal = OutputDevice::LogicToLogic(nValue, MapUnit::MapPoint, eUnit); + short nKern = (nValue == 0) ? 0 : static_cast<short>(mxEditKerning->denormalize(nVal)); SvxKerningItem aKernItem(nSign * nKern, SID_ATTR_CHAR_KERNING); SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING, SfxCallMode::RECORD, { &aKernItem }); - if(bClose) - EndPopupMode(); + if (bClose) + mxControl->EndPopupMode(); } -IMPL_LINK(TextCharacterSpacingControl, PredefinedValuesHdl, Button*, pControl, void) +IMPL_LINK(TextCharacterSpacingControl, PredefinedValuesHdl, weld::Button&, rControl, void) { mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; - if(pControl == maNormal) + if (&rControl == mxNormal.get()) { ExecuteCharacterSpacing(SPACING_NORMAL); } - else if(pControl == maVeryTight) + else if (&rControl == mxVeryTight.get()) { ExecuteCharacterSpacing(SPACING_VERY_TIGHT); } - else if(pControl == maTight) + else if (&rControl == mxTight.get()) { ExecuteCharacterSpacing(SPACING_TIGHT); } - else if(pControl == maVeryLoose) + else if (&rControl == mxVeryLoose.get()) { ExecuteCharacterSpacing(SPACING_VERY_LOOSE); } - else if(pControl == maLoose) + else if (&rControl == mxLoose.get()) { ExecuteCharacterSpacing(SPACING_LOOSE); } - else if(pControl == maLastCustom) + else if (&rControl == mxLastCustom.get()) { ExecuteCharacterSpacing(mnCustomKern); } } -IMPL_LINK_NOARG(TextCharacterSpacingControl, KerningModifyHdl, Edit&, void) +IMPL_LINK_NOARG(TextCharacterSpacingControl, KerningModifyHdl, weld::MetricSpinButton&, void) { mnLastCus = SPACING_CLOSE_BY_CUS_EDIT; - mnCustomKern = static_cast<long>(maEditKerning->GetValue()); + mnCustomKern = mxEditKerning->get_value(FieldUnit::NONE); ExecuteCharacterSpacing(mnCustomKern, false); } diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx index d4f79cdbbbe7..c1ea339b1ae3 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx +++ b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx @@ -20,8 +20,6 @@ #define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGCONTROL_HXX #include <sfx2/bindings.hxx> -#include <vcl/fixed.hxx> -#include <vcl/field.hxx> #include <svtools/toolbarmenu.hxx> namespace svx { @@ -33,35 +31,39 @@ namespace svx { class TextCharacterSpacingPopup; -class TextCharacterSpacingControl final : public svtools::ToolbarPopup +class TextCharacterSpacingControl final : public WeldToolbarPopup { public: - explicit TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, vcl::Window* pParent); - virtual ~TextCharacterSpacingControl() override; - virtual void dispose() override; + explicit TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, weld::Widget* pParent); -private: - VclPtr<MetricField> maEditKerning; + virtual void GrabFocus() override; - VclPtr<PushButton> maNormal; - VclPtr<PushButton> maVeryTight; - VclPtr<PushButton> maTight; - VclPtr<PushButton> maVeryLoose; - VclPtr<PushButton> maLoose; - VclPtr<PushButton> maLastCustom; + virtual ~TextCharacterSpacingControl() override; +private: sal_uInt16 mnId; long mnCustomKern; short mnLastCus; + std::unique_ptr<weld::MetricSpinButton> mxEditKerning; + std::unique_ptr<weld::Button> mxTight; + std::unique_ptr<weld::Button> mxVeryTight; + std::unique_ptr<weld::Button> mxNormal; + std::unique_ptr<weld::Button> mxLoose; + std::unique_ptr<weld::Button> mxVeryLoose; + std::unique_ptr<weld::Button> mxLastCustom; + + rtl::Reference<TextCharacterSpacingPopup> mxControl; + void Initialize(); void ExecuteCharacterSpacing(long nValue, bool bClose = true); - DECL_LINK(PredefinedValuesHdl, Button*, void); - DECL_LINK(KerningModifyHdl, Edit&, void); + DECL_LINK(PredefinedValuesHdl, weld::Button&, void); + DECL_LINK(KerningModifyHdl, weld::MetricSpinButton&, void); MapUnit GetCoreMetric() const; }; + } #endif diff --git a/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx index ea7104344f75..259fa83fe494 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx +++ b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx @@ -43,9 +43,19 @@ TextCharacterSpacingPopup::~TextCharacterSpacingPopup() { } -VclPtr<vcl::Window> TextCharacterSpacingPopup::createPopupWindow(vcl::Window* pParent) +std::unique_ptr<WeldToolbarPopup> TextCharacterSpacingPopup::weldPopupWindow() { - return VclPtr<TextCharacterSpacingControl>::Create(this, pParent); + return std::make_unique<TextCharacterSpacingControl>(this, m_pToolbar); +} + +VclPtr<vcl::Window> TextCharacterSpacingPopup::createPopupWindow( vcl::Window* pParent ) +{ + mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent, + std::make_unique<TextCharacterSpacingControl>(this, pParent->GetFrameWeld())); + + mxInterimPopover->Show(); + + return mxInterimPopover; } OUString TextCharacterSpacingPopup::getImplementationName() diff --git a/svx/uiconfig/ui/textcharacterspacingcontrol.ui b/svx/uiconfig/ui/textcharacterspacingcontrol.ui index 7d64085d8a94..a95833274f9e 100644 --- a/svx/uiconfig/ui/textcharacterspacingcontrol.ui +++ b/svx/uiconfig/ui/textcharacterspacingcontrol.ui @@ -1,71 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> - <object class="GtkAdjustment" id="adjustment1"> - <property name="lower">-2</property> - <property name="upper">10000</property> - <property name="step_increment">0.10000000000000001</property> - <property name="page_increment">1</property> - </object> - <object class="GtkImage" id="image_spacing_1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="pixbuf">svx/res/symphony/spacing_very_tight.png</property> - </object> - <object class="GtkImage" id="image_spacing_115"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_right">6</property> - <property name="xalign">0</property> - <property name="pixbuf">svx/res/symphony/spacing_tight.png</property> - <property name="icon_size">1</property> - </object> - <object class="GtkImage" id="image_spacing_15"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_right">6</property> - <property name="xalign">0</property> - <property name="pixbuf">svx/res/symphony/spacing_normal.png</property> - <property name="icon_size">1</property> - </object> - <object class="GtkImage" id="image_spacing_2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_right">6</property> - <property name="xalign">0</property> - <property name="pixbuf">svx/res/symphony/spacing_loose.png</property> - <property name="icon_size">1</property> - </object> - <object class="GtkImage" id="image_spacing_3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="pixbuf">svx/res/symphony/spacing_very_loose.png</property> - <property name="icon_size">1</property> - </object> - <object class="GtkImage" id="image_spacing_4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="pixbuf">svx/res/symphony/last_custom_common.png</property> - <property name="icon_size">1</property> - </object> - <object class="GtkWindow" id="TextCharacterSpacingControl"> + <object class="GtkPopover" id="TextCharacterSpacingControl"> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> + <property name="no_show_all">True</property> <property name="border_width">4</property> - <property name="resizable">False</property> - <property name="destroy_with_parent">True</property> - <property name="type_hint">popup-menu</property> - <property name="skip_pager_hint">True</property> - <property name="deletable">False</property> <child> - <object class="GtkGrid" id="grid2"> + <object class="GtkGrid" id="container"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="margin_right">6</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <child> @@ -168,7 +112,6 @@ <object class="GtkFrame" id="frame1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="margin_left">3</property> <property name="margin_top">6</property> <property name="hexpand">True</property> <property name="vexpand">True</property> @@ -181,12 +124,12 @@ <property name="margin_top">6</property> <property name="left_padding">12</property> <child> - <object class="GtkSpinButton" id="kerning:0pt"> + <object class="GtkSpinButton" id="kerning"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="width_chars">0</property> - <property name="text" translatable="yes" context="textcharacterspacingcontrol|kerning">0,0</property> + <property name="text" translatable="yes" context="textcharacterspacingcontrol|kerning">0.0</property> <property name="adjustment">adjustment1</property> <property name="digits">1</property> </object> @@ -212,4 +155,45 @@ </object> </child> </object> + <object class="GtkAdjustment" id="adjustment1"> + <property name="lower">-2</property> + <property name="upper">10000</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">1</property> + </object> + <object class="GtkImage" id="image_spacing_1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/symphony/spacing_very_tight.png</property> + </object> + <object class="GtkImage" id="image_spacing_115"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/symphony/spacing_tight.png</property> + <property name="icon_size">1</property> + </object> + <object class="GtkImage" id="image_spacing_15"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/symphony/spacing_normal.png</property> + <property name="icon_size">1</property> + </object> + <object class="GtkImage" id="image_spacing_2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/symphony/spacing_loose.png</property> + <property name="icon_size">1</property> + </object> + <object class="GtkImage" id="image_spacing_3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/symphony/spacing_very_loose.png</property> + <property name="icon_size">1</property> + </object> + <object class="GtkImage" id="image_spacing_4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/symphony/last_custom_common.png</property> + <property name="icon_size">1</property> + </object> </interface> |