From a5d6c9a27683820be3d84eea73c2d6f161ce0e8e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 24 Jul 2016 18:49:11 +0200 Subject: Add Text tag and update widgets code (bzr r15017.1.2) --- src/ui/widget/Makefile_insert | 2 + src/ui/widget/font-selector.cpp | 115 ++++++++++++++++++++++++++++++++++++ src/ui/widget/font-selector.h | 81 +++++++++++++++++++++++++ src/ui/widget/registered-widget.cpp | 44 ++++++++++++++ src/ui/widget/registered-widget.h | 18 ++++++ 5 files changed, 260 insertions(+) create mode 100644 src/ui/widget/font-selector.cpp create mode 100644 src/ui/widget/font-selector.h (limited to 'src/ui/widget') diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index eb98e6872..bb833e5ec 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -33,6 +33,8 @@ ink_common_sources += \ ui/widget/entry.h \ ui/widget/filter-effect-chooser.h \ ui/widget/filter-effect-chooser.cpp \ + ui/widget/font-selector.h \ + ui/widget/font-selector.cpp \ ui/widget/font-variants.h \ ui/widget/font-variants.cpp \ ui/widget/gimpspinscale.c \ diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp new file mode 100644 index 000000000..77bf83fe1 --- /dev/null +++ b/src/ui/widget/font-selector.cpp @@ -0,0 +1,115 @@ +/* + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "font-selector.h" +#include "widgets/icon.h" +#include + +namespace Inkscape { +namespace UI { +namespace Widget { + +FontSelector::FontSelector(Glib::ustring const &label, Glib::ustring const &tooltip, + Glib::ustring const &suffix, + Glib::ustring const &icon, + bool mnemonic) + :_widget(new Gtk::HBox()), expanded(true) +{ + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); + GtkWidget *fontsel = sp_font_selector_new(); + gtk_widget_set_size_request (fontsel, 290, 150); + fsel = SP_FONT_SELECTOR(fontsel); + Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "on", Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &FontSelector::onFontSelectorSave)); + pButton->set_tooltip_text(_("Save the changes to font selector")); + vbox_expander->pack_start(*Gtk::manage(Glib::wrap(fontsel)), true, true); + vbox_expander->pack_start(*pButton, true, true); + expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Font Selector:")))); + expander->add(*vbox_expander); + expander->set_expanded(expanded); + expander->set_spacing(5); + expander->set_use_markup(true); + onExpanderChanged(); + _widget->set_tooltip_text(tooltip); + expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &FontSelector::onExpanderChanged) ); + pack_start(*expander, true, true); + pack_start(*Gtk::manage(_widget), true, true); +} + +void +FontSelector::onExpanderChanged() +{ + expanded = expander->get_expanded(); + if(expanded) { + expander->set_label (Glib::ustring(_("Font Selector:"))); + } else { + expander->set_label (Glib::ustring(_("Font Selector: hided"))); + } +} + +Glib::ustring FontSelector::getFontSpec() const +{ + return _fontspec; +} + +void FontSelector::setFontSpec(Glib::ustring fontspec) +{ + _fontspec = fontspec; +} + +double FontSelector::getFontSize() const +{ + return _fontsize; +} + +void FontSelector::setFontSize(double fontsize) +{ + _fontsize = fontsize; +} + +void FontSelector::setValue (Glib::ustring fontspec, double fontsize) +{ + if (_fontsize != fontsize || _fontspec != fontspec) { + setFontSize(fontsize); + setFontSpec(fontspec); + sp_font_selector_set_fontspec(fsel, fontspec, fontsize); + } +} + +void +FontSelector::onFontSelectorSave() +{ + if (_fontspec != sp_font_selector_get_fontspec(fsel) || _fontsize != sp_font_selector_get_size(fsel)) { + setFontSpec(sp_font_selector_get_fontspec(fsel)); + setFontSize(sp_font_selector_get_size(fsel)); + signal_fontselupd.emit(); + onExpanderChanged(); + } +} + + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + 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-selector.h b/src/ui/widget/font-selector.h new file mode 100644 index 000000000..cfea54bde --- /dev/null +++ b/src/ui/widget/font-selector.h @@ -0,0 +1,81 @@ +/* + * + * Copyright (C) 2007 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_FONT_SELECTOR_H +#define INKSCAPE_UI_WIDGET_FONT_SELECTOR_H + +#include +#include "widgets/font-selector.h" + +struct SPFontSelector; +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary number values. It adds an extra + * number called "startseed", that is not UI edittable, but should be put in SVG. + * This does NOT generate a random number, but provides merely the saving of + * the startseed value. + */ +class FontSelector : public Gtk::HBox +{ +public: + + /** + * Construct a FontSelector Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ + FontSelector( Glib::ustring const &label, + Glib::ustring const &tooltip, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + + Glib::ustring getFontSpec() const; + void onExpanderChanged(); + void setFontSpec(Glib::ustring fontspec); + double getFontSize() const; + void setFontSize(double fontsize); + void setValue (Glib::ustring fontspec, double fontsize); + sigc::signal signal_fontselupd; + +protected: + Gtk::Widget *_widget; + bool expanded; + Gtk::Expander * expander; + SPFontSelector *fsel; + Glib::ustring _fontspec; + double _fontsize; + +private: + void onFontSelectorSave(); +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_RANDOM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + 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/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 298377af3..7abab25c9 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -25,6 +25,7 @@ #include "ui/widget/scalar-unit.h" #include "ui/widget/point.h" #include "ui/widget/random.h" +#include "ui/widget/font-selector.h" #include "widgets/spinbutton-events.h" #include "xml/repr.h" @@ -805,6 +806,49 @@ RegisteredRandom::on_value_changed() _wr->setUpdating (false); } +/*######################################### + * Registered FONT-SELECTOR + */ + +RegisteredFontSelector::~RegisteredFontSelector() +{ + _value_changed_connection.disconnect(); +} + +RegisteredFontSelector::RegisteredFontSelector ( const Glib::ustring& label, const Glib::ustring& tip, + const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, + SPDocument* doc_in ) + : RegisteredWidget (label, tip) +{ + init_parent(key, wr, repr_in, doc_in); + _value_changed_connection = signal_fontselupd.connect (sigc::mem_fun (*this, &RegisteredFontSelector::on_value_changed)); +} + +void +RegisteredFontSelector::setValue (Glib::ustring fontspec, double fontsize) +{ + if (fontsize != 0) { //have value in the effect + FontSelector::setValue (fontspec, fontsize); + } +} + +void +RegisteredFontSelector::on_value_changed() +{ + + if (_wr->isUpdating()) + return; + + _wr->setUpdating (true); + + Inkscape::SVGOStringStream os; + os << getFontSpec() << " @ " << getFontSize(); + + write_to_xml(os.str().c_str()); + + _wr->setUpdating (false); +} + } // namespace Dialog } // namespace UI } // namespace Inkscape diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 9d2489712..17c04de9f 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -22,6 +22,7 @@ #include "ui/widget/text.h" #include "ui/widget/random.h" #include "ui/widget/unit-menu.h" +#include "ui/widget/font-selector.h" #include "ui/widget/color-picker.h" #include "inkscape.h" @@ -419,6 +420,23 @@ protected: void on_value_changed(); }; +class RegisteredFontSelector : public RegisteredWidget { +public: + virtual ~RegisteredFontSelector(); + RegisteredFontSelector ( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + Registry& wr, + Inkscape::XML::Node* repr_in = NULL, + SPDocument *doc_in = NULL); + + void setValue (Glib::ustring fontspec, double fontsize); + +protected: + sigc::connection _value_changed_connection; + void on_value_changed(); +}; + } // namespace Widget } // namespace UI } // namespace Inkscape -- cgit v1.2.3 From d7bdf3ed2d198c0027babed217dfec32f5f4f389 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 26 Jul 2016 00:10:01 +0200 Subject: Add gap,offset,insensitive transforms, and delete on lpe remove (bzr r15017.1.6) --- src/ui/widget/font-selector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp index 77bf83fe1..6b0bdca36 100644 --- a/src/ui/widget/font-selector.cpp +++ b/src/ui/widget/font-selector.cpp @@ -19,7 +19,7 @@ FontSelector::FontSelector(Glib::ustring const &label, Glib::ustring const &tool Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - :_widget(new Gtk::HBox()), expanded(true) + :_widget(new Gtk::HBox()), expanded(false) { Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); GtkWidget *fontsel = sp_font_selector_new(); -- cgit v1.2.3 From 5c04358b2fd79db36b8064ad5e7a9fd8bbe314bb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 28 Jul 2016 12:30:52 +0200 Subject: Finish linked path and add local number format (bzr r15017.1.9) --- src/ui/widget/font-selector.cpp | 8 ++++---- src/ui/widget/font-selector.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp index 6b0bdca36..0fcb307eb 100644 --- a/src/ui/widget/font-selector.cpp +++ b/src/ui/widget/font-selector.cpp @@ -19,7 +19,7 @@ FontSelector::FontSelector(Glib::ustring const &label, Glib::ustring const &tool Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - :_widget(new Gtk::HBox()), expanded(false) + :_widget(new Gtk::HBox()), expanded(false), _label(label) { Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); GtkWidget *fontsel = sp_font_selector_new(); @@ -35,7 +35,7 @@ FontSelector::FontSelector(Glib::ustring const &label, Glib::ustring const &tool pButton->set_tooltip_text(_("Save the changes to font selector")); vbox_expander->pack_start(*Gtk::manage(Glib::wrap(fontsel)), true, true); vbox_expander->pack_start(*pButton, true, true); - expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Font Selector:")))); + expander = Gtk::manage(new Gtk::Expander(label)); expander->add(*vbox_expander); expander->set_expanded(expanded); expander->set_spacing(5); @@ -52,9 +52,9 @@ FontSelector::onExpanderChanged() { expanded = expander->get_expanded(); if(expanded) { - expander->set_label (Glib::ustring(_("Font Selector:"))); + expander->set_label (Glib::ustring(_label)); } else { - expander->set_label (Glib::ustring(_("Font Selector: hided"))); + expander->set_label (Glib::ustring(_label + _(" hided"))); } } diff --git a/src/ui/widget/font-selector.h b/src/ui/widget/font-selector.h index cfea54bde..8146bc370 100644 --- a/src/ui/widget/font-selector.h +++ b/src/ui/widget/font-selector.h @@ -54,6 +54,7 @@ public: protected: Gtk::Widget *_widget; bool expanded; + Glib::ustring _label; Gtk::Expander * expander; SPFontSelector *fsel; Glib::ustring _fontspec; -- cgit v1.2.3 From 53500549df51879d6a7aaec5a0c8c37ca7087817 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 29 Jul 2016 20:28:00 +0200 Subject: Add orientation and alow unsort combobox enum widget (bzr r15017.1.12) --- src/ui/widget/combo-enums.h | 9 +++++---- src/ui/widget/registered-enums.h | 6 +++--- src/ui/widget/registered-widget.h | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/combo-enums.h b/src/ui/widget/combo-enums.h index 4678ab83b..e7524ac71 100644 --- a/src/ui/widget/combo-enums.h +++ b/src/ui/widget/combo-enums.h @@ -16,7 +16,6 @@ #include #include "attr-widget.h" #include "util/enums.h" - #include namespace Inkscape { @@ -190,9 +189,11 @@ public: const Util::EnumDataConverter& c, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", - bool mnemonic = true) - : Labelled(label, tooltip, new ComboBoxEnum(c), suffix, icon, mnemonic) - { } + bool mnemonic = true, + bool sorted = true) + : Labelled(label, tooltip, new ComboBoxEnum(c, SP_ATTR_INVALID, sorted), suffix, icon, mnemonic) + { + } ComboBoxEnum* getCombobox() { return static_cast< ComboBoxEnum* > (_widget); diff --git a/src/ui/widget/registered-enums.h b/src/ui/widget/registered-enums.h index 9e1682c7d..1d5074836 100644 --- a/src/ui/widget/registered-enums.h +++ b/src/ui/widget/registered-enums.h @@ -33,11 +33,11 @@ public: const Util::EnumDataConverter& c, Registry& wr, Inkscape::XML::Node* repr_in = NULL, - SPDocument *doc_in = NULL ) - : RegisteredWidget< LabelledComboBoxEnum >(label, tip, c) + SPDocument *doc_in = NULL, + bool sorted = true ) + : RegisteredWidget< LabelledComboBoxEnum >(label, tip, c, (const Glib::ustring &)"", (const Glib::ustring &)"", true, sorted) { RegisteredWidget< LabelledComboBoxEnum >::init_parent(key, wr, repr_in, doc_in); - _changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed)); } diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 3c8205058..2b4d98b88 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -78,6 +78,8 @@ protected: RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); } template< typename A, typename B, typename C, typename D, typename E , typename F> RegisteredWidget( A& a, B& b, C c, D& d, E& e, F* f): W( a, b, c, d, e, f) { construct(); } + template< typename A, typename B, typename C, typename D, typename E , typename F, typename G> + RegisteredWidget( A& a, B& b, C& c, D& d, E& e, F f, G& g): W( a, b, c, d, e, f, g) { construct(); } virtual ~RegisteredWidget() {}; -- cgit v1.2.3 From d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 30 Jul 2016 01:44:17 +0200 Subject: Remove font-Dialog and useGtk::FontSelector instead (bzr r15017.1.13) --- src/ui/widget/Makefile_insert | 4 +- src/ui/widget/font-button.cpp | 58 ++++++++++++++++++ src/ui/widget/font-button.h | 63 ++++++++++++++++++++ src/ui/widget/font-selector.cpp | 115 ------------------------------------ src/ui/widget/font-selector.h | 82 ------------------------- src/ui/widget/registered-widget.cpp | 24 ++++---- src/ui/widget/registered-widget.h | 12 ++-- 7 files changed, 140 insertions(+), 218 deletions(-) create mode 100644 src/ui/widget/font-button.cpp create mode 100644 src/ui/widget/font-button.h delete mode 100644 src/ui/widget/font-selector.cpp delete mode 100644 src/ui/widget/font-selector.h (limited to 'src/ui/widget') diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index bb833e5ec..b5d8a74f6 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -33,8 +33,8 @@ ink_common_sources += \ ui/widget/entry.h \ ui/widget/filter-effect-chooser.h \ ui/widget/filter-effect-chooser.cpp \ - ui/widget/font-selector.h \ - ui/widget/font-selector.cpp \ + ui/widget/font-button.h \ + ui/widget/font-button.cpp \ ui/widget/font-variants.h \ ui/widget/font-variants.cpp \ ui/widget/gimpspinscale.c \ diff --git a/src/ui/widget/font-button.cpp b/src/ui/widget/font-button.cpp new file mode 100644 index 000000000..2c79347b2 --- /dev/null +++ b/src/ui/widget/font-button.cpp @@ -0,0 +1,58 @@ +/* + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "font-button.h" +#include + +namespace Inkscape { +namespace UI { +namespace Widget { + +FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip, + Glib::ustring const &suffix, + Glib::ustring const &icon, + bool mnemonic) + : Labelled(label, tooltip, new Gtk::FontButton("sans"), suffix, icon, mnemonic) +{ +} + +Glib::ustring FontButton::getValue() const +{ + g_assert(_widget != NULL); + return static_cast(_widget)->get_font_name(); +} + + +void FontButton::setValue (Glib::ustring fontspec) +{ + g_assert(_widget != NULL); + static_cast(_widget)->set_font_name(fontspec); +} + +Glib::SignalProxy0 FontButton::signal_font_value_changed() +{ + g_assert(_widget != NULL); + return static_cast(_widget)->signal_font_set(); +} + + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + 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-button.h b/src/ui/widget/font-button.h new file mode 100644 index 000000000..1f1ad2d01 --- /dev/null +++ b/src/ui/widget/font-button.h @@ -0,0 +1,63 @@ +/* + * + * Copyright (C) 2007 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_FONT_BUTTON_H +#define INKSCAPE_UI_WIDGET_FONT_BUTTON_H + +#include +#include "labelled.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * A labelled font button for entering font values + */ +class FontButton : public Labelled +{ +public: + /** + * Construct a FontButton Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ + FontButton( Glib::ustring const &label, + Glib::ustring const &tooltip, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + + Glib::ustring getValue() const; + void setValue (Glib::ustring fontspec); + /** + * Signal raised when the font button's value changes. + */ + Glib::SignalProxy0 signal_font_value_changed(); +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_RANDOM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + 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-selector.cpp b/src/ui/widget/font-selector.cpp deleted file mode 100644 index 0fcb307eb..000000000 --- a/src/ui/widget/font-selector.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "font-selector.h" -#include "widgets/icon.h" -#include - -namespace Inkscape { -namespace UI { -namespace Widget { - -FontSelector::FontSelector(Glib::ustring const &label, Glib::ustring const &tooltip, - Glib::ustring const &suffix, - Glib::ustring const &icon, - bool mnemonic) - :_widget(new Gtk::HBox()), expanded(false), _label(label) -{ - Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); - GtkWidget *fontsel = sp_font_selector_new(); - gtk_widget_set_size_request (fontsel, 290, 150); - fsel = SP_FONT_SELECTOR(fontsel); - Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "on", Inkscape::ICON_SIZE_BUTTON) ); - Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &FontSelector::onFontSelectorSave)); - pButton->set_tooltip_text(_("Save the changes to font selector")); - vbox_expander->pack_start(*Gtk::manage(Glib::wrap(fontsel)), true, true); - vbox_expander->pack_start(*pButton, true, true); - expander = Gtk::manage(new Gtk::Expander(label)); - expander->add(*vbox_expander); - expander->set_expanded(expanded); - expander->set_spacing(5); - expander->set_use_markup(true); - onExpanderChanged(); - _widget->set_tooltip_text(tooltip); - expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &FontSelector::onExpanderChanged) ); - pack_start(*expander, true, true); - pack_start(*Gtk::manage(_widget), true, true); -} - -void -FontSelector::onExpanderChanged() -{ - expanded = expander->get_expanded(); - if(expanded) { - expander->set_label (Glib::ustring(_label)); - } else { - expander->set_label (Glib::ustring(_label + _(" hided"))); - } -} - -Glib::ustring FontSelector::getFontSpec() const -{ - return _fontspec; -} - -void FontSelector::setFontSpec(Glib::ustring fontspec) -{ - _fontspec = fontspec; -} - -double FontSelector::getFontSize() const -{ - return _fontsize; -} - -void FontSelector::setFontSize(double fontsize) -{ - _fontsize = fontsize; -} - -void FontSelector::setValue (Glib::ustring fontspec, double fontsize) -{ - if (_fontsize != fontsize || _fontspec != fontspec) { - setFontSize(fontsize); - setFontSpec(fontspec); - sp_font_selector_set_fontspec(fsel, fontspec, fontsize); - } -} - -void -FontSelector::onFontSelectorSave() -{ - if (_fontspec != sp_font_selector_get_fontspec(fsel) || _fontsize != sp_font_selector_get_size(fsel)) { - setFontSpec(sp_font_selector_get_fontspec(fsel)); - setFontSize(sp_font_selector_get_size(fsel)); - signal_fontselupd.emit(); - onExpanderChanged(); - } -} - - -} // namespace Widget -} // namespace UI -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - 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-selector.h b/src/ui/widget/font-selector.h deleted file mode 100644 index 8146bc370..000000000 --- a/src/ui/widget/font-selector.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright (C) 2007 Author - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifndef INKSCAPE_UI_WIDGET_FONT_SELECTOR_H -#define INKSCAPE_UI_WIDGET_FONT_SELECTOR_H - -#include -#include "widgets/font-selector.h" - -struct SPFontSelector; -namespace Inkscape { -namespace UI { -namespace Widget { - -/** - * A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. It adds an extra - * number called "startseed", that is not UI edittable, but should be put in SVG. - * This does NOT generate a random number, but provides merely the saving of - * the startseed value. - */ -class FontSelector : public Gtk::HBox -{ -public: - - /** - * Construct a FontSelector Widget. - * - * @param label Label. - * @param suffix Suffix, placed after the widget (defaults to ""). - * @param icon Icon filename, placed before the label (defaults to ""). - * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ - FontSelector( Glib::ustring const &label, - Glib::ustring const &tooltip, - Glib::ustring const &suffix = "", - Glib::ustring const &icon = "", - bool mnemonic = true); - - Glib::ustring getFontSpec() const; - void onExpanderChanged(); - void setFontSpec(Glib::ustring fontspec); - double getFontSize() const; - void setFontSize(double fontsize); - void setValue (Glib::ustring fontspec, double fontsize); - sigc::signal signal_fontselupd; - -protected: - Gtk::Widget *_widget; - bool expanded; - Glib::ustring _label; - Gtk::Expander * expander; - SPFontSelector *fsel; - Glib::ustring _fontspec; - double _fontsize; - -private: - void onFontSelectorSave(); -}; - -} // namespace Widget -} // namespace UI -} // namespace Inkscape - -#endif // INKSCAPE_UI_WIDGET_RANDOM_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - 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/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index c58e599ee..38bb7f7cc 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -25,7 +25,7 @@ #include "ui/widget/scalar-unit.h" #include "ui/widget/point.h" #include "ui/widget/random.h" -#include "ui/widget/font-selector.h" +#include "ui/widget/font-button.h" #include "widgets/spinbutton-events.h" #include "xml/repr.h" @@ -805,33 +805,31 @@ RegisteredRandom::on_value_changed() } /*######################################### - * Registered FONT-SELECTOR + * Registered FONT-BUTTON */ -RegisteredFontSelector::~RegisteredFontSelector() +RegisteredFontButton::~RegisteredFontButton() { - _value_changed_connection.disconnect(); + _signal_font_set.disconnect(); } -RegisteredFontSelector::RegisteredFontSelector ( const Glib::ustring& label, const Glib::ustring& tip, +RegisteredFontButton::RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument* doc_in ) - : RegisteredWidget (label, tip) + : RegisteredWidget(label, tip) { init_parent(key, wr, repr_in, doc_in); - _value_changed_connection = signal_fontselupd.connect (sigc::mem_fun (*this, &RegisteredFontSelector::on_value_changed)); + _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed)); } void -RegisteredFontSelector::setValue (Glib::ustring fontspec, double fontsize) +RegisteredFontButton::setValue (Glib::ustring fontspec) { - if (fontsize != 0) { //have value in the effect - FontSelector::setValue (fontspec, fontsize); - } + FontButton::setValue(fontspec); } void -RegisteredFontSelector::on_value_changed() +RegisteredFontButton::on_value_changed() { if (_wr->isUpdating()) @@ -840,7 +838,7 @@ RegisteredFontSelector::on_value_changed() _wr->setUpdating (true); Inkscape::SVGOStringStream os; - os << getFontSpec() << " @ " << getFontSize(); + os << getValue(); write_to_xml(os.str().c_str()); diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 2b4d98b88..d410dbfe6 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -22,7 +22,7 @@ #include "ui/widget/text.h" #include "ui/widget/random.h" #include "ui/widget/unit-menu.h" -#include "ui/widget/font-selector.h" +#include "ui/widget/font-button.h" #include "ui/widget/color-picker.h" #include "inkscape.h" @@ -421,20 +421,20 @@ protected: void on_value_changed(); }; -class RegisteredFontSelector : public RegisteredWidget { +class RegisteredFontButton : public RegisteredWidget { public: - virtual ~RegisteredFontSelector(); - RegisteredFontSelector ( const Glib::ustring& label, + virtual ~RegisteredFontButton(); + RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in = NULL, SPDocument *doc_in = NULL); - void setValue (Glib::ustring fontspec, double fontsize); + void setValue (Glib::ustring fontspec); protected: - sigc::connection _value_changed_connection; + sigc::connection _signal_font_set; void on_value_changed(); }; -- cgit v1.2.3 From f391d1cb5c644cd325f64a88d6d3a9da73fdb9de Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 30 Jul 2016 02:50:36 +0200 Subject: Fixes positions of labels (bzr r15017.1.14) --- src/ui/widget/font-button.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/font-button.cpp b/src/ui/widget/font-button.cpp index 2c79347b2..a472ac6a4 100644 --- a/src/ui/widget/font-button.cpp +++ b/src/ui/widget/font-button.cpp @@ -18,7 +18,7 @@ FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::FontButton("sans"), suffix, icon, mnemonic) + : Labelled(label, tooltip, new Gtk::FontButton("Sans 10"), suffix, icon, mnemonic) { } -- cgit v1.2.3 From 7f16afbb515eceed9c63afacec73cd528a662327 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 30 Jul 2016 19:04:34 +0200 Subject: Full rewrite on working mode now no linked paths necesary (bzr r15017.1.15) --- src/ui/widget/registered-widget.cpp | 1 - src/ui/widget/scalar.cpp | 6 ++++-- src/ui/widget/scalar.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 38bb7f7cc..923949b72 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -298,7 +298,6 @@ RegisteredScalar::on_value_changed() setProgrammatically = false; return; } - if (_wr->isUpdating()) { return; } diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index fca8a7974..80a2454b0 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -126,10 +126,12 @@ void Scalar::setRange(double min, double max) static_cast(_widget)->set_range(min, max); } -void Scalar::setValue(double value) +void Scalar::setValue(double value, bool setProg) { g_assert(_widget != NULL); - setProgrammatically = true; // callback is supposed to reset back, if it cares + if (setProg) { + setProgrammatically = true; // callback is supposed to reset back, if it cares + } static_cast(_widget)->set_value(value); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 86d7aee28..9cceeaa1f 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -139,7 +139,7 @@ public: /** * Sets the value of the spin button. */ - void setValue(double value); + void setValue(double value, bool setProg = true); /** * Manually forces an update of the spin button. -- cgit v1.2.3 From 28d25258de5d2274382dbb592f62e21ca8f91729 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 1 Aug 2016 00:47:38 +0200 Subject: Fix text param and alow run from commandline (bzr r15017.1.21) --- src/ui/widget/registered-widget.cpp | 13 ++++--------- src/ui/widget/text.cpp | 6 +++--- src/ui/widget/text.h | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 923949b72..8b8bdc8e4 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -331,8 +331,6 @@ RegisteredText::RegisteredText ( const Glib::ustring& label, const Glib::ustring init_parent(key, wr, repr_in, doc_in); setProgrammatically = false; - - setText(""); _activate_connection = signal_activate().connect (sigc::mem_fun (*this, &RegisteredText::on_activate)); } @@ -348,16 +346,13 @@ RegisteredText::on_activate() return; } _wr->setUpdating (true); - - Inkscape::SVGOStringStream os; - os << getText(); - + Glib::ustring str(getText()); set_sensitive(false); + Inkscape::SVGOStringStream os; + os << str; write_to_xml(os.str().c_str()); - set_sensitive(true); - setText(os.str().c_str()); - + set_sensitive(true); _wr->setUpdating (false); } diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp index ec58d5bb4..e6795b138 100644 --- a/src/ui/widget/text.cpp +++ b/src/ui/widget/text.cpp @@ -28,13 +28,13 @@ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip, { } -const char *Text::getText() const +Glib::ustring const Text::getText() const { g_assert(_widget != NULL); - return static_cast(_widget)->get_text().c_str(); + return static_cast(_widget)->get_text(); } -void Text::setText(const char* text) +void Text::setText(Glib::ustring const text) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h index b90788940..593875b23 100644 --- a/src/ui/widget/text.h +++ b/src/ui/widget/text.h @@ -44,12 +44,12 @@ public: /** * Get the text in the entry. */ - const char* getText() const; + Glib::ustring const getText() const; /** * Sets the text of the text entry. */ - void setText(const char* text); + void setText(Glib::ustring const text); void update(); -- cgit v1.2.3 From b7556c8456244e9cc884f721d8a728c1377d565e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 1 Aug 2016 18:11:45 +0200 Subject: Noumerous bug fixes, font size, stroke with arroow position, and text input response (bzr r15017.1.25) --- src/ui/widget/registered-widget.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 8b8bdc8e4..dc2e4e14a 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -351,7 +351,6 @@ RegisteredText::on_activate() Inkscape::SVGOStringStream os; os << str; write_to_xml(os.str().c_str()); - setText(os.str().c_str()); set_sensitive(true); _wr->setUpdating (false); } -- cgit v1.2.3