summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-10-08 00:30:57 +0000
committerjabiertxof <info@marker.es>2016-10-08 00:30:57 +0000
commitbf899f7b2615bc40094815c81f7a127a42822f8e (patch)
tree8b30db7baf42c2051c1de654779dcb3082cbe39a /src/ui
parentDoc rotate start (diff)
parentFix bug:1622321 on powerstroke (diff)
downloadinkscape-bf899f7b2615bc40094815c81f7a127a42822f8e.tar.gz
inkscape-bf899f7b2615bc40094815c81f7a127a42822f8e.zip
Update to trunk
(bzr r15142.1.2)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp46
-rw-r--r--src/ui/dialog/filter-effects-dialog.h8
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp39
-rw-r--r--src/ui/dialog/livepatheffect-editor.h11
-rw-r--r--src/ui/tools/eraser-tool.cpp153
-rw-r--r--src/ui/tools/eraser-tool.h4
-rw-r--r--src/ui/tools/measure-tool.cpp112
-rw-r--r--src/ui/tools/measure-tool.h9
-rw-r--r--src/ui/tools/node-tool.cpp11
-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
20 files changed, 543 insertions, 80 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/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;
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..a7c749ef3 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);
@@ -63,15 +64,15 @@ 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);
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();
@@ -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/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index 4b40262cd..12686160b 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -51,15 +51,21 @@
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
+#include "sp-clippath.h"
+#include "sp-rect.h"
#include "sp-text.h"
+#include "sp-root.h"
+#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "document-undo.h"
#include "verbs.h"
#include "style.h"
#include <2geom/pathvector.h>
#include "path-chemistry.h"
+#include "selection-chemistry.h"
#include "display/curve.h"
-
+#include "layer-model.h"
+#include "layer-manager.h"
#include "ui/tools/eraser-tool.h"
using Inkscape::DocumentUndo;
@@ -369,7 +375,7 @@ void EraserTool::cancel() {
bool EraserTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode", 2);
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !this->space_panning) {
@@ -389,7 +395,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
if (this->repr) {
this->repr = NULL;
}
- if ( ! eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH);
}
@@ -437,7 +443,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
- if ( !eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
this->accumulated->reset();
Inkscape::Rubberband::get(desktop)->move(motion_dt);
}
@@ -480,7 +486,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
- if (!eraserMode && Inkscape::Rubberband::get(desktop)->is_started()) {
+ if (eraser_mode == ERASER_MODE_DELETE && Inkscape::Rubberband::get(desktop)->is_started()) {
Inkscape::Rubberband::get(desktop)->stop();
}
@@ -567,7 +573,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_Escape:
- if ( !eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
Inkscape::Rubberband::get(desktop)->stop();
}
if (this->is_drawing) {
@@ -629,52 +635,53 @@ void EraserTool::clear_current() {
void EraserTool::set_to_accumulated() {
bool workDone = false;
-
+ SPDocument *document = this->desktop->doc();
if (!this->accumulated->is_empty()) {
if (!this->repr) {
/* Create object */
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
/* Set style */
- sp_desktop_apply_style_tool (desktop, repr, "/tools/eraser", false);
+ sp_desktop_apply_style_tool (this->desktop, repr, "/tools/eraser", false);
this->repr = repr;
}
- SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr));
+ SPObject * top_layer = desktop->layer_manager->nthChildOf(desktop->layers->currentRoot(), 0);
+ SPItem *item_repr = SP_ITEM(top_layer->appendChildRepr(this->repr));
Inkscape::GC::release(this->repr);
- item->updateRepr();
- Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc();
- pathv *= item->i2doc_affine().inverse();
+ item_repr->updateRepr();
+ Geom::PathVector pathv = this->accumulated->get_pathvector() * this->desktop->dt2doc();
+ pathv *= item_repr->i2doc_affine().inverse();
gchar *str = sp_svg_write_path(pathv);
g_assert( str != NULL );
this->repr->setAttribute("d", str);
g_free(str);
-
+ Geom::OptRect eraserBbox;
if ( this->repr ) {
bool wasSelection = false;
- Inkscape::Selection *selection = desktop->getSelection();
+ Inkscape::Selection *selection = this->desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode", ERASER_MODE_CLIP);
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
- SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr));
- Geom::OptRect eraserBbox = acid->desktopVisualBounds();
+ SPItem* acid = SP_ITEM(this->desktop->doc()->getObjectByRepr(this->repr));
+ eraserBbox = acid->desktopVisualBounds();
std::vector<SPItem*> remainingItems;
std::vector<SPItem*> toWorkOn;
if (selection->isEmpty()) {
- if ( eraserMode ) {
- toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox);
+ if (eraser_mode == ERASER_MODE_CUT || eraser_mode == ERASER_MODE_CLIP) {
+ toWorkOn = document->getItemsPartiallyInBox(this->desktop->dkey, *eraserBbox);
} else {
- Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
- toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop);
+ toWorkOn = document->getItemsAtPoints(this->desktop->dkey, r->getPoints());
}
toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end());
} else {
- if ( !eraserMode ) {
- Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
+ if (eraser_mode == ERASER_MODE_DELETE) {
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop);
std::vector<SPItem*> touched;
- touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
+ touched = document->getItemsAtPoints(this->desktop->dkey, r->getPoints());
for (std::vector<SPItem*>::const_iterator i = touched.begin();i!=touched.end();++i) {
if(selection->includes(*i)){
toWorkOn.push_back((*i));
@@ -687,7 +694,7 @@ void EraserTool::set_to_accumulated() {
}
if ( !toWorkOn.empty() ) {
- if ( eraserMode ) {
+ if (eraser_mode == ERASER_MODE_CUT) {
for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){
SPItem *item = *i;
SPUse *use = dynamic_cast<SPUse *>(item);
@@ -713,7 +720,7 @@ void EraserTool::set_to_accumulated() {
if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-rule", "evenodd");
- sp_desktop_set_style(desktop, css);
+ sp_desktop_set_style(this->desktop, css);
sp_repr_css_attr_unref(css);
css = 0;
}
@@ -725,10 +732,10 @@ void EraserTool::set_to_accumulated() {
workDone = true; // TODO set this only if something was cut.
bool break_apart = prefs->getBool("/tools/eraser/break_apart", false);
if(!break_apart){
- sp_selected_path_combine(desktop, true);
+ sp_selected_path_combine(this->desktop, true);
} else {
if(!this->nowidth){
- sp_selected_path_break_apart(desktop, true);
+ sp_selected_path_break_apart(this->desktop, true);
}
}
if ( !selection->isEmpty() ) {
@@ -743,6 +750,78 @@ void EraserTool::set_to_accumulated() {
}
}
}
+ } else if (eraser_mode == ERASER_MODE_CLIP) {
+ if (!this->nowidth) {
+ remainingItems.clear();
+ for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){
+ selection->clear();
+ SPItem *item = *i;
+ Geom::OptRect bbox = item->desktopVisualBounds();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
+ Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc);
+ this->repr->parent()->appendChild(dup);
+ Inkscape::GC::release(dup); // parent takes over
+ selection->set(dup);
+ sp_selected_path_union_skip_undo(selection);
+ if (bbox && bbox->intersects(*eraserBbox)) {
+ SPClipPath *clip_path = item->clip_ref->getObject();
+ if (clip_path) {
+ std::vector<SPItem*> selected;
+ selected.push_back(SP_ITEM(clip_path->firstChild()));
+ std::vector<Inkscape::XML::Node*> to_select;
+ std::vector<SPItem*> 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 = clip_data->duplicate(xml_doc);
+ if (dup_clip) {
+ SPItem * dup_clip_obj = SP_ITEM(item_repr->parent->appendChildRepr(dup_clip));
+ if (dup_clip_obj) {
+ dup_clip_obj->doWriteTransform(dup_clip, item->transform);
+ sp_object_ref(clip_path, 0);
+ clip_path->deleteObject(true);
+ sp_object_unref(clip_path);
+ sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->add(dup_clip);
+ sp_selected_path_diff_skip_undo(selection);
+ SPItem * clip = SP_ITEM(*(selection->items().begin()));
+ }
+ }
+ }
+ } else {
+ Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect");
+ sp_desktop_apply_style_tool (this->desktop, rect_repr, "/tools/eraser", false);
+ SPRect * rect = SP_RECT(item_repr->parent->appendChildRepr(rect_repr));
+ Inkscape::GC::release(rect_repr);
+ rect->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height());
+ rect->transform = SP_ITEM(rect->parent)->i2dt_affine().inverse();
+ rect->updateRepr();
+ rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->add(rect);
+ sp_selected_path_diff_skip_undo(selection);
+ }
+ sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->add(item);
+ sp_selection_set_mask(this->desktop, true, false, true);
+ } else {
+ SPItem *erase_clip = selection->singleItem();
+ if (erase_clip) {
+ sp_object_ref(erase_clip, 0);
+ erase_clip->deleteObject(true);
+ sp_object_unref(erase_clip);
+ }
+ }
+ workDone = true;
+ selection->clear();
+ if (wasSelection) {
+ remainingItems.push_back(item);
+ }
+ }
+ }
} else {
for (std::vector<SPItem*> ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();++i) {
sp_object_ref( *i, 0 );
@@ -756,8 +835,8 @@ void EraserTool::set_to_accumulated() {
}
}
- if ( !eraserMode ) {
- //sp_selection_delete(desktop);
+ if (eraser_mode == ERASER_MODE_DELETE) {
+ sp_selection_delete(this->desktop);
remainingItems.clear();
}
@@ -779,12 +858,10 @@ void EraserTool::set_to_accumulated() {
this->repr = 0;
}
}
-
-
if ( workDone ) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
+ DocumentUndo::done(document, SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
} else {
- DocumentUndo::cancel(desktop->getDocument());
+ DocumentUndo::cancel(document);
}
}
@@ -975,7 +1052,7 @@ void EraserTool::fit_and_split(bool release) {
g_print("[%d]Yup\n", this->npoints);
#endif
if (!release) {
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode",2);
g_assert(!this->currentcurve->is_empty());
SPCanvasItem *cbp = sp_canvas_item_new(desktop->getSketch(), SP_TYPE_CANVAS_BPATH, NULL);
@@ -997,7 +1074,7 @@ void EraserTool::fit_and_split(bool release) {
this->segments = g_slist_prepend(this->segments, cbp);
- if ( !eraserMode ) {
+ if (eraser_mode == ERASER_MODE_DELETE) {
sp_canvas_item_hide(cbp);
sp_canvas_item_hide(this->currentshape);
}
diff --git a/src/ui/tools/eraser-tool.h b/src/ui/tools/eraser-tool.h
index 50ce6b6e3..bd0e98057 100644
--- a/src/ui/tools/eraser-tool.h
+++ b/src/ui/tools/eraser-tool.h
@@ -31,6 +31,10 @@
#define ERC_MAX_TILT 1.0
#define ERC_DEFAULT_TILT 0.0
+#define ERASER_MODE_DELETE 0
+#define ERASER_MODE_CUT 1
+#define ERASER_MODE_CLIP 2
+
namespace Inkscape {
namespace UI {
namespace Tools {
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index c941b9bee..f3185649b 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -378,6 +378,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]);
}
@@ -591,6 +595,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();
@@ -1111,6 +1121,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 << _("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);
+ 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<SPCanvasItem *> measure_tmp_items;
std::vector<SPCanvasItem *> measure_phantom_items;
+ std::vector<SPCanvasItem *> 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;
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<Geom::Point> selectedNodesPositions;
- for (Inkscape::UI::ControlPointSelection::Set::iterator i = selectionNodes.begin(); i != selectionNodes.end(); ++i) {
- if ((*i)->selected()) {
- Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i);
- selectedNodesPositions.push_back(n->position());
- }
+ for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) {
+ Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*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);
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();