From ac25f7827cc250eb47eedf1bd3aa5ec8438fc0e5 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 7 Jun 2016 01:35:26 +0200 Subject: Add measure Over Item by a vlada idea on IRC (bzr r14957.1.1) --- src/ui/tools/measure-tool.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++ src/ui/tools/measure-tool.h | 9 ++++ 2 files changed, 121 insertions(+) (limited to 'src/ui') diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 287828d32..8b2a734ff 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -394,6 +394,10 @@ MeasureTool::~MeasureTool() sp_canvas_item_destroy(measure_tmp_items[idx]); } measure_tmp_items.clear(); + for (size_t idx = 0; idx < measure_item.size(); ++idx) { + sp_canvas_item_destroy(measure_item[idx]); + } + measure_item.clear(); for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) { sp_canvas_item_destroy(measure_phantom_items[idx]); } @@ -608,6 +612,12 @@ bool MeasureTool::root_handler(GdkEvent* event) snap_manager.preSnap(scp); snap_manager.unSetup(); } + Geom::Point const motion_w(event->motion.x, event->motion.y); + if(event->motion.state & GDK_SHIFT_MASK) { + showInfoBox(motion_w, true); + } else { + showInfoBox(motion_w, false); + } } else { ret = TRUE; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1128,6 +1138,108 @@ void MeasureTool::setMeasureCanvasControlLine(Geom::Point start, Geom::Point end } } +void MeasureTool::showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize) +{ + SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(), + desktop, + pos, + measure_str); + sp_canvastext_set_fontsize(canvas_tooltip, fontsize); + canvas_tooltip->rgba = 0xffffffff; + canvas_tooltip->outline = false; + canvas_tooltip->background = true; + canvas_tooltip->anchor_position = TEXT_ANCHOR_LEFT; + canvas_tooltip->rgba_background = 0x00000099; + measure_item.push_back(SP_CANVAS_ITEM(canvas_tooltip)); + sp_canvas_item_show(SP_CANVAS_ITEM(canvas_tooltip)); +} + +void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) +{ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit(); + for (size_t idx = 0; idx < measure_item.size(); ++idx) { + sp_canvas_item_destroy(measure_item[idx]); + } + measure_item.clear(); + + SPItem *newover = desktop->getItemAtPoint(cursor, into_groups); + if (newover) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double fontsize = prefs->getDouble("/tools/measure/fontsize", 10.0); + double scale = prefs->getDouble("/tools/measure/scale", 100.0) / 100.0; + int precision = prefs->getInt("/tools/measure/precision", 2); + Glib::ustring unit_name = prefs->getString("/tools/measure/unit"); + if (!unit_name.compare("")) { + unit_name = "px"; + } + Geom::Scale zoom = Geom::Scale(Inkscape::Util::Quantity::convert(desktop->current_zoom(), "px", unit->abbr)).inverse(); + if(newover != over){ + over = newover; + Preferences *prefs = Preferences::get(); + int prefs_bbox = prefs->getBool("/tools/bounding_box", 0); + SPItem::BBoxType bbox_type = !prefs_bbox ? SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; + Geom::OptRect bbox = over->bounds(bbox_type); + if (bbox) { + + item_width = Inkscape::Util::Quantity::convert((*bbox).width() * scale, unit->abbr, unit_name); + item_height = Inkscape::Util::Quantity::convert((*bbox).height() * scale, unit->abbr, unit_name); + item_x = Inkscape::Util::Quantity::convert((*bbox).left(), unit->abbr, unit_name); + Geom::Point y_point(0,Inkscape::Util::Quantity::convert((*bbox).bottom() * scale, unit->abbr, "px")); + y_point *= desktop->doc2dt(); + item_y = Inkscape::Util::Quantity::convert(y_point[Geom::Y] * scale, "px", unit_name); + if (SP_IS_SHAPE(over)) { + Geom::PathVector shape = SP_SHAPE(over)->getCurve()->get_pathvector(); + item_length = Geom::length(paths_to_pw(shape)); + item_length = Inkscape::Util::Quantity::convert(item_length * scale, unit->abbr, unit_name); + } + } + } + gchar *measure_str = NULL; + std::stringstream precision_str; + precision_str.imbue(std::locale::classic()); + double origin = Inkscape::Util::Quantity::convert(14, "px", unit->abbr); + Geom::Point rel_position = Geom::Point(origin, origin); + Geom::Point pos = desktop->w2d(cursor); + double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr); + if (SP_IS_SHAPE(over)) { + precision_str << _("Lenght") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_length, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + } else if (SP_IS_GROUP(over)) { + measure_str = _("Shift to measure into group"); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + } + + precision_str << "Y: %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_y, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << "X: %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_x, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << _("Height") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_height, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << _("Width") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_width, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + g_free(measure_str); + } +} + void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, Inkscape::XML::Node *measure_repr) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; diff --git a/src/ui/tools/measure-tool.h b/src/ui/tools/measure-tool.h index 14fc9f81a..42122dca1 100644 --- a/src/ui/tools/measure-tool.h +++ b/src/ui/tools/measure-tool.h @@ -54,6 +54,8 @@ public: virtual void setMarker(bool isStart); virtual const std::string& getPrefsPath(); Geom::Point readMeasurePoint(bool is_start); + void showInfoBox(Geom::Point cursor, bool into_groups); + void showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize); void writeMeasurePoint(Geom::Point point, bool is_start); void setGuide(Geom::Point origin, double angle, const char *label); void setPoint(Geom::Point origin, Inkscape::XML::Node *measure_repr); @@ -77,6 +79,13 @@ private: Geom::Point end_p; std::vector measure_tmp_items; std::vector measure_phantom_items; + std::vector measure_item; + double item_width; + double item_height; + double item_x; + double item_y; + double item_length; + SPItem *over; sigc::connection _knot_start_moved_connection; sigc::connection _knot_start_ungrabbed_connection; sigc::connection _knot_start_click_connection; -- cgit v1.2.3 From 6d5d7e5421a5ac585814bde11866d796d81653cd Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 11 Jun 2016 14:04:09 +0200 Subject: Fix a typo pointed by CR (bzr r14957.1.2) --- src/ui/tools/measure-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 8b2a734ff..900274afc 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1203,7 +1203,7 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) Geom::Point pos = desktop->w2d(cursor); double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr); if (SP_IS_SHAPE(over)) { - precision_str << _("Lenght") << ": %." << precision << "f %s"; + precision_str << _("Length") << ": %." << precision << "f %s"; measure_str = g_strdup_printf(precision_str.str().c_str(), item_length, unit_name.c_str()); precision_str.str(""); showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); -- cgit v1.2.3 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/CMakeLists.txt | 2 + src/ui/dialog/livepatheffect-editor.cpp | 31 +++++++-- src/ui/dialog/livepatheffect-editor.h | 5 +- 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 +++++ 8 files changed, 291 insertions(+), 7 deletions(-) create mode 100644 src/ui/widget/font-selector.cpp create mode 100644 src/ui/widget/font-selector.h (limited to 'src/ui') 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(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(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 +#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') 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') 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') 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/CMakeLists.txt | 4 +- 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 ++-- 8 files changed, 142 insertions(+), 220 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') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 62f341962..af375f1f9 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -128,7 +128,7 @@ set(ui_SRC widget/entity-entry.cpp widget/entry.cpp widget/filter-effect-chooser.cpp - widget/font-selector.cpp + widget/font-button.cpp widget/font-variants.cpp widget/frame.cpp widget/gimpcolorwheel.c @@ -313,7 +313,7 @@ set(ui_SRC widget/entity-entry.h widget/entry.h widget/filter-effect-chooser.h - widget/font-selector.h + widget/font-button.h widget/font-variants.h widget/frame.h widget/gimpspinscale.h 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') 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/dialog/livepatheffect-editor.cpp | 8 ++++++++ src/ui/widget/registered-widget.cpp | 1 - src/ui/widget/scalar.cpp | 6 ++++-- src/ui/widget/scalar.h | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 7205beaa8..e177ae01e 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -589,6 +589,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(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/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') 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') 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 From e1d0c1cb00f84b66b38af6eec563cf60df7ba726 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 3 Oct 2016 18:08:29 +0200 Subject: Fix a bug on eraser mode when previous clip are shapes not paths (bzr r15145) --- src/ui/tools/eraser-tool.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 38c72cac0..12686160b 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -766,9 +766,17 @@ void EraserTool::set_to_accumulated() { if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { - SPPath *clip_data = SP_PATH(clip_path->firstChild()); + std::vector selected; + selected.push_back(SP_ITEM(clip_path->firstChild())); + std::vector to_select; + std::vector items(selected); + sp_item_list_to_curves(items, selected, to_select); + Inkscape::XML::Node * clip_data = SP_ITEM(clip_path->firstChild())->getRepr(); + if (!clip_data && !to_select.empty()) { + clip_data = *(to_select.begin()); + } if (clip_data) { - Inkscape::XML::Node *dup_clip = SP_OBJECT(clip_data)->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup_clip = clip_data->duplicate(xml_doc); if (dup_clip) { SPItem * dup_clip_obj = SP_ITEM(item_repr->parent->appendChildRepr(dup_clip)); if (dup_clip_obj) { -- cgit v1.2.3 From eb4b3b8d4823f7a9cef4e623080e3d1e4b7426eb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 7 Oct 2016 20:03:23 +0200 Subject: Fix bug:1630821 on LPE selected nodes Fixed bugs: - https://launchpad.net/bugs/1630821 (bzr r15149) --- src/ui/tools/node-tool.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 2bd4fdea3..f3679b40f 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -285,13 +285,11 @@ void NodeTool::update_helperpath () { if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) { - Inkscape::UI::ControlPointSelection::Set &selectionNodes = _selected_nodes->allPoints(); + Inkscape::UI::ControlPointSelection *selectionNodes = _selected_nodes; std::vector selectedNodesPositions; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selectionNodes.begin(); i != selectionNodes.end(); ++i) { - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast(*i); - selectedNodesPositions.push_back(n->position()); - } + for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { + Inkscape::UI::Node *n = dynamic_cast(*i); + selectedNodesPositions.push_back(n->position()); } lpe->setSelectedNodePoints(selectedNodesPositions); lpe->setCurrentZoom(this->desktop->current_zoom()); @@ -470,6 +468,7 @@ bool NodeTool::root_handler(GdkEvent* event) { switch (event->type) { case GDK_MOTION_NOTIFY: { + update_helperpath(); combine_motion_events(desktop->canvas, event->motion, 0); SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button), FALSE, TRUE); -- cgit v1.2.3 From 60688fe72a9a75ac54d895a7aa61d3a0518ca8ab Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 7 Oct 2016 20:48:31 +0200 Subject: Fix bug:1630796 on flatten button Fixed bugs: - https://launchpad.net/bugs/1630796 (bzr r15150) --- src/ui/dialog/livepatheffect-editor.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index 489e9564d..8e9e66435 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -49,6 +49,8 @@ public: void onSelectionModified(Inkscape::Selection *sel); virtual void on_effect_selection_changed(); void setDesktop(SPDesktop *desktop); + // void add_entry(const char* name ); + void effect_list_reload(SPLPEItem *lpeitem); private: @@ -70,9 +72,6 @@ private: void showText(Glib::ustring const &str); void selectInList(LivePathEffect::Effect* effect); - // void add_entry(const char* name ); - void effect_list_reload(SPLPEItem *lpeitem); - // callback methods for buttons on grids page. void onAdd(); void onRemove(); -- cgit v1.2.3 From 4265fc5086c2a7467de2b8d1c26efac1412a5089 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 7 Oct 2016 22:58:19 +0200 Subject: Fix bug:1605334 FeImage X and Y position Fixed bugs: - https://launchpad.net/bugs/1605334 (bzr r15151) --- src/ui/dialog/filter-effects-dialog.cpp | 46 ++++++++++++++++++++++++++++++++- src/ui/dialog/filter-effects-dialog.h | 8 ++++++ 2 files changed, 53 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index a0cd786dc..f657e1b76 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -860,6 +860,17 @@ public: return dss; } + // SpinButton + SpinButtonAttr* add_spinbutton(double defalt_value, const SPAttributeEnum attr, const Glib::ustring& label, + const double lo, const double hi, const double step_inc, + const double climb, const int digits, char* tip = NULL) + { + SpinButtonAttr* sb = new SpinButtonAttr(lo, hi, step_inc, climb, digits, attr, defalt_value, tip); + add_widget(sb, label); + add_attr_widget(sb); + return sb; + } + // DualSpinButton DualSpinButton* add_dualspinbutton(char* defalt_value, const SPAttributeEnum attr, const Glib::ustring& label, const double lo, const double hi, const double step_inc, @@ -2785,8 +2796,14 @@ void FilterEffectsDialog::init_settings_widgets() _settings->type(NR_FILTER_IMAGE); _settings->add_fileorelement(SP_ATTR_XLINK_HREF, _("Source of Image:")); - + _image_x = _settings->add_entry(SP_ATTR_X,_("X"),_("X")); + _image_x->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::image_x_changed)); + //This commented because we want the default empty value of X or Y and couldent get it from SpinButton + //_image_y = _settings->add_spinbutton(0, SP_ATTR_Y, _("Y:"), -DBL_MAX, DBL_MAX, 1, 1, 5, _("Y")); + _image_y = _settings->add_entry(SP_ATTR_Y,_("Y"),_("Y")); + _image_y->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::image_y_changed)); _settings->type(NR_FILTER_OFFSET); + _settings->add_checkbutton(false, SP_ATTR_PRESERVEALPHA, _("Preserve Alpha"), "true", "false", _("If set, the alpha channel won't be altered by this filter primitive.")); _settings->add_spinscale(0, SP_ATTR_DX, _("Delta X:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted to the right")); _settings->add_spinscale(0, SP_ATTR_DY, _("Delta Y:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted downwards")); @@ -2926,6 +2943,33 @@ void FilterEffectsDialog::convolve_order_changed() _convolve_target->get_spinbuttons()[1]->get_adjustment()->set_upper(_convolve_order->get_spinbutton2().get_value() - 1); } +bool number_or_empy(const Glib::ustring& text) { + if (text.empty()) { + return true; + } + double n = atof( text.c_str() ); + if (n == 0.0 && strcmp(text.c_str(), "0") != 0 && strcmp(text.c_str(), "0.0") != 0) { + return false; + } + else { + return true; + } +} + +void FilterEffectsDialog::image_x_changed() +{ + if (number_or_empy(_image_x->get_text())) { + _image_x->set_from_attribute(_primitive_list.get_selected()); + } +} + +void FilterEffectsDialog::image_y_changed() +{ + if (number_or_empy(_image_y->get_text())) { + _image_y->set_from_attribute(_primitive_list.get_selected()); + } +} + void FilterEffectsDialog::set_attr_direct(const AttrWidget* input) { set_attr(_primitive_list.get_selected(), input->get_attribute(), input->get_as_attribute().c_str()); diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index eae0fc317..32fabb741 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -35,6 +35,8 @@ namespace Inkscape { namespace UI { namespace Dialog { +class EntryAttr; +//class SpinButtonAttr; class DualSpinButton; class MultiSpinButton; class FilterEffectsDialog : public UI::Widget::Panel { @@ -258,6 +260,8 @@ private: void remove_primitive(); void duplicate_primitive(); void convolve_order_changed(); + void image_x_changed(); + void image_y_changed(); void set_attr_direct(const UI::Widget::AttrWidget*); void set_child_attr_direct(const UI::Widget::AttrWidget*); @@ -308,6 +312,10 @@ private: DualSpinButton* _convolve_order; MultiSpinButton* _convolve_target; + // Image + EntryAttr* _image_x; + EntryAttr* _image_y; + // For controlling setting sensitivity Gtk::Widget* _k1, *_k2, *_k3, *_k4; -- cgit v1.2.3 From 3fb11a7eb8d066e2b16bddb98de9b4c03e28ba56 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Oct 2016 01:46:38 +0200 Subject: Fix bug:1630796 on flatten button. Attemp 2 Fixed bugs: - https://launchpad.net/bugs/1630796 (bzr r15152) --- src/ui/dialog/livepatheffect-editor.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index 8e9e66435..a7c749ef3 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -49,8 +49,6 @@ public: void onSelectionModified(Inkscape::Selection *sel); virtual void on_effect_selection_changed(); void setDesktop(SPDesktop *desktop); - // void add_entry(const char* name ); - void effect_list_reload(SPLPEItem *lpeitem); private: @@ -66,6 +64,9 @@ private: sigc::connection selection_changed_connection; sigc::connection selection_modified_connection; + // void add_entry(const char* name ); + void effect_list_reload(SPLPEItem *lpeitem); + void set_sensitize_all(bool sensitive); void showParams(LivePathEffect::Effect& effect); -- cgit v1.2.3 From 7be3086bf70ba9bf28c5cfe06fd7a8e28e719bcc Mon Sep 17 00:00:00 2001 From: sandra-snan Date: Sat, 8 Oct 2016 08:16:53 +0200 Subject: [Bug #770681] KEY MAPPING: Comma and period hijacked by scaling. Fixed bugs: - https://launchpad.net/bugs/770681 (bzr r15155) --- src/ui/tools/select-tool.cpp | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 86a2dbed3..0cdeda0b6 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -1045,37 +1045,7 @@ bool SelectTool::root_handler(GdkEvent* event) { ret = TRUE; break; - - case GDK_KEY_less: - case GDK_KEY_comma: - if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale_screen(selection, -2*mul); - } else if (MOD__CTRL(event)) { - sp_selection_scale_times(selection, 0.5); - } else { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale(selection, -offset*mul); - } - - ret = TRUE; - break; - - case GDK_KEY_greater: - case GDK_KEY_period: - if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale_screen(selection, 2*mul); - } else if (MOD__CTRL(event)) { - sp_selection_scale_times(selection, 2); - } else { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale(selection, offset*mul); - } - - ret = TRUE; - break; - + case GDK_KEY_Return: if (MOD__CTRL_ONLY(event)) { if (selection->singleItem()) { -- cgit v1.2.3