summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/Makefile_insert6
-rw-r--r--src/ui/widget/font-variants.cpp375
-rw-r--r--src/ui/widget/font-variants.h137
3 files changed, 516 insertions, 2 deletions
diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert
index d56946745..eb98e6872 100644
--- a/src/ui/widget/Makefile_insert
+++ b/src/ui/widget/Makefile_insert
@@ -33,8 +33,10 @@ ink_common_sources += \
ui/widget/entry.h \
ui/widget/filter-effect-chooser.h \
ui/widget/filter-effect-chooser.cpp \
- ui/widget/gimpspinscale.c \
- ui/widget/gimpspinscale.h \
+ ui/widget/font-variants.h \
+ ui/widget/font-variants.cpp \
+ ui/widget/gimpspinscale.c \
+ ui/widget/gimpspinscale.h \
ui/widget/gimpcolorwheel.c \
ui/widget/gimpcolorwheel.h \
ui/widget/frame.cpp \
diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp
new file mode 100644
index 000000000..8ca926d8f
--- /dev/null
+++ b/src/ui/widget/font-variants.cpp
@@ -0,0 +1,375 @@
+/*
+ * Author:
+ * Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Copyright (C) 2015 Tavmong Bah
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtkmm.h>
+#include <glibmm/i18n.h>
+
+#include <iostream>
+
+#include "font-variants.h"
+
+// For updating from selection
+#include "desktop.h"
+#include "selection.h"
+#include "style.h"
+#include "sp-text.h"
+#include "sp-tspan.h"
+#include "sp-tref.h"
+#include "sp-textpath.h"
+#include "sp-item-group.h"
+#include "xml/repr.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+ FontVariants::FontVariants () :
+ Gtk::VBox (),
+ _ligatures_frame ( Glib::ustring(_("Ligatures" )) ),
+ _ligatures_common ( Glib::ustring(_("Common" )) ),
+ _ligatures_discretionary ( Glib::ustring(_("Discretionary")) ),
+ _ligatures_historical ( Glib::ustring(_("Historical" )) ),
+ _ligatures_contextual ( Glib::ustring(_("Contextual" )) ),
+
+ _position_frame ( Glib::ustring(_("Position" )) ),
+ _position_normal ( Glib::ustring(_("Normal" )) ),
+ _position_sub ( Glib::ustring(_("Subscript" )) ),
+ _position_super ( Glib::ustring(_("Superscript" )) ),
+
+ _caps_frame ( Glib::ustring(_("Capitals" )) ),
+ _caps_normal ( Glib::ustring(_("Normal" )) ),
+ _caps_small ( Glib::ustring(_("Small" )) ),
+ _caps_all_small ( Glib::ustring(_("All small" )) ),
+ _caps_petite ( Glib::ustring(_("Petite" )) ),
+ _caps_all_petite ( Glib::ustring(_("All petite" )) ),
+ _caps_unicase ( Glib::ustring(_("Unicase" )) ),
+ _caps_titling ( Glib::ustring(_("Titling" )) ),
+
+ _numeric_frame ( Glib::ustring(_("Numeric" )) ),
+ _numeric_lining ( Glib::ustring(_("Lining" )) ),
+ _numeric_old_style ( Glib::ustring(_("Old Style" )) ),
+ _numeric_default_style ( Glib::ustring(_("Default Style")) ),
+ _numeric_proportional ( Glib::ustring(_("Proportional" )) ),
+ _numeric_tabular ( Glib::ustring(_("Tabular" )) ),
+ _numeric_default_width ( Glib::ustring(_("Default Width")) ),
+ _numeric_diagonal ( Glib::ustring(_("Diagonal" )) ),
+ _numeric_stacked ( Glib::ustring(_("Stacked" )) ),
+ _numeric_default_fractions( Glib::ustring(_("Default Fractions")) ),
+ _numeric_ordinal ( Glib::ustring(_("Ordinal" )) ),
+ _numeric_slashed_zero ( Glib::ustring(_("Slashed Zero" )) ),
+
+ _ligatures_changed( false ),
+ _position_changed( false ),
+ _caps_changed( false ),
+ _numeric_changed( false )
+
+ {
+
+ // Ligatures --------------------------
+ _ligatures_common.set_tooltip_text(
+ _("Common ligatures. On by default. OpenType tables: 'liga', 'clig'"));
+ _ligatures_discretionary.set_tooltip_text(
+ _("Discretionary ligatures. Off by default. OpenType table: 'dlig'"));
+ _ligatures_historical.set_tooltip_text(
+ _("Historical ligatures. Off by default. OpenType table: 'hlig'"));
+ _ligatures_contextual.set_tooltip_text(
+ _("Contextual forms. On by default. OpenType table: 'calt'"));
+
+
+ _ligatures_common.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_discretionary.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_historical.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_contextual.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_vbox.add( _ligatures_common );
+ _ligatures_vbox.add( _ligatures_discretionary );
+ _ligatures_vbox.add( _ligatures_historical );
+ _ligatures_vbox.add( _ligatures_contextual );
+ _ligatures_frame.add( _ligatures_vbox );
+ add( _ligatures_frame );
+
+ ligatures_init();
+
+ // Position ----------------------------------
+ _position_vbox.add( _position_normal );
+ _position_vbox.add( _position_sub );
+ _position_vbox.add( _position_super );
+ _position_frame.add( _position_vbox );
+ add( _position_frame );
+
+ // Group buttons
+ Gtk::RadioButton::Group position_group = _position_normal.get_group();
+ _position_sub.set_group(position_group);
+ _position_super.set_group(position_group);
+ _position_normal.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
+ _position_sub.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
+ _position_super.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
+
+ position_init();
+
+ // Caps ----------------------------------
+ _caps_vbox.add( _caps_normal );
+ _caps_vbox.add( _caps_small );
+ _caps_vbox.add( _caps_all_small );
+ _caps_vbox.add( _caps_petite );
+ _caps_vbox.add( _caps_all_petite );
+ _caps_vbox.add( _caps_unicase );
+ _caps_vbox.add( _caps_titling );
+ _caps_frame.add( _caps_vbox );
+ add( _caps_frame );
+
+ // Group buttons
+ Gtk::RadioButton::Group caps_group = _caps_normal.get_group();
+ _caps_small.set_group(caps_group);
+ _caps_all_small.set_group(caps_group);
+ _caps_petite.set_group(caps_group);
+ _caps_all_petite.set_group(caps_group);
+ _caps_unicase.set_group(caps_group);
+ _caps_titling.set_group(caps_group);
+ _caps_normal.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_small.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_all_small.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_petite.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_all_petite.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_unicase.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_titling.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+
+ caps_init();
+
+ // Numeric ------------------------------
+ _numeric_stylebox.add( _numeric_default_style );
+ _numeric_stylebox.add( _numeric_lining );
+ _numeric_stylebox.add( _numeric_old_style );
+ _numeric_vbox.add( _numeric_stylebox );
+ _numeric_widthbox.add( _numeric_default_width );
+ _numeric_widthbox.add( _numeric_proportional );
+ _numeric_widthbox.add( _numeric_tabular );
+ _numeric_vbox.add( _numeric_widthbox );
+ _numeric_fractionbox.add( _numeric_default_fractions );
+ _numeric_fractionbox.add( _numeric_diagonal );
+ _numeric_fractionbox.add( _numeric_stacked );
+ _numeric_vbox.add( _numeric_fractionbox );
+ _numeric_vbox.add( _numeric_ordinal );
+ _numeric_vbox.add( _numeric_slashed_zero );
+ _numeric_frame.add( _numeric_vbox );
+ add( _numeric_frame );
+
+ // Group buttons
+ Gtk::RadioButton::Group style_group = _numeric_default_style.get_group();
+ _numeric_lining.set_group(style_group);
+ _numeric_old_style.set_group(style_group);
+
+ Gtk::RadioButton::Group width_group = _numeric_default_width.get_group();
+ _numeric_proportional.set_group(width_group);
+ _numeric_tabular.set_group(width_group);
+
+ Gtk::RadioButton::Group fraction_group = _numeric_default_fractions.get_group();
+ _numeric_diagonal.set_group(fraction_group);
+ _numeric_stacked.set_group(fraction_group);
+
+ show_all_children();
+ }
+
+ void
+ FontVariants::ligatures_init() {
+ // std::cout << "FontVariants::ligatures_init()" << std::endl;
+ }
+
+ void
+ FontVariants::ligatures_callback() {
+ // std::cout << "FontVariants::ligatures_callback()" << std::endl;
+ _ligatures_changed = true;
+ }
+
+ void
+ FontVariants::position_init() {
+ // std::cout << "FontVariants::position_init()" << std::endl;
+ }
+
+ void
+ FontVariants::position_callback() {
+ // std::cout << "FontVariants::position_callback()" << std::endl;
+ _position_changed = true;
+ }
+
+ void
+ FontVariants::caps_init() {
+ // std::cout << "FontVariants::caps_init()" << std::endl;
+ }
+
+ void
+ FontVariants::caps_callback() {
+ // std::cout << "FontVariants::caps_callback()" << std::endl;
+ _caps_changed = true;
+ }
+
+ void
+ FontVariants::numeric_init() {
+ std::cout << "FontVariants::numeric_init()" << std::endl;
+ // _numeric_tabular.set_inconsistent();
+ }
+
+ void
+ FontVariants::numeric_callback() {
+ // std::cout << "FontVariants::numeric_callback()" << std::endl;
+ _numeric_changed = true;
+ }
+
+ // Update GUI based on query.
+ void
+ FontVariants::update( SPStyle const *query ) {
+ // std::cout << "FontVariants::update" << std::endl;
+
+ _ligatures_all = query->font_variant_ligatures.computed;
+ _ligatures_mix = query->font_variant_ligatures.value;
+
+ _ligatures_common.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
+ _ligatures_discretionary.set_active(_ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
+ _ligatures_historical.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
+ _ligatures_contextual.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
+
+ _ligatures_common.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
+ _ligatures_discretionary.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
+ _ligatures_historical.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
+ _ligatures_contextual.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
+
+ _position_all = query->font_variant_position.computed;
+ _position_mix = query->font_variant_position.value;
+
+ _position_normal.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_NORMAL );
+ _position_sub.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_SUB );
+ _position_super.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_SUPER );
+
+ _position_normal.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_NORMAL );
+ _position_sub.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_SUB );
+ _position_super.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_SUPER );
+
+ unsigned _caps_all = query->font_variant_caps.computed;
+ unsigned _caps_mix = query->font_variant_caps.value;
+
+ _caps_normal.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_NORMAL );
+ _caps_small.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_SMALL );
+ _caps_all_small.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL );
+ _caps_petite.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_PETITE );
+ _caps_all_petite.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE );
+ _caps_unicase.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_UNICASE );
+ _caps_titling.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_TITLING );
+
+ _caps_normal.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_NORMAL );
+ _caps_small.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_SMALL );
+ _caps_all_small.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL );
+ _caps_petite.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_PETITE );
+ _caps_all_petite.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE );
+ _caps_unicase.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_UNICASE );
+ _caps_titling.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_TITLING );
+
+ _ligatures_changed = false;
+ _position_changed = false;
+ _caps_changed = false;
+ _numeric_changed = false;
+ }
+
+ void
+ FontVariants::fill_css( SPCSSAttr *css ) {
+
+ // Ligatures
+ bool common = _ligatures_common.get_active();
+ bool discretionary = _ligatures_discretionary.get_active();
+ bool historical = _ligatures_historical.get_active();
+ bool contextual = _ligatures_contextual.get_active();
+
+ if( !common && !discretionary && !historical && !contextual ) {
+ sp_repr_css_set_property(css, "font-variant-ligatures", "none" );
+ } else if ( common && !discretionary && !historical && contextual ) {
+ sp_repr_css_set_property(css, "font-variant-ligatures", "normal" );
+ } else {
+ Glib::ustring css_string;
+ if ( !common )
+ css_string += "no-common-ligatures ";
+ if ( discretionary )
+ css_string += "discretionary-ligatures ";
+ if ( historical )
+ css_string += "historical-ligatures ";
+ if ( !contextual )
+ css_string += "no-contextual ";
+ sp_repr_css_set_property(css, "font-variant-ligatures", css_string.c_str() );
+ }
+
+ // Position
+ {
+ unsigned position_new = SP_CSS_FONT_VARIANT_POSITION_NORMAL;
+ Glib::ustring css_string;
+ if( _position_normal.get_active() ) {
+ css_string = "normal";
+ } else if( _position_sub.get_active() ) {
+ css_string = "sub";
+ position_new = SP_CSS_FONT_VARIANT_POSITION_SUB;
+ } else if( _position_super.get_active() ) {
+ css_string = "super";
+ position_new = SP_CSS_FONT_VARIANT_POSITION_SUPER;
+ }
+
+ // 'if' may not be necessary... need to test.
+ if( (_position_all != position_new) || ((_position_mix != 0) && _position_changed) ) {
+ sp_repr_css_set_property(css, "font-variant-position", css_string.c_str() );
+ }
+ }
+
+ // Caps
+ {
+ unsigned caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
+ Glib::ustring css_string;
+ if( _caps_normal.get_active() ) {
+ css_string = "normal";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
+ } else if( _caps_small.get_active() ) {
+ css_string = "small-caps";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_SMALL;
+ } else if( _caps_all_small.get_active() ) {
+ css_string = "all-small-caps";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL;
+ } else if( _caps_all_petite.get_active() ) {
+ css_string = "petite";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_PETITE;
+ } else if( _caps_all_petite.get_active() ) {
+ css_string = "all-petite";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE;
+ } else if( _caps_unicase.get_active() ) {
+ css_string = "unicase";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_UNICASE;
+ } else if( _caps_titling.get_active() ) {
+ css_string = "titling";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_TITLING;
+ }
+
+ // May not be necessary... need to test.
+ //if( (_caps_all != caps_new) || ((_caps_mix != 0) && _caps_changed) ) {
+ sp_repr_css_set_property(css, "font-variant-caps", css_string.c_str() );
+ //}
+ }
+
+ }
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/font-variants.h b/src/ui/widget/font-variants.h
new file mode 100644
index 000000000..04c05d3c6
--- /dev/null
+++ b/src/ui/widget/font-variants.h
@@ -0,0 +1,137 @@
+/*
+ * Author:
+ * Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Copyright (C) 2015 Tavmong Bah
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_WIDGET_FONT_VARIANT_H
+#define INKSCAPE_UI_WIDGET_FONT_VARIANT_H
+
+// Temp: both frame and expander
+#include <gtkmm/frame.h>
+#include <gtkmm/expander.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/radiobutton.h>
+
+class SPDesktop;
+class SPObject;
+class SPStyle;
+class SPCSSAttr;
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * A container for selecting font variants (OpenType Features).
+ */
+class FontVariants : public Gtk::VBox
+{
+
+public:
+
+ /**
+ * Constructor
+ */
+ FontVariants();
+
+protected:
+ // To start, use four check buttons.
+ Gtk::Expander _ligatures_frame;
+ Gtk::VBox _ligatures_vbox;
+ Gtk::CheckButton _ligatures_common;
+ Gtk::CheckButton _ligatures_discretionary;
+ Gtk::CheckButton _ligatures_historical;
+ Gtk::CheckButton _ligatures_contextual;
+
+ // Exclusive options
+ Gtk::Expander _position_frame;
+ Gtk::VBox _position_vbox;
+ Gtk::RadioButton _position_normal;
+ Gtk::RadioButton _position_sub;
+ Gtk::RadioButton _position_super;
+
+ // Exclusive options (maybe a dropdown menu to save space?)
+ Gtk::Expander _caps_frame;
+ Gtk::VBox _caps_vbox;
+ Gtk::RadioButton _caps_normal;
+ Gtk::RadioButton _caps_small;
+ Gtk::RadioButton _caps_all_small;
+ Gtk::RadioButton _caps_petite;
+ Gtk::RadioButton _caps_all_petite;
+ Gtk::RadioButton _caps_unicase;
+ Gtk::RadioButton _caps_titling;
+
+ // Complicated!
+ Gtk::Expander _numeric_frame;
+ Gtk::VBox _numeric_vbox;
+ Gtk::HBox _numeric_stylebox;
+ Gtk::RadioButton _numeric_lining;
+ Gtk::RadioButton _numeric_old_style;
+ Gtk::RadioButton _numeric_default_style;
+ Gtk::HBox _numeric_widthbox;
+ Gtk::RadioButton _numeric_proportional;
+ Gtk::RadioButton _numeric_tabular;
+ Gtk::RadioButton _numeric_default_width;
+ Gtk::HBox _numeric_fractionbox;
+ Gtk::RadioButton _numeric_diagonal;
+ Gtk::RadioButton _numeric_stacked;
+ Gtk::RadioButton _numeric_default_fractions;
+ Gtk::CheckButton _numeric_ordinal;
+ Gtk::CheckButton _numeric_slashed_zero;
+
+private:
+ void ligatures_init();
+ void ligatures_callback();
+
+ void position_init();
+ void position_callback();
+
+ void caps_init();
+ void caps_callback();
+
+ void numeric_init();
+ void numeric_callback();
+
+ // To determine if we need to write out property (may not be necessary)
+ unsigned _ligatures_all;
+ unsigned _position_all;
+ unsigned _caps_all;
+ unsigned _numeric_all;
+
+ unsigned _ligatures_mix;
+ unsigned _position_mix;
+ unsigned _caps_mix;
+ unsigned _numeric_mix;
+
+ bool _ligatures_changed;
+ bool _position_changed;
+ bool _caps_changed;
+ bool _numeric_changed;
+
+public:
+ void update( SPStyle const *query );
+
+ void fill_css( SPCSSAttr* css );
+};
+
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_WIDGET_FONT_VARIANT_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :