diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2011-06-18 08:51:28 +0000 |
|---|---|---|
| committer | Felipe C. da S. Sanches <juca@members.fsf.org> | 2011-06-18 08:51:28 +0000 |
| commit | 637e36780dacfed78c322064e322f247bd764fd1 (patch) | |
| tree | 66c8f43162231ba5e5ddf3b12ded0b0b320f4f70 /src | |
| parent | cmake: correct syntax error. (diff) | |
| download | inkscape-637e36780dacfed78c322064e322f247bd764fd1.tar.gz inkscape-637e36780dacfed78c322064e322f247bd764fd1.zip | |
user interface for selecting colors of guidelines
(bzr r10315)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-guide.cpp | 17 | ||||
| -rw-r--r-- | src/sp-guide.h | 1 | ||||
| -rw-r--r-- | src/ui/dialog/guides.cpp | 16 | ||||
| -rw-r--r-- | src/ui/dialog/guides.h | 3 |
4 files changed, 37 insertions, 0 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 584a6a366..19b64eb1a 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -412,6 +412,23 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool */ } +void sp_guide_set_color(SPGuide &guide, const unsigned char r, const unsigned char g, const unsigned char b, bool const commit) +{ + g_assert(SP_IS_GUIDE(&guide)); + guide.color = (r << 24) | (g << 16) | (b << 8) | 0x7f; + + if (guide.views){ + sp_guideline_set_color(SP_GUIDELINE(guide.views->data), guide.color); + } + + if (commit){ + std::ostringstream os; + os << "rgb(" << r << "," << g << "," << b << ")"; + //XML Tree being used directly while it shouldn't be + guide.getRepr()->setAttribute("inkscape:color", os.str().c_str()); + } +} + void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit) { g_assert(SP_IS_GUIDE(&guide)); diff --git a/src/sp-guide.h b/src/sp-guide.h index a164fda84..8cf9c7dc2 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -64,6 +64,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, const char* label, bool const commit); +void sp_guide_set_color(SPGuide &guide, const unsigned char r, const unsigned char g, const unsigned char b, 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 da517ba1a..3e324ca67 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -63,6 +63,14 @@ void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { dialog.run(); } +void GuidelinePropertiesDialog::_colorChanged() +{ + const Gdk::Color c = _color.get_color(); + char r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; + //TODO: why 257? verify this! + sp_guide_set_color(*_guide, r, g, b, true); +} + void GuidelinePropertiesDialog::_modeChanged() { _mode = !_relative_toggle.get_active(); @@ -177,6 +185,11 @@ void GuidelinePropertiesDialog::_setup() { _layout_table.attach(_label_entry, 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _layout_table.attach(_color, + 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _color.signal_color_set().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_colorChanged)); + + // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ _unit_menu.setUnitType(UNIT_TYPE_LINEAR); @@ -254,6 +267,9 @@ void GuidelinePropertiesDialog::_setup() { // init name entry _label_entry.getEntry()->set_text(_guide->label ? _guide->label : ""); + Gdk::Color c; + c.set_rgb_p(((_guide->color>>24)&0xff) / 255.0, ((_guide->color>>16)&0xff) / 255.0, ((_guide->color>>8)&0xff) / 255.0); + _color.set_color(c); _modeChanged(); // sets values of spinboxes. diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index efef0142b..88d0310b9 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -20,6 +20,7 @@ #include <gtkmm/label.h> #include <gtkmm/stock.h> #include <gtkmm/adjustment.h> +#include <gtkmm/colorbutton.h> #include "ui/widget/button.h" #include "ui/widget/spinbutton.h" #include "ui/widget/unit-menu.h" @@ -57,6 +58,7 @@ protected: void _response(gint response); void _modeChanged(); + void _colorChanged(); private: GuidelinePropertiesDialog(GuidelinePropertiesDialog const &); // no copy @@ -73,6 +75,7 @@ private: Inkscape::UI::Widget::ScalarUnit _spin_button_x; Inkscape::UI::Widget::ScalarUnit _spin_button_y; Inkscape::UI::Widget::Entry _label_entry; + Gtk::ColorButton _color; Inkscape::UI::Widget::ScalarUnit _spin_angle; static Glib::ustring _angle_unit_status; // remember the status of the _relative_toggle_status button across instances |
