summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2016-10-06 21:12:33 +0000
committerMartin Owens <doctormo@gmail.com>2016-10-06 21:12:33 +0000
commit032cb7a6b8f3b83b75f71048a896f03907436f9e (patch)
tree672d01cd146779e67916c4553a27134b20c2ba42 /src/ui
parentxverbs branch merge by dmitry-zhulanov (diff)
parentFix on delete line (diff)
downloadinkscape-032cb7a6b8f3b83b75f71048a896f03907436f9e.tar.gz
inkscape-032cb7a6b8f3b83b75f71048a896f03907436f9e.zip
Merge jabier's Measure line LPE
(bzr r15148)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp39
-rw-r--r--src/ui/dialog/livepatheffect-editor.h5
-rw-r--r--src/ui/widget/combo-enums.h9
-rw-r--r--src/ui/widget/font-button.cpp58
-rw-r--r--src/ui/widget/font-button.h63
-rw-r--r--src/ui/widget/registered-enums.h6
-rw-r--r--src/ui/widget/registered-widget.cpp54
-rw-r--r--src/ui/widget/registered-widget.h20
-rw-r--r--src/ui/widget/scalar.cpp6
-rw-r--r--src/ui/widget/scalar.h2
-rw-r--r--src/ui/widget/text.cpp6
-rw-r--r--src/ui/widget/text.h4
13 files changed, 242 insertions, 32 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 9e641edc3..f2a256698 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-button.cpp
widget/font-variants.cpp
widget/frame.cpp
widget/highlight-picker.cpp
@@ -312,6 +313,7 @@ set(ui_SRC
widget/entity-entry.h
widget/entry.h
widget/filter-effect-chooser.h
+ widget/font-button.h
widget/font-variants.h
widget/frame.h
widget/highlight-picker.h
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 459d8d4ee..73f8debd6 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -52,7 +52,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)
@@ -89,7 +89,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);
@@ -190,6 +191,10 @@ LivePathEffectEditor::~LivePathEffectEditor()
void
LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
{
+ if ( ! effect.upd_params ) {
+ return;
+ }
+
if (effectwidget) {
effectcontrol_vbox.remove(*effectwidget);
delete effectwidget;
@@ -249,9 +254,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
@@ -275,6 +279,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);
@@ -478,6 +485,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,
@@ -532,11 +545,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);
+ }
}
}
}
@@ -554,6 +573,14 @@ void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
/* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
* So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
+ Inkscape::Selection *sel = _getSelection();
+ if ( sel && !sel->isEmpty() ) {
+ SPItem *item = sel->singleItem();
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if ( lpeitem ) {
+ lpeobjref->lpeobject->get_lpe()->doOnVisibilityToggled(lpeitem);
+ }
+ }
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
newValue ? _("Activate path effect") : _("Deactivate path effect"));
}
diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h
index b69ee007a..489e9564d 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);
@@ -122,6 +123,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/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 <gtkmm/liststore.h>
#include "attr-widget.h"
#include "util/enums.h"
-
#include <glibmm/i18n.h>
namespace Inkscape {
@@ -190,9 +189,11 @@ public:
const Util::EnumDataConverter<E>& c,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
- bool mnemonic = true)
- : Labelled(label, tooltip, new ComboBoxEnum<E>(c), suffix, icon, mnemonic)
- { }
+ bool mnemonic = true,
+ bool sorted = true)
+ : Labelled(label, tooltip, new ComboBoxEnum<E>(c, SP_ATTR_INVALID, sorted), suffix, icon, mnemonic)
+ {
+ }
ComboBoxEnum<E>* getCombobox() {
return static_cast< ComboBoxEnum<E>* > (_widget);
diff --git a/src/ui/widget/font-button.cpp b/src/ui/widget/font-button.cpp
new file mode 100644
index 000000000..a472ac6a4
--- /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 <config.h>
+#endif
+
+#include "font-button.h"
+#include <glibmm/i18n.h>
+
+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 10"), suffix, icon, mnemonic)
+{
+}
+
+Glib::ustring FontButton::getValue() const
+{
+ g_assert(_widget != NULL);
+ return static_cast<Gtk::FontButton*>(_widget)->get_font_name();
+}
+
+
+void FontButton::setValue (Glib::ustring fontspec)
+{
+ g_assert(_widget != NULL);
+ static_cast<Gtk::FontButton*>(_widget)->set_font_name(fontspec);
+}
+
+Glib::SignalProxy0<void> FontButton::signal_font_value_changed()
+{
+ g_assert(_widget != NULL);
+ return static_cast<Gtk::FontButton*>(_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 <gtkmm.h>
+#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<void> 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/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<E>& c,
Registry& wr,
Inkscape::XML::Node* repr_in = NULL,
- SPDocument *doc_in = NULL )
- : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c)
+ SPDocument *doc_in = NULL,
+ bool sorted = true )
+ : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c, (const Glib::ustring &)"", (const Glib::ustring &)"", true, sorted)
{
RegisteredWidget< LabelledComboBoxEnum<E> >::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.cpp b/src/ui/widget/registered-widget.cpp
index 7dc5abc75..be677a434 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -285,7 +285,6 @@ RegisteredScalar::on_value_changed()
setProgrammatically = false;
return;
}
-
if (_wr->isUpdating()) {
return;
}
@@ -319,8 +318,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));
}
@@ -336,16 +333,12 @@ 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());
-
_wr->setUpdating (false);
}
@@ -791,6 +784,47 @@ RegisteredRandom::on_value_changed()
_wr->setUpdating (false);
}
+/*#########################################
+ * Registered FONT-BUTTON
+ */
+
+RegisteredFontButton::~RegisteredFontButton()
+{
+ _signal_font_set.disconnect();
+}
+
+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<FontButton>(label, tip)
+{
+ init_parent(key, wr, repr_in, doc_in);
+ _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed));
+}
+
+void
+RegisteredFontButton::setValue (Glib::ustring fontspec)
+{
+ FontButton::setValue(fontspec);
+}
+
+void
+RegisteredFontButton::on_value_changed()
+{
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Inkscape::SVGOStringStream os;
+ os << getValue();
+
+ 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 ab2e4c8e4..d410dbfe6 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-button.h"
#include "ui/widget/color-picker.h"
#include "inkscape.h"
@@ -77,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() {};
@@ -418,6 +421,23 @@ protected:
void on_value_changed();
};
+class RegisteredFontButton : public RegisteredWidget<FontButton> {
+public:
+ 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);
+
+protected:
+ sigc::connection _signal_font_set;
+ void on_value_changed();
+};
+
} // namespace Widget
} // namespace UI
} // namespace Inkscape
diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp
index 434c2c0bb..f8543a371 100644
--- a/src/ui/widget/scalar.cpp
+++ b/src/ui/widget/scalar.cpp
@@ -122,10 +122,12 @@ void Scalar::setRange(double min, double max)
static_cast<SpinButton*>(_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<SpinButton*>(_widget)->set_value(value);
}
diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h
index 847790b96..f186f46ac 100644
--- a/src/ui/widget/scalar.h
+++ b/src/ui/widget/scalar.h
@@ -135,7 +135,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.
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<Gtk::Entry*>(_widget)->get_text().c_str();
+ return static_cast<Gtk::Entry*>(_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();