diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-11-22 17:12:04 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-05-11 09:34:45 +0200 |
commit | b13886436dde34d33141138e7d1a20e7ca89c20b (patch) | |
tree | 6be857a69c71d8b94ddf31cef891c676726fc4e6 /cui | |
parent | 8c9d925e2030ee58f4fb2afd7f6e4737de1b2d9c (diff) |
cui: add UI for semi-transparent shape text
- Make font color only work with the RGB color, otherwise the preview
would be white for e.g. half-transparent red.
- Add label and widget to see already set transparency.
- Add a flag to show these only for Draw/Impress and leave Writer/Calc
unchanged.
- Update returned item set to contain transparency in case the widget
changes.
(cherry picked from commit b4554b8eddd048532269df610e89ae739c46fab7)
Change-Id: If77771076ff4b10a4a5d468a6583809a94deb57e
Diffstat (limited to 'cui')
-rw-r--r-- | cui/qa/uitest/dialogs/chardlg.py | 49 | ||||
-rw-r--r-- | cui/source/inc/chardlg.hxx | 3 | ||||
-rw-r--r-- | cui/source/tabpages/chardlg.cxx | 40 | ||||
-rw-r--r-- | cui/uiconfig/ui/effectspage.ui | 30 |
4 files changed, 121 insertions, 1 deletions
diff --git a/cui/qa/uitest/dialogs/chardlg.py b/cui/qa/uitest/dialogs/chardlg.py new file mode 100644 index 000000000000..59cf10d18c29 --- /dev/null +++ b/cui/qa/uitest/dialogs/chardlg.py @@ -0,0 +1,49 @@ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos + +# Test for cui/source/tabpages/chardlg.cxx. +class Test(UITestCase): + + def testSvxCharEffectsPage(self): + # Start Impress. + self.ui_test.create_doc_in_start_center("impress") + template = self.xUITest.getTopFocusWindow() + self.ui_test.close_dialog_through_button(template.getChild("cancel")) + doc = self.xUITest.getTopFocusWindow() + editWin = doc.getChild("impress_win") + # Select the title shape. + editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"})) + self.xUITest.executeCommand(".uno:SelectAll") + + # Now use Format -> Character. + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + # Select RID_SVXPAGE_CHAR_EFFECTS. + select_pos(xTabs, "1") + xFontTransparency = xDialog.getChild("fonttransparencymtr") + for _ in range(5): + xFontTransparency.executeAction("UP", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + + # Verify the result. + component = self.ui_test.get_component() + drawPage = component.getDrawPages().getByIndex(0) + shape = drawPage.getByIndex(0) + + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 100 != 5 + # i.e. the dialog did not set transparency to 5%, instead it left the character color at + # COL_AUTO. + self.assertEqual(shape.CharTransparence, 5) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index 9e4419d4406e..da382112af6f 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -171,6 +171,8 @@ private: std::unique_ptr<weld::Label> m_xFontColorFT; std::unique_ptr<ColorListBox> m_xFontColorLB; + std::unique_ptr<weld::Label> m_xFontTransparencyFT; + std::unique_ptr<weld::MetricSpinButton> m_xFontTransparencyMtr; std::unique_ptr<weld::Label> m_xEffectsFT; std::unique_ptr<weld::ComboBox> m_xEffectsLB; std::unique_ptr<weld::Label> m_xReliefFT; @@ -207,6 +209,7 @@ private: DECL_LINK(TristClickHdl_Impl, weld::ToggleButton&, void); DECL_LINK(UpdatePreview_Impl, weld::ComboBox&, void); DECL_LINK(ColorBoxSelectHdl_Impl, ColorListBox&, void); + DECL_LINK(ModifyFontTransparencyHdl_Impl, weld::MetricSpinButton&, void); public: SvxCharEffectsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index d7dca728de87..211ec9e15679 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -1319,6 +1319,9 @@ SvxCharEffectsPage::SvxCharEffectsPage(weld::Container* pPage, weld::DialogContr , m_bUnderlineColorDisabled(false) , m_xFontColorFT(m_xBuilder->weld_label("fontcolorft")) , m_xFontColorLB(new ColorListBox(m_xBuilder->weld_menu_button("fontcolorlb"), pController->getDialog())) + , m_xFontTransparencyFT(m_xBuilder->weld_label("fonttransparencyft")) + , m_xFontTransparencyMtr( + m_xBuilder->weld_metric_spin_button("fonttransparencymtr", FieldUnit::PERCENT)) , m_xEffectsFT(m_xBuilder->weld_label("effectsft")) , m_xEffectsLB(m_xBuilder->weld_combo_box("effectslb")) , m_xReliefFT(m_xBuilder->weld_label("reliefft")) @@ -1370,6 +1373,7 @@ SvxCharEffectsPage::~SvxCharEffectsPage() { m_xUnderlineColorLB.reset(); m_xOverlineColorLB.reset(); + m_xFontTransparencyMtr.reset(); m_xFontColorLB.reset(); } @@ -1393,6 +1397,8 @@ void SvxCharEffectsPage::Initialize() } m_xFontColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl)); + m_xFontTransparencyMtr->connect_value_changed( + LINK(this, SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl)); // handler Link<weld::ComboBox&,void> aLink = LINK( this, SvxCharEffectsPage, SelectListBoxHdl_Impl ); @@ -1558,7 +1564,19 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet ) m_aPreviewWin.Invalidate(); - m_xFontColorLB->SelectEntry(aColor); + Color aRGBColor = aColor; + if (aRGBColor.GetTransparency()) + { + aRGBColor.SetTransparency(0); + } + m_xFontColorLB->SelectEntry(aRGBColor); + + if (m_xFontTransparencyMtr->get_visible() && aColor != COL_AUTO) + { + double fTransparency = aColor.GetTransparency() * 100.0 / 255; + m_xFontTransparencyMtr->set_value(basegfx::fround(fTransparency), + FieldUnit::PERCENT); + } m_aOrigFontColor = aColor; m_bOrigFontColor = true; @@ -1579,6 +1597,14 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet ) if (bChanged) { aSelectedColor = m_xFontColorLB->GetSelectEntryColor(); + + if (m_xFontTransparencyMtr->get_value_changed_from_saved()) + { + double fTransparency + = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100; + aSelectedColor.SetTransparency(static_cast<sal_uInt8>(basegfx::fround(fTransparency))); + } + if (m_bOrigFontColor) bChanged = aSelectedColor != m_aOrigFontColor; if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR) @@ -1662,6 +1688,11 @@ IMPL_LINK(SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox&, rBox, void) UpdatePreview_Impl(); } +IMPL_LINK_NOARG(SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl, weld::MetricSpinButton&, void) +{ + m_bNewFontColor = true; +} + DeactivateRC SvxCharEffectsPage::DeactivatePage( SfxItemSet* _pSet ) { if ( _pSet ) @@ -2064,6 +2095,7 @@ void SvxCharEffectsPage::ChangesApplied() m_xShadowBtn->save_state(); m_xBlinkingBtn->save_state(); m_xHiddenBtn->save_state(); + m_xFontTransparencyMtr->save_value(); } bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) @@ -2427,6 +2459,12 @@ void SvxCharEffectsPage::PageCreated(const SfxAllItemSet& aSet) if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) // the writer uses SID_ATTR_BRUSH as font background m_bPreviewBackgroundToCharacter = true; + if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY) + { + // Only show these in case client code explicitly wants this. + m_xFontTransparencyFT->hide(); + m_xFontTransparencyMtr->hide(); + } } } diff --git a/cui/uiconfig/ui/effectspage.ui b/cui/uiconfig/ui/effectspage.ui index 9a5cb1a89fe1..581b28912c16 100644 --- a/cui/uiconfig/ui/effectspage.ui +++ b/cui/uiconfig/ui/effectspage.ui @@ -585,6 +585,31 @@ </packing> </child> <child> + <object class="GtkLabel" id="fonttransparencyft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="effectspage|fonttransparencyft">_Transparency:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">fonttransparencymtr</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="fonttransparencymtr"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentPercent</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> <placeholder/> </child> </object> @@ -636,4 +661,9 @@ <widget name="fontcolorlb"/> </widgets> </object> + <object class="GtkAdjustment" id="adjustmentPercent"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> </interface> |