1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Author: 4 * Tavmjong Bah <tavmjong@free.fr> 5 * 6 * Copyright (C) 2015, 2018 Tavmong Bah 7 * 8 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 9 */ 10 11 #ifndef INKSCAPE_UI_WIDGET_FONT_VARIANT_H 12 #define INKSCAPE_UI_WIDGET_FONT_VARIANT_H 13 14 #include <gtkmm/expander.h> 15 #include <gtkmm/checkbutton.h> 16 #include <gtkmm/radiobutton.h> 17 #include <gtkmm/entry.h> 18 #include <gtkmm/grid.h> 19 #include <gtkmm/hvbox.h> 20 21 class SPDesktop; 22 class SPObject; 23 class SPStyle; 24 class SPCSSAttr; 25 26 namespace Inkscape { 27 namespace UI { 28 namespace Widget { 29 30 class Feature; 31 32 /** 33 * A container for selecting font variants (OpenType Features). 34 */ 35 class FontVariants : public Gtk::Box 36 { 37 38 public: 39 40 /** 41 * Constructor 42 */ 43 FontVariants(); 44 45 protected: 46 // Ligatures: To start, use four check buttons. 47 Gtk::Expander _ligatures_frame; 48 Gtk::Grid _ligatures_grid; 49 Gtk::CheckButton _ligatures_common; 50 Gtk::CheckButton _ligatures_discretionary; 51 Gtk::CheckButton _ligatures_historical; 52 Gtk::CheckButton _ligatures_contextual; 53 Gtk::Label _ligatures_label_common; 54 Gtk::Label _ligatures_label_discretionary; 55 Gtk::Label _ligatures_label_historical; 56 Gtk::Label _ligatures_label_contextual; 57 58 // Position: Exclusive options 59 Gtk::Expander _position_frame; 60 Gtk::Grid _position_grid; 61 Gtk::RadioButton _position_normal; 62 Gtk::RadioButton _position_sub; 63 Gtk::RadioButton _position_super; 64 65 // Caps: Exclusive options (maybe a dropdown menu to save space?) 66 Gtk::Expander _caps_frame; 67 Gtk::Grid _caps_grid; 68 Gtk::RadioButton _caps_normal; 69 Gtk::RadioButton _caps_small; 70 Gtk::RadioButton _caps_all_small; 71 Gtk::RadioButton _caps_petite; 72 Gtk::RadioButton _caps_all_petite; 73 Gtk::RadioButton _caps_unicase; 74 Gtk::RadioButton _caps_titling; 75 76 // Numeric: Complicated! 77 Gtk::Expander _numeric_frame; 78 Gtk::Grid _numeric_grid; 79 80 Gtk::RadioButton _numeric_default_style; 81 Gtk::RadioButton _numeric_lining; 82 Gtk::Label _numeric_lining_label; 83 Gtk::RadioButton _numeric_old_style; 84 Gtk::Label _numeric_old_style_label; 85 86 Gtk::RadioButton _numeric_default_width; 87 Gtk::RadioButton _numeric_proportional; 88 Gtk::Label _numeric_proportional_label; 89 Gtk::RadioButton _numeric_tabular; 90 Gtk::Label _numeric_tabular_label; 91 92 Gtk::RadioButton _numeric_default_fractions; 93 Gtk::RadioButton _numeric_diagonal; 94 Gtk::Label _numeric_diagonal_label; 95 Gtk::RadioButton _numeric_stacked; 96 Gtk::Label _numeric_stacked_label; 97 98 Gtk::CheckButton _numeric_ordinal; 99 Gtk::Label _numeric_ordinal_label; 100 101 Gtk::CheckButton _numeric_slashed_zero; 102 Gtk::Label _numeric_slashed_zero_label; 103 104 // East Asian: Complicated! 105 Gtk::Expander _asian_frame; 106 Gtk::Grid _asian_grid; 107 108 Gtk::RadioButton _asian_default_variant; 109 Gtk::RadioButton _asian_jis78; 110 Gtk::RadioButton _asian_jis83; 111 Gtk::RadioButton _asian_jis90; 112 Gtk::RadioButton _asian_jis04; 113 Gtk::RadioButton _asian_simplified; 114 Gtk::RadioButton _asian_traditional; 115 116 Gtk::RadioButton _asian_default_width; 117 Gtk::RadioButton _asian_full_width; 118 Gtk::RadioButton _asian_proportional_width; 119 120 Gtk::CheckButton _asian_ruby; 121 122 // ----- 123 Gtk::Expander _feature_frame; 124 Gtk::Grid _feature_grid; 125 Gtk::Box _feature_vbox; 126 Gtk::Entry _feature_entry; 127 Gtk::Label _feature_label; 128 Gtk::Label _feature_list; 129 Gtk::Label _feature_substitutions; 130 131 private: 132 void ligatures_init(); 133 void ligatures_callback(); 134 135 void position_init(); 136 void position_callback(); 137 138 void caps_init(); 139 void caps_callback(); 140 141 void numeric_init(); 142 void numeric_callback(); 143 144 void asian_init(); 145 void asian_callback(); 146 147 void feature_init(); 148 public: 149 void feature_callback(); 150 151 private: 152 // To determine if we need to write out property (may not be necessary) 153 unsigned _ligatures_all; 154 unsigned _position_all; 155 unsigned _caps_all; 156 unsigned _numeric_all; 157 unsigned _asian_all; 158 159 unsigned _ligatures_mix; 160 unsigned _position_mix; 161 unsigned _caps_mix; 162 unsigned _numeric_mix; 163 unsigned _asian_mix; 164 165 bool _ligatures_changed; 166 bool _position_changed; 167 bool _caps_changed; 168 bool _numeric_changed; 169 bool _feature_changed; 170 bool _asian_changed; 171 172 std::map<std::string, Feature*> _features; 173 174 sigc::signal<void> _changed_signal; 175 176 public: 177 178 /** 179 * Update GUI based on query results. 180 */ 181 void update( SPStyle const *query, bool different_features, Glib::ustring& font_spec ); 182 183 /** 184 * Update GUI based on OpenType features of selected font. 185 */ 186 void update_opentype( Glib::ustring& font_spec ); 187 188 /** 189 * Fill SPCSSAttr based on settings of buttons. 190 */ 191 void fill_css( SPCSSAttr* css ); 192 193 /** 194 * Get CSS string for markup. 195 */ 196 Glib::ustring get_markup(); 197 198 /** 199 * Let others know that user has changed GUI settings. 200 * (Used to enable 'Apply' and 'Default' buttons.) 201 */ connectChanged(sigc::slot<void> slot)202 sigc::connection connectChanged(sigc::slot<void> slot) { 203 return _changed_signal.connect(slot); 204 } 205 }; 206 207 208 } // namespace Widget 209 } // namespace UI 210 } // namespace Inkscape 211 212 #endif // INKSCAPE_UI_WIDGET_FONT_VARIANT_H 213 214 /* 215 Local Variables: 216 mode:c++ 217 c-file-style:"stroustrup" 218 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 219 indent-tabs-mode:nil 220 fill-column:99 221 End: 222 */ 223 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : 224