cui/source/dialogs/FontFeaturesDialog.cxx | 53 ++++++++++- cui/source/inc/FontFeaturesDialog.hxx | 5 + cui/uiconfig/ui/fontfeaturesdialog.ui | 133 ++++++++++++++++++++++++++++-- 3 files changed, 176 insertions(+), 15 deletions(-)
New commits: commit df57f192c03b38b834a8283b80fc9cd9610b1583 Author: Khaled Hosny <kha...@aliftype.com> AuthorDate: Sat Dec 3 15:33:08 2022 +0200 Commit: خالد حسني <kha...@aliftype.com> CommitDate: Sun Dec 4 08:19:58 2022 +0000 Seperate Stylistic Sets and Character Variants in Font Features Dialog Makes clear what these features are when we use feature names provided by the font. Change-Id: I98a7294d3e1e7fef5293d0444c0fbbfcc131ed44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143611 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@aliftype.com> diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx index a23c0083c1b3..e4154e640ab5 100644 --- a/cui/source/dialogs/FontFeaturesDialog.cxx +++ b/cui/source/dialogs/FontFeaturesDialog.cxx @@ -23,7 +23,12 @@ FontFeaturesDialog::FontFeaturesDialog(weld::Window* pParent, OUString aFontName : GenericDialogController(pParent, "cui/ui/fontfeaturesdialog.ui", "FontFeaturesDialog") , m_sFontName(std::move(aFontName)) , m_xContentWindow(m_xBuilder->weld_scrolled_window("contentWindow")) + , m_xContentBox(m_xBuilder->weld_container("contentBox")) , m_xContentGrid(m_xBuilder->weld_container("contentGrid")) + , m_xStylisticSetsBox(m_xBuilder->weld_container("stylisticSetsBox")) + , m_xStylisticSetsGrid(m_xBuilder->weld_container("stylisticSetsGrid")) + , m_xCharacterVariantsBox(m_xBuilder->weld_container("characterVariantsBox")) + , m_xCharacterVariantsGrid(m_xBuilder->weld_container("characterVariantsGrid")) , m_xPreviewWindow(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWindow)) { initialize(); @@ -66,9 +71,11 @@ void FontFeaturesDialog::initialize() int nRowHeight = fillGrid(rFilteredFontFeatures); + auto nFeaturesHeight = m_xContentBox->get_preferred_size().Height() + + m_xStylisticSetsBox->get_preferred_size().Height() + + m_xCharacterVariantsBox->get_preferred_size().Height(); m_xContentWindow->set_size_request( - -1, std::min(std::max(m_xContentWindow->get_preferred_size().Height(), - m_xContentGrid->get_preferred_size().Height()), + -1, std::min(std::max(m_xContentWindow->get_preferred_size().Height(), nFeaturesHeight), static_cast<tools::Long>(300L))); if (nRowHeight) @@ -80,6 +87,21 @@ void FontFeaturesDialog::initialize() updateFontPreview(); } +namespace +{ +bool isCharacterVariantCode(sal_uInt32 nFeatureCode) +{ + return ((sal_uInt32(nFeatureCode) >> 24) & 0xFF) == 'c' + && ((sal_uInt32(nFeatureCode) >> 16) & 0xFF) == 'v'; +} + +bool isStylisticSetCode(sal_uInt32 nFeatureCode) +{ + return ((sal_uInt32(nFeatureCode) >> 24) & 0xFF) == 's' + && ((sal_uInt32(nFeatureCode) >> 16) & 0xFF) == 's'; +} +} + int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFeatures) { int nRowHeight(0); @@ -87,7 +109,7 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea vcl::font::FeatureParser aParser(m_sFontName); auto aExistingFeatures = aParser.getFeaturesMap(); - sal_Int32 i = 0; + sal_Int32 i = 0, j = 0, k = 0, n = 0; for (vcl::font::Feature const& rFontFeature : rFontFeatures) { sal_uInt32 nFontFeatureCode = rFontFeature.m_nCode; @@ -98,7 +120,24 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea if (!aDefinition) aDefinition = { nFontFeatureCode, "" }; - m_aFeatureItems.emplace_back(m_xContentGrid.get()); + if (isStylisticSetCode(nFontFeatureCode)) + { + n = j++; + m_xStylisticSetsBox->set_visible(true); + m_aFeatureItems.emplace_back(m_xStylisticSetsGrid.get()); + } + else if (isCharacterVariantCode(nFontFeatureCode)) + { + n = k++; + m_xCharacterVariantsBox->set_visible(true); + m_aFeatureItems.emplace_back(m_xCharacterVariantsGrid.get()); + } + else + { + n = i++; + m_xContentBox->set_visible(true); + m_aFeatureItems.emplace_back(m_xContentGrid.get()); + } int32_t nValue = 0; if (aExistingFeatures.find(nFontFeatureCode) != aExistingFeatures.end()) @@ -110,8 +149,8 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea aCurrentItem.m_aFeatureCode = nFontFeatureCode; aCurrentItem.m_nDefault = aDefinition.getDefault(); - sal_Int32 nGridPositionX = (i % 2) * 2; - sal_Int32 nGridPositionY = i / 2; + sal_Int32 nGridPositionX = (n % 2) * 2; + sal_Int32 nGridPositionY = n / 2; aCurrentItem.m_xContainer->set_grid_left_attach(nGridPositionX); aCurrentItem.m_xContainer->set_grid_top_attach(nGridPositionY); @@ -144,8 +183,6 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea nRowHeight = std::max<int>(nRowHeight, aCurrentItem.m_xContainer->get_preferred_size().Height()); - - i++; } return nRowHeight; diff --git a/cui/source/inc/FontFeaturesDialog.hxx b/cui/source/inc/FontFeaturesDialog.hxx index 6b30a33111b2..c4eb43b79e98 100644 --- a/cui/source/inc/FontFeaturesDialog.hxx +++ b/cui/source/inc/FontFeaturesDialog.hxx @@ -49,7 +49,12 @@ private: SvxFontPrevWindow m_aPreviewWindow; std::unique_ptr<weld::ScrolledWindow> m_xContentWindow; + std::unique_ptr<weld::Container> m_xContentBox; std::unique_ptr<weld::Container> m_xContentGrid; + std::unique_ptr<weld::Container> m_xStylisticSetsBox; + std::unique_ptr<weld::Container> m_xStylisticSetsGrid; + std::unique_ptr<weld::Container> m_xCharacterVariantsBox; + std::unique_ptr<weld::Container> m_xCharacterVariantsGrid; std::unique_ptr<weld::CustomWeld> m_xPreviewWindow; void initialize(); diff --git a/cui/uiconfig/ui/fontfeaturesdialog.ui b/cui/uiconfig/ui/fontfeaturesdialog.ui index 4b4427f0041f..c0eca92c3b73 100644 --- a/cui/uiconfig/ui/fontfeaturesdialog.ui +++ b/cui/uiconfig/ui/fontfeaturesdialog.ui @@ -89,16 +89,135 @@ <property name="visible">True</property> <property name="can-focus">False</property> <child> - <!-- n-columns=1 n-rows=1 --> - <object class="GtkGrid" id="contentGrid"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="valign">start</property> - <property name="row-spacing">6</property> - <property name="column-spacing">12</property> - <property name="row-homogeneous">True</property> + <property name="orientation">vertical</property> <child> - <placeholder/> + <object class="GtkBox" id="contentBox"> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="contentGrid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="valign">start</property> + <property name="row-spacing">6</property> + <property name="column-spacing">12</property> + <property name="row-homogeneous">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="stylisticSetsBox"> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="margin-top">6</property> + <property name="label" translatable="yes" context="fontfeaturesdialog">Stylistic Sets</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="stylisticSetsGrid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="valign">start</property> + <property name="row-spacing">6</property> + <property name="column-spacing">12</property> + <property name="row-homogeneous">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="characterVariantsBox"> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="margin-top">6</property> + <property name="label" translatable="yes" context="fontfeaturesdialog">Character Variants</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="characterVariantsGrid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="valign">start</property> + <property name="row-spacing">6</property> + <property name="column-spacing">12</property> + <property name="row-homogeneous">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> </child> </object> </child>