diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2011-05-26 21:17:37 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2011-05-26 21:17:37 +0000 |
| commit | d08f8e9ed468767cc64766eb80ea134bb5edb197 (patch) | |
| tree | 5ef0aa6763dc38420a0479469d4c2c8b352af65d /src | |
| parent | rename "set width" and "units per em" to "Em-size" (diff) | |
| download | inkscape-d08f8e9ed468767cc64766eb80ea134bb5edb197.tar.gz inkscape-d08f8e9ed468767cc64766eb80ea134bb5edb197.zip | |
add entry widget to guideline dialog to change guide's label
(and fix some label xml writing and rendering bugs)
(bzr r10234)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/guideline.cpp | 11 | ||||
| -rw-r--r-- | src/display/guideline.h | 2 | ||||
| -rw-r--r-- | src/sp-guide.cpp | 4 | ||||
| -rw-r--r-- | src/sp-guide.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/guides.cpp | 14 | ||||
| -rw-r--r-- | src/ui/dialog/guides.h | 2 |
6 files changed, 26 insertions, 9 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index f0e1c7724..dddf1f30e 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -21,6 +21,7 @@ #include "guideline.h" #include "cairo.h" #include "inkscape-cairo.h" +#include "color.h" static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); @@ -112,7 +113,8 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) cairo_t* ctx = nr_create_cairo_context_canvasbuf (NULL /*area*/, buf); //this function ignores the "area" parameter cairo_set_font_size (ctx, 10); cairo_set_line_width (ctx, 10); - cairo_set_source_rgb (ctx, 0, 0, 0); + /// @todo uh??! why must the order of these arguments be reversed? bgra instead of rgba! + cairo_set_source_rgba (ctx, SP_RGBA32_B_F(gl->rgba), SP_RGBA32_G_F(gl->rgba), SP_RGBA32_R_F(gl->rgba), SP_RGBA32_A_F(gl->rgba)); unsigned int const r = NR_RGBA32_R (gl->rgba); unsigned int const g = NR_RGBA32_G (gl->rgba); @@ -274,9 +276,12 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point p return item; } -void sp_guideline_set_label(SPGuideLine *gl, char* label) +void sp_guideline_set_label(SPGuideLine *gl, const char* label) { - gl->label = label; + if (gl->label) { + g_free(gl->label); + } + gl->label = g_strdup(label); sp_canvas_item_request_update(SP_CANVAS_ITEM (gl)); } diff --git a/src/display/guideline.h b/src/display/guideline.h index dbf990d1f..dfc3b7007 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -48,7 +48,7 @@ GType sp_guideline_get_type(); SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point point_on_line, Geom::Point normal); -void sp_guideline_set_label(SPGuideLine *gl, char* label); +void sp_guideline_set_label(SPGuideLine *gl, const char* label); void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line); void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line); void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba); diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 1e51ee4d5..584a6a366 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -412,7 +412,7 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool */ } -void sp_guide_set_label(SPGuide &guide, char* label, bool const commit) +void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit) { g_assert(SP_IS_GUIDE(&guide)); if (guide.views){ @@ -421,7 +421,7 @@ void sp_guide_set_label(SPGuide &guide, char* label, bool const commit) if (commit){ //XML Tree being used directly while it shouldn't be - guide.getRepr()->setAttribute("label", label); + guide.getRepr()->setAttribute("inkscape:label", label); } } diff --git a/src/sp-guide.h b/src/sp-guide.h index 1dcdbc662..a164fda84 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -63,7 +63,7 @@ void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit); void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit); -void sp_guide_set_label(SPGuide &guide, char* const label, bool const commit); +void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit); void sp_guide_remove(SPGuide *guide); char *sp_guide_description(SPGuide const *guide, const bool verbose = true); diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 60038cab0..12aeddecc 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -42,6 +42,7 @@ GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop * _relative_toggle(_("Rela_tive change"), _("Move and/or rotate the guide relative to current settings")), _spin_button_x(_("X:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), _spin_button_y(_("Y:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _label_entry(_("Label:"), _("Optionally give this guideline a name")), _spin_angle(_("Angle:"), "", UNIT_TYPE_RADIAL), _mode(true), _oldpos(0.,0.), _oldangle(0.0) { @@ -104,6 +105,9 @@ void GuidelinePropertiesDialog::_onApply() sp_guide_moveto(*_guide, newpos, true); + const gchar* name = _label_entry.getEntry()->get_text().c_str(); + sp_guide_set_label(*_guide, name, true); + DocumentUndo::done(_guide->document, SP_VERB_NONE, _("Set guide properties")); } @@ -167,8 +171,11 @@ void GuidelinePropertiesDialog::_setup() { _label_descr.set_alignment(0, 0.5); // indent - _layout_table.attach(*manage(new Gtk::Label(" ")), - 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); +// _layout_table.attach(*manage(new Gtk::Label(" ")), +// 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); + + _layout_table.attach(_label_entry, + 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ @@ -245,6 +252,9 @@ void GuidelinePropertiesDialog::_setup() { g_free(label); } + // init name entry + _label_entry.getEntry()->set_text(_guide->label ? _guide->label : ""); + _modeChanged(); // sets values of spinboxes. if ( _oldangle == 90. || _oldangle == 270. || _oldangle == -90. || _oldangle == -270.) { diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index f015c49ff..efef0142b 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -24,6 +24,7 @@ #include "ui/widget/spinbutton.h" #include "ui/widget/unit-menu.h" #include "ui/widget/scalar-unit.h" +#include "ui/widget/entry.h" #include <2geom/point.h> class SPGuide; @@ -71,6 +72,7 @@ private: Inkscape::UI::Widget::UnitMenu _unit_menu; Inkscape::UI::Widget::ScalarUnit _spin_button_x; Inkscape::UI::Widget::ScalarUnit _spin_button_y; + Inkscape::UI::Widget::Entry _label_entry; Inkscape::UI::Widget::ScalarUnit _spin_angle; static Glib::ustring _angle_unit_status; // remember the status of the _relative_toggle_status button across instances |
