summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp31
-rw-r--r--src/ui/dialog/livepatheffect-editor.h5
-rw-r--r--src/ui/widget/Makefile_insert2
-rw-r--r--src/ui/widget/font-selector.cpp115
-rw-r--r--src/ui/widget/font-selector.h81
-rw-r--r--src/ui/widget/registered-widget.cpp44
-rw-r--r--src/ui/widget/registered-widget.h18
8 files changed, 291 insertions, 7 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 587974b90..62f341962 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -128,6 +128,7 @@ set(ui_SRC
widget/entity-entry.cpp
widget/entry.cpp
widget/filter-effect-chooser.cpp
+ widget/font-selector.cpp
widget/font-variants.cpp
widget/frame.cpp
widget/gimpcolorwheel.c
@@ -312,6 +313,7 @@ set(ui_SRC
widget/entity-entry.h
widget/entry.h
widget/filter-effect-chooser.h
+ widget/font-selector.h
widget/font-variants.h
widget/frame.h
widget/gimpspinscale.h
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 422ec10ae..7205beaa8 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -61,7 +61,7 @@ void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data
{
LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
lpeeditor->lpe_list_locked = false;
- lpeeditor->onSelectionChanged(selection);
+ lpeeditor->onSelectionChanged(selection, true);
}
static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
@@ -98,7 +98,8 @@ LivePathEffectEditor::LivePathEffectEditor()
button_up(),
button_down(),
current_desktop(NULL),
- current_lpeitem(NULL)
+ current_lpeitem(NULL),
+ current_lperef(NULL)
{
Gtk::Box *contents = _getContents();
contents->set_spacing(4);
@@ -206,6 +207,10 @@ LivePathEffectEditor::~LivePathEffectEditor()
void
LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
{
+ if ( ! effect.upd_params ) {
+ return;
+ }
+
if (effectwidget) {
effectcontrol_vbox.remove(*effectwidget);
delete effectwidget;
@@ -265,9 +270,8 @@ LivePathEffectEditor::set_sensitize_all(bool sensitive)
button_down.set_sensitive(sensitive);
}
-
void
-LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
+LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel, bool upd_params)
{
if (lpe_list_locked) {
// this was triggered by selecting a row in the list, so skip reloading
@@ -291,6 +295,9 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
if ( lpeitem->hasPathEffect() ) {
Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE();
if (lpe) {
+ if (upd_params) {
+ lpe->upd_params = true;
+ }
showParams(*lpe);
lpe_list_locked = true;
selectInList(lpe);
@@ -494,6 +501,12 @@ LivePathEffectEditor::onRemove()
SPItem *item = sel->singleItem();
SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
if ( lpeitem ) {
+ if (current_lperef && current_lperef->lpeobject) {
+ LivePathEffect::Effect * effect = current_lperef->lpeobject->get_lpe();
+ if (effect) {
+ effect->upd_params = true;
+ }
+ }
lpeitem->removeCurrentPathEffect(false);
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
@@ -548,11 +561,17 @@ void LivePathEffectEditor::on_effect_selection_changed()
Gtk::TreeModel::iterator it = sel->get_selected();
LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
- if (lperef && current_lpeitem) {
+ if (lperef && current_lpeitem && current_lperef != lperef) {
+ //The last condition ignore Gtk::TreeModel may occasionally be changed emitted when nothing has happened
if (lperef->lpeobject->get_lpe()) {
lpe_list_locked = true; // prevent reload of the list which would lose selection
current_lpeitem->setCurrentPathEffect(lperef);
- showParams(*lperef->lpeobject->get_lpe());
+ current_lperef = lperef;
+ LivePathEffect::Effect * effect = lperef->lpeobject->get_lpe();
+ if (effect) {
+ effect->upd_params = true;
+ showParams(*effect);
+ }
}
}
}
diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h
index 4aac25eaa..b7ec1eeec 100644
--- a/src/ui/dialog/livepatheffect-editor.h
+++ b/src/ui/dialog/livepatheffect-editor.h
@@ -45,7 +45,8 @@ public:
static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); }
- void onSelectionChanged(Inkscape::Selection *sel);
+ void onSelectionChanged(Inkscape::Selection *sel, bool upd_params = false);
+ void onSelectionModified(Inkscape::Selection *sel);
virtual void on_effect_selection_changed();
void setDesktop(SPDesktop *desktop);
@@ -126,6 +127,8 @@ private:
SPLPEItem * current_lpeitem;
+ LivePathEffect::LPEObjectReference * current_lperef;
+
friend void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data);
LivePathEffectEditor(LivePathEffectEditor const &d);
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 <config.h>
+#endif
+
+#include "font-selector.h"
+#include "widgets/icon.h"
+#include <glibmm/i18n.h>
+
+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: <b>hided</b>")));
+ }
+}
+
+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 <gtkmm.h>
+#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 <void> 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<FontSelector> (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<FontSelector> {
+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