From 00a70f10f4c5c273a783f87f61e9d98b9d79deca Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 22 Jun 2015 16:13:38 +0200 Subject: Add simple GUI for 'font-feature-settings'. (bzr r14208) --- src/ui/widget/font-variants.cpp | 46 ++++++++++++++++++++++++++++++++++++++++- src/ui/widget/font-variants.h | 12 ++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp index 637631fda..7a1e02839 100644 --- a/src/ui/widget/font-variants.cpp +++ b/src/ui/widget/font-variants.cpp @@ -68,6 +68,9 @@ namespace Widget { _numeric_ordinal ( Glib::ustring(_("Ordinal" )) ), _numeric_slashed_zero ( Glib::ustring(_("Slashed Zero" )) ), + _feature_frame ( Glib::ustring(_("Feature Settings")) ), + _feature_label ( Glib::ustring(_("Selection has different Feature Settings!")) ), + _ligatures_changed( false ), _position_changed( false ), _caps_changed( false ), @@ -231,6 +234,21 @@ namespace Widget { add( _numeric_frame ); + // Feature settings --------------------- + + // Add tooltips + _feature_entry.set_tooltip_text( _("Feature settings in CSS form. No sanity checking is performed.")); + + // Add to frame + _feature_vbox.add( _feature_entry ); + _feature_vbox.add( _feature_label ); + _feature_frame.add( _feature_vbox ); + add( _feature_frame ); + + // Add signals + //_feature_entry.signal_key_press_event().connect ( sigc::mem_fun(*this, &FontVariants::feature_callback) ); + _feature_entry.signal_changed().connect( sigc::mem_fun(*this, &FontVariants::feature_callback) ); + show_all_children(); } @@ -283,9 +301,21 @@ namespace Widget { _changed_signal.emit(); } + void + FontVariants::feature_init() { + // std::cout << "FontVariants::feature_init()" << std::endl; + } + + void + FontVariants::feature_callback() { + // std::cout << "FontVariants::feature_callback()" << std::endl; + _feature_changed = true; + _changed_signal.emit(); + } + // Update GUI based on query. void - FontVariants::update( SPStyle const *query ) { + FontVariants::update( SPStyle const *query, bool different_features ) { _ligatures_all = query->font_variant_ligatures.computed; _ligatures_mix = query->font_variant_ligatures.value; @@ -370,10 +400,19 @@ namespace Widget { _numeric_ordinal.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_ORDINAL ); _numeric_slashed_zero.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_SLASHED_ZERO ); + if( query->font_feature_settings.value ) + _feature_entry.set_text( query->font_feature_settings.value ); + if( different_features ) { + _feature_label.show(); + } else { + _feature_label.hide(); + } + _ligatures_changed = false; _position_changed = false; _caps_changed = false; _numeric_changed = false; + _feature_changed = false; } void @@ -494,6 +533,11 @@ namespace Widget { sp_repr_css_set_property(css, "font-variant-numeric", css_string.c_str() ); } + // Feature settings + Glib::ustring feature_string = _feature_entry.get_text(); + if( !feature_string.empty() || feature_string.compare( "normal" ) ) { + sp_repr_css_set_property(css, "font-feature-settings", feature_string.c_str()); + } } } // namespace Widget diff --git a/src/ui/widget/font-variants.h b/src/ui/widget/font-variants.h index e6a9dd68b..ca41c050b 100644 --- a/src/ui/widget/font-variants.h +++ b/src/ui/widget/font-variants.h @@ -13,6 +13,7 @@ #include #include #include +#include class SPDesktop; class SPObject; @@ -81,6 +82,11 @@ protected: Gtk::CheckButton _numeric_ordinal; Gtk::CheckButton _numeric_slashed_zero; + Gtk::Expander _feature_frame; + Gtk::VBox _feature_vbox; + Gtk::Entry _feature_entry; + Gtk::Label _feature_label; + private: void ligatures_init(); void ligatures_callback(); @@ -94,6 +100,9 @@ private: void numeric_init(); void numeric_callback(); + void feature_init(); + void feature_callback(); + // To determine if we need to write out property (may not be necessary) unsigned _ligatures_all; unsigned _position_all; @@ -109,6 +118,7 @@ private: bool _position_changed; bool _caps_changed; bool _numeric_changed; + bool _feature_changed; sigc::signal _changed_signal; @@ -117,7 +127,7 @@ public: /** * Update GUI based on query results. */ - void update( SPStyle const *query ); + void update( SPStyle const *query, bool different_features ); /** * Fill SPCSSAttr based on settings of buttons. -- cgit v1.2.3