1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Author: 4 * Felipe Corrêa da Silva Sanches <juca@members.fsf.org> 5 * Tavmjong Bah <tavmjong@free.fr> 6 * 7 * Copyright (C) 2018 Felipe Corrêa da Silva Sanches, Tavmong Bah 8 * 9 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 10 */ 11 12 #ifndef INKSCAPE_UI_WIDGET_FONT_VARIATIONS_H 13 #define INKSCAPE_UI_WIDGET_FONT_VARIATIONS_H 14 15 #include <gtkmm/grid.h> 16 #include <gtkmm/sizegroup.h> 17 #include <gtkmm/label.h> 18 #include <gtkmm/scale.h> 19 20 #include "libnrtype/OpenTypeUtil.h" 21 22 #include "style.h" 23 24 namespace Inkscape { 25 namespace UI { 26 namespace Widget { 27 28 29 /** 30 * A widget for a single axis: Label and Slider 31 */ 32 class FontVariationAxis : public Gtk::Grid 33 { 34 public: 35 FontVariationAxis(Glib::ustring name, OTVarAxis& axis); get_name()36 Glib::ustring get_name() { return name; } get_label()37 Gtk::Label* get_label() { return label; } get_value()38 double get_value() { return scale->get_value(); } get_precision()39 int get_precision() { return precision; } get_scale()40 Gtk::Scale* get_scale() { return scale; } get_def()41 double get_def() { return def; } 42 43 private: 44 45 // Widgets 46 Glib::ustring name; 47 Gtk::Label* label; 48 Gtk::Scale* scale; 49 50 int precision; 51 double def = 0.0; // Default value 52 53 // Signals 54 sigc::signal<void> signal_changed; 55 }; 56 57 /** 58 * A widget for selecting font variations (OpenType Variations). 59 */ 60 class FontVariations : public Gtk::Grid 61 { 62 63 public: 64 65 /** 66 * Constructor 67 */ 68 FontVariations(); 69 70 protected: 71 72 public: 73 74 /** 75 * Update GUI. 76 */ 77 void update(const Glib::ustring& font_spec); 78 79 /** 80 * Fill SPCSSAttr based on settings of buttons. 81 */ 82 void fill_css( SPCSSAttr* css ); 83 84 /** 85 * Get CSS String 86 */ 87 Glib::ustring get_css_string(); 88 89 Glib::ustring get_pango_string(); 90 91 void on_variations_change(); 92 93 /** 94 * Let others know that user has changed GUI settings. 95 * (Used to enable 'Apply' and 'Default' buttons.) 96 */ connectChanged(sigc::slot<void> slot)97 sigc::connection connectChanged(sigc::slot<void> slot) { 98 return signal_changed.connect(slot); 99 } 100 101 // return true if there are some variations present 102 bool variations_present() const; 103 104 private: 105 106 std::vector<FontVariationAxis*> axes; 107 Glib::RefPtr<Gtk::SizeGroup> size_group; 108 109 sigc::signal<void> signal_changed; 110 }; 111 112 113 } // namespace Widget 114 } // namespace UI 115 } // namespace Inkscape 116 117 #endif // INKSCAPE_UI_WIDGET_FONT_VARIATIONS_H 118 119 /* 120 Local Variables: 121 mode:c++ 122 c-file-style:"stroustrup" 123 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 124 indent-tabs-mode:nil 125 fill-column:99 126 End: 127 */ 128 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : 129