Merge lp:~penginsbacon/inkscape/fill-n-stroke-cppify into lp:~inkscape.dev/inkscape/trunk
- fill-n-stroke-cppify
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~penginsbacon/inkscape/fill-n-stroke-cppify |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
10178 lines (+3899/-4073) 45 files modified
src/desktop-style.cpp (+2/-2) src/extension/internal/cairo-render-context.cpp (+8/-9) src/extension/internal/emf-print.cpp (+4/-4) src/extension/internal/wmf-print.cpp (+2/-2) src/extension/param/color.cpp (+32/-41) src/extension/param/color.h (+7/-2) src/extension/param/parameter.cpp (+5/-2) src/knot-holder-entity.cpp (+9/-9) src/selection-chemistry.cpp (+5/-5) src/sp-item.cpp (+4/-4) src/sp-pattern.cpp (+387/-402) src/sp-pattern.h (+98/-65) src/ui/CMakeLists.txt (+14/-0) src/ui/Makefile_insert (+2/-0) src/ui/dialog/objects.cpp (+17/-20) src/ui/dialog/objects.h (+6/-3) src/ui/dialog/tags.cpp (+1/-1) src/ui/selected-color.cpp (+163/-0) src/ui/selected-color.h (+96/-0) src/ui/widget/Makefile_insert (+12/-0) src/ui/widget/color-entry.cpp (+104/-0) src/ui/widget/color-entry.h (+53/-0) src/ui/widget/color-icc-selector.cpp (+586/-620) src/ui/widget/color-icc-selector.h (+41/-35) src/ui/widget/color-notebook.cpp (+226/-673) src/ui/widget/color-notebook.h (+61/-82) src/ui/widget/color-picker.cpp (+31/-41) src/ui/widget/color-picker.h (+5/-3) src/ui/widget/color-scales.cpp (+594/-677) src/ui/widget/color-scales.h (+66/-56) src/ui/widget/color-slider.cpp (+611/-727) src/ui/widget/color-slider.h (+99/-49) src/ui/widget/color-wheel-selector.cpp (+239/-285) src/ui/widget/color-wheel-selector.h (+75/-56) src/widgets/CMakeLists.txt (+0/-10) src/widgets/Makefile_insert (+0/-10) src/widgets/fill-style.cpp (+4/-6) src/widgets/gradient-selector.cpp (+4/-0) src/widgets/gradient-vector.cpp (+58/-24) src/widgets/paint-selector.cpp (+75/-67) src/widgets/paint-selector.h (+14/-5) src/widgets/sp-color-selector.cpp (+6/-1) src/widgets/sp-color-selector.h (+8/-0) src/widgets/swatch-selector.cpp (+58/-70) src/widgets/swatch-selector.h (+7/-5) |
To merge this branch: | bzr merge lp:~penginsbacon/inkscape/fill-n-stroke-cppify |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tavmjong Bah | Needs Fixing | ||
Review via email: mp+258120@code.launchpad.net |
This proposal supersedes a proposal from 2015-04-26.
This proposal has been superseded by a proposal from 2015-05-17.
Commit message
Description of the change
This branch merges the c++-sification effort from GSOC 2014 project.
Refactored classes are related to fill'n'stroke dialog. The list includes:
SPColorSelector
SPColorWheelSel
SPColorICCSelector
SPColorScales
SPNotebook
SPColorSlider
SPPattern
Tavmjong Bah (tavmjong-free) wrote : Posted in a previous version of this proposal | # |
Tavmjong Bah (tavmjong-free) wrote : | # |
Bugs:
1. Crash when selecting an object with a gradient and then clicking the solid color icon.
2. Color selection dialog doesn't remember last open tab (always opens in HSL even if RGB was last used tab).
3. First time dialog opened, there is an extra row in the RGB and HSL tabs.
At least #1 needs fixing before the code can be checked in.
- 14080. By Tomasz Boczkowski
-
merged trunk
- 14081. By Tomasz Boczkowski
-
Using MODE_SOLID_COLOR in paint selector instead of duplicated MODE_COLOR_RGB and MODE_COLOR_CMYK
- 14082. By Tomasz Boczkowski
-
fixed crash in paint selector when changing from gradient to solid color
- 14083. By Tomasz Boczkowski
-
merged trunk
- 14084. By Tomasz Boczkowski
-
fixed color selector not remembering it's last open tab
- 14085. By Tomasz Boczkowski
-
merged trunk
Tomasz Boczkowski (penginsbacon) wrote : | # |
I've fixed the bugs #1 and #2 in fill-n-
I cannot reproduce #3 on my computer. Could you please send me a screenshot?
On Sun, May 3, 2015 at 9:32 PM, Tavmjong Bah <email address hidden> wrote:
> Review: Needs Fixing
>
> Bugs:
>
> 1. Crash when selecting an object with a gradient and then clicking the
> solid color icon.
>
> 2. Color selection dialog doesn't remember last open tab (always opens in
> HSL even if RGB was last used tab).
>
> 3. First time dialog opened, there is an extra row in the RGB and HSL tabs.
>
> At least #1 needs fixing before the code can be checked in.
>
>
> --
>
> https:/
> You are the owner of lp:~penginsbacon/inkscape/fill-n-stroke-cppify.
>
su_v (suv-lp) wrote : | # |
On 2015-05-12 24:42 (+0200), Tomasz Boczkowski wrote:
>> 3. First time dialog opened, there is an extra row in the RGB and
>> HSL tabs.
>
> I cannot reproduce #3 on my computer. Could you please send me a
> screenshot?
Steps to reproduce:
1) launch branch build with default (new) prefs
2) draw a rectangle
3) open Fill & Stroke
--> there's an additional color slider below the regular ones.
Screenshot:
https:/
Does not happen if nothing is selected when opening Fill & Stroke for the first time in the current session.
su_v (suv-lp) wrote : | # |
Another regression (reproduced with r14085):
Steps to reproduce:
1) launch branch build with default (new) prefs
2) draw a rect
3) draw an ellipse
4) group ellipse (Ctrl+G)
5) deselect everything (<esc>)
6) open fill&stroke dialog
7) select rect
--> fill shows blue paint as expected
8) select group
--> fill shows 'Paint is undefined' as expected
9) select again the rectangle
--> fill shows solid white paint (incorrect)
Seems to be triggered after having selected an object with undefined style property (can be reproduced e.g. with clones, and with stroke paint, too).
- 14086. By Tomasz Boczkowski
-
merged trunk
- 14087. By Tomasz Boczkowski
-
fixed: color scales - extra row in RGB mode
- 14088. By Tomasz Boczkowski
-
fixed: color scales - updating color when switched from undefined
- 14089. By Tomasz Boczkowski
-
fixed: color icc selector - extra rows on startup
Unmerged revisions
Preview Diff
1 | === modified file 'src/desktop-style.cpp' | |||
2 | --- src/desktop-style.cpp 2015-05-16 12:50:10 +0000 | |||
3 | +++ src/desktop-style.cpp 2015-05-17 11:43:43 +0000 | |||
4 | @@ -576,8 +576,8 @@ | |||
5 | 576 | return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server | 576 | return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server |
6 | 577 | } | 577 | } |
7 | 578 | 578 | ||
10 | 579 | SPPattern *pat = pattern_getroot (pattern); | 579 | SPPattern *pat = SP_PATTERN (server)->rootPattern(); |
11 | 580 | SPPattern *pat_res = pattern_getroot (pattern_res); | 580 | SPPattern *pat_res = SP_PATTERN (server_res)->rootPattern(); |
12 | 581 | if (pat_res != pat) { | 581 | if (pat_res != pat) { |
13 | 582 | return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots | 582 | return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots |
14 | 583 | } | 583 | } |
15 | 584 | 584 | ||
16 | === modified file 'src/extension/internal/cairo-render-context.cpp' | |||
17 | --- src/extension/internal/cairo-render-context.cpp 2015-05-08 13:46:25 +0000 | |||
18 | +++ src/extension/internal/cairo-render-context.cpp 2015-05-17 11:43:43 +0000 | |||
19 | @@ -1008,17 +1008,16 @@ | |||
20 | 1008 | ps2user = Geom::identity(); | 1008 | ps2user = Geom::identity(); |
21 | 1009 | pcs2dev = Geom::identity(); | 1009 | pcs2dev = Geom::identity(); |
22 | 1010 | 1010 | ||
27 | 1011 | double x = pattern_x(pat); | 1011 | double x = pat->x(); |
28 | 1012 | double y = pattern_y(pat); | 1012 | double y = pat->y(); |
29 | 1013 | double width = pattern_width(pat); | 1013 | double width = pat->width(); |
30 | 1014 | double height = pattern_height(pat); | 1014 | double height = pat->height(); |
31 | 1015 | double bbox_width_scaler; | 1015 | double bbox_width_scaler; |
32 | 1016 | double bbox_height_scaler; | 1016 | double bbox_height_scaler; |
33 | 1017 | 1017 | ||
34 | 1018 | TRACE(("%f x %f pattern\n", width, height)); | 1018 | TRACE(("%f x %f pattern\n", width, height)); |
35 | 1019 | 1019 | ||
38 | 1020 | if (pbox && pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { | 1020 | if (pbox && pat->patternUnits() == SPPattern::UNITS_OBJECTBOUNDINGBOX) { |
37 | 1021 | //Geom::Affine bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); | ||
39 | 1022 | bbox_width_scaler = pbox->width(); | 1021 | bbox_width_scaler = pbox->width(); |
40 | 1023 | bbox_height_scaler = pbox->height(); | 1022 | bbox_height_scaler = pbox->height(); |
41 | 1024 | ps2user[4] = x * bbox_width_scaler + pbox->left(); | 1023 | ps2user[4] = x * bbox_width_scaler + pbox->left(); |
42 | @@ -1031,13 +1030,13 @@ | |||
43 | 1031 | } | 1030 | } |
44 | 1032 | 1031 | ||
45 | 1033 | // apply pattern transformation | 1032 | // apply pattern transformation |
47 | 1034 | Geom::Affine pattern_transform(pattern_patternTransform(pat)); | 1033 | Geom::Affine pattern_transform(pat->getTransform()); |
48 | 1035 | ps2user *= pattern_transform; | 1034 | ps2user *= pattern_transform; |
49 | 1036 | Geom::Point ori (ps2user[4], ps2user[5]); | 1035 | Geom::Point ori (ps2user[4], ps2user[5]); |
50 | 1037 | 1036 | ||
51 | 1038 | // create pattern contents coordinate system | 1037 | // create pattern contents coordinate system |
52 | 1039 | if (pat->viewBox_set) { | 1038 | if (pat->viewBox_set) { |
54 | 1040 | Geom::Rect view_box = *pattern_viewBox(pat); | 1039 | Geom::Rect view_box = *pat->viewbox(); |
55 | 1041 | 1040 | ||
56 | 1042 | double x, y, w, h; | 1041 | double x, y, w, h; |
57 | 1043 | x = 0; | 1042 | x = 0; |
58 | @@ -1050,7 +1049,7 @@ | |||
59 | 1050 | pcs2dev[3] = h / view_box.height(); | 1049 | pcs2dev[3] = h / view_box.height(); |
60 | 1051 | pcs2dev[4] = x - view_box.left() * pcs2dev[0]; | 1050 | pcs2dev[4] = x - view_box.left() * pcs2dev[0]; |
61 | 1052 | pcs2dev[5] = y - view_box.top() * pcs2dev[3]; | 1051 | pcs2dev[5] = y - view_box.top() * pcs2dev[3]; |
63 | 1053 | } else if (pbox && pattern_patternContentUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { | 1052 | } else if (pbox && pat->patternContentUnits() == SPPattern::UNITS_OBJECTBOUNDINGBOX) { |
64 | 1054 | pcs2dev[0] = pbox->width(); | 1053 | pcs2dev[0] = pbox->width(); |
65 | 1055 | pcs2dev[3] = pbox->height(); | 1054 | pcs2dev[3] = pbox->height(); |
66 | 1056 | } | 1055 | } |
67 | 1057 | 1056 | ||
68 | === modified file 'src/extension/internal/emf-print.cpp' | |||
69 | --- src/extension/internal/emf-print.cpp 2015-04-27 18:49:22 +0000 | |||
70 | +++ src/extension/internal/emf-print.cpp 2015-05-17 11:43:43 +0000 | |||
71 | @@ -388,8 +388,8 @@ | |||
72 | 388 | } else if (SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style))) { // must be paint-server | 388 | } else if (SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style))) { // must be paint-server |
73 | 389 | SPPaintServer *paintserver = style->fill.value.href->getObject(); | 389 | SPPaintServer *paintserver = style->fill.value.href->getObject(); |
74 | 390 | SPPattern *pat = SP_PATTERN(paintserver); | 390 | SPPattern *pat = SP_PATTERN(paintserver); |
77 | 391 | double dwidth = pattern_width(pat); | 391 | double dwidth = pat->width(); |
78 | 392 | double dheight = pattern_height(pat); | 392 | double dheight = pat->height(); |
79 | 393 | width = dwidth; | 393 | width = dwidth; |
80 | 394 | height = dheight; | 394 | height = dheight; |
81 | 395 | brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); | 395 | brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); |
82 | @@ -573,8 +573,8 @@ | |||
83 | 573 | if (SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style))) { // must be paint-server | 573 | if (SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style))) { // must be paint-server |
84 | 574 | SPPaintServer *paintserver = style->stroke.value.href->getObject(); | 574 | SPPaintServer *paintserver = style->stroke.value.href->getObject(); |
85 | 575 | SPPattern *pat = SP_PATTERN(paintserver); | 575 | SPPattern *pat = SP_PATTERN(paintserver); |
88 | 576 | double dwidth = pattern_width(pat); | 576 | double dwidth = pat->width(); |
89 | 577 | double dheight = pattern_height(pat); | 577 | double dheight = pat->height(); |
90 | 578 | width = dwidth; | 578 | width = dwidth; |
91 | 579 | height = dheight; | 579 | height = dheight; |
92 | 580 | brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); | 580 | brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); |
93 | 581 | 581 | ||
94 | === modified file 'src/extension/internal/wmf-print.cpp' | |||
95 | --- src/extension/internal/wmf-print.cpp 2015-04-27 18:49:22 +0000 | |||
96 | +++ src/extension/internal/wmf-print.cpp 2015-05-17 11:43:43 +0000 | |||
97 | @@ -380,8 +380,8 @@ | |||
98 | 380 | } else if (SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style))) { // must be paint-server | 380 | } else if (SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style))) { // must be paint-server |
99 | 381 | SPPaintServer *paintserver = style->fill.value.href->getObject(); | 381 | SPPaintServer *paintserver = style->fill.value.href->getObject(); |
100 | 382 | SPPattern *pat = SP_PATTERN(paintserver); | 382 | SPPattern *pat = SP_PATTERN(paintserver); |
103 | 383 | double dwidth = pattern_width(pat); | 383 | double dwidth = pat->width(); |
104 | 384 | double dheight = pattern_height(pat); | 384 | double dheight = pat->height(); |
105 | 385 | width = dwidth; | 385 | width = dwidth; |
106 | 386 | height = dheight; | 386 | height = dheight; |
107 | 387 | brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); | 387 | brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); |
108 | 388 | 388 | ||
109 | === modified file 'src/extension/param/color.cpp' | |||
110 | --- src/extension/param/color.cpp 2015-04-27 23:38:31 +0000 | |||
111 | +++ src/extension/param/color.cpp 2015-05-17 11:43:43 +0000 | |||
112 | @@ -24,41 +24,37 @@ | |||
113 | 24 | #include "color.h" | 24 | #include "color.h" |
114 | 25 | 25 | ||
115 | 26 | #include <color.h> | 26 | #include <color.h> |
118 | 27 | #include "widgets/sp-color-selector.h" | 27 | #include "ui/widget/color-notebook.h" |
117 | 28 | #include "widgets/sp-color-notebook.h" | ||
119 | 29 | #include "preferences.h" | 28 | #include "preferences.h" |
120 | 30 | 29 | ||
121 | 31 | |||
122 | 32 | namespace Inkscape { | 30 | namespace Inkscape { |
123 | 33 | namespace Extension { | 31 | namespace Extension { |
124 | 34 | 32 | ||
125 | 35 | void sp_color_param_changed(SPColorSelector *csel, GObject *cp); | ||
126 | 36 | |||
127 | 37 | |||
128 | 38 | ParamColor::~ParamColor(void) | 33 | ParamColor::~ParamColor(void) |
129 | 39 | { | 34 | { |
131 | 40 | 35 | _color_changed.disconnect(); | |
132 | 41 | } | 36 | } |
133 | 42 | 37 | ||
134 | 43 | guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) | 38 | guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) |
135 | 44 | { | 39 | { |
137 | 45 | _value = in; | 40 | _color_changed.block(true); |
138 | 41 | _color.setValue(in); | ||
139 | 42 | _color_changed.block(false); | ||
140 | 46 | 43 | ||
141 | 47 | gchar * prefname = this->pref_name(); | 44 | gchar * prefname = this->pref_name(); |
142 | 48 | std::string value; | 45 | std::string value; |
143 | 49 | string(value); | 46 | string(value); |
145 | 50 | 47 | ||
146 | 51 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 48 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
147 | 52 | prefs->setString(extension_pref_root + prefname, value); | 49 | prefs->setString(extension_pref_root + prefname, value); |
148 | 53 | g_free(prefname); | 50 | g_free(prefname); |
149 | 54 | 51 | ||
151 | 55 | return _value; | 52 | return in; |
152 | 56 | } | 53 | } |
153 | 57 | 54 | ||
158 | 58 | ParamColor::ParamColor(const gchar *name, const gchar *guitext, const gchar *desc, const Parameter::_scope_t scope, | 55 | ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : |
159 | 59 | bool gui_hidden, const gchar *gui_tip, Inkscape::Extension::Extension *ext, | 56 | Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), |
160 | 60 | Inkscape::XML::Node *xml) | 57 | _changeSignal(0) |
157 | 61 | : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0), _changeSignal(0) | ||
161 | 62 | { | 58 | { |
162 | 63 | const char * defaulthex = NULL; | 59 | const char * defaulthex = NULL; |
163 | 64 | if (xml->firstChild() != NULL) | 60 | if (xml->firstChild() != NULL) |
164 | @@ -72,51 +68,46 @@ | |||
165 | 72 | if (!paramval.empty()) | 68 | if (!paramval.empty()) |
166 | 73 | defaulthex = paramval.data(); | 69 | defaulthex = paramval.data(); |
167 | 74 | 70 | ||
170 | 75 | if (defaulthex) | 71 | if (defaulthex) { |
171 | 76 | _value = atoi(defaulthex); | 72 | _color.setValue(atoi(defaulthex)); |
172 | 73 | } | ||
173 | 74 | _color_changed = _color.signal_changed.connect(sigc::mem_fun(this, &ParamColor::_onColorChanged)); | ||
174 | 75 | |||
175 | 77 | } | 76 | } |
176 | 78 | 77 | ||
177 | 79 | void ParamColor::string(std::string &string) const | 78 | void ParamColor::string(std::string &string) const |
178 | 80 | { | 79 | { |
179 | 81 | char str[16]; | 80 | char str[16]; |
181 | 82 | sprintf(str, "%i", _value); | 81 | snprintf(str, 16, "%i", _color.value()); |
182 | 83 | string += str; | 82 | string += str; |
183 | 84 | } | 83 | } |
184 | 85 | 84 | ||
185 | 86 | Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal ) | 85 | Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal ) |
186 | 87 | { | 86 | { |
188 | 88 | if (_gui_hidden) return NULL; | 87 | using Inkscape::UI::Widget::ColorNotebook; |
189 | 88 | |||
190 | 89 | if (_gui_hidden) return NULL; | ||
191 | 89 | 90 | ||
192 | 90 | _changeSignal = new sigc::signal<void>(*changeSignal); | 91 | _changeSignal = new sigc::signal<void>(*changeSignal); |
193 | 91 | Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); | ||
194 | 92 | SPColorSelector* spColorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK); | ||
195 | 93 | 92 | ||
199 | 94 | ColorSelector* colorSelector = spColorSelector->base; | 93 | if (_color.value() < 1) { |
200 | 95 | if (_value < 1) { | 94 | _color_changed.block(true); |
201 | 96 | _value = 0xFF000000; | 95 | _color.setValue(0xFF000000); |
202 | 96 | _color_changed.block(false); | ||
203 | 97 | } | 97 | } |
212 | 98 | SPColor *color = new SPColor( _value ); | 98 | |
213 | 99 | float alpha = (_value & 0xff) / 255.0F; | 99 | Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, 4)); |
214 | 100 | colorSelector->setColorAlpha(*color, alpha); | 100 | Gtk::Widget *selector = Gtk::manage(new ColorNotebook(_color)); |
215 | 101 | 101 | hbox->pack_start (*selector, true, true, 0); | |
216 | 102 | hbox->pack_start (*Glib::wrap(&spColorSelector->vbox), true, true, 0); | 102 | selector->show(); |
209 | 103 | g_signal_connect(G_OBJECT(spColorSelector), "changed", G_CALLBACK(sp_color_param_changed), (void*)this); | ||
210 | 104 | |||
211 | 105 | gtk_widget_show(GTK_WIDGET(spColorSelector)); | ||
217 | 106 | hbox->show(); | 103 | hbox->show(); |
220 | 107 | 104 | return hbox; | |
219 | 108 | return dynamic_cast<Gtk::Widget *>(hbox); | ||
221 | 109 | } | 105 | } |
222 | 110 | 106 | ||
224 | 111 | void sp_color_param_changed(SPColorSelector *csel, GObject *obj) | 107 | void ParamColor::_onColorChanged() |
225 | 112 | { | 108 | { |
233 | 113 | const SPColor color = csel->base->getColor(); | 109 | if (_changeSignal) |
234 | 114 | float alpha = csel->base->getAlpha(); | 110 | _changeSignal->emit(); |
228 | 115 | |||
229 | 116 | ParamColor* ptr = reinterpret_cast<ParamColor*>(obj); | ||
230 | 117 | ptr->set(color.toRGBA32( alpha ), NULL, NULL); | ||
231 | 118 | |||
232 | 119 | ptr->_changeSignal->emit(); | ||
235 | 120 | } | 111 | } |
236 | 121 | 112 | ||
237 | 122 | }; /* namespace Extension */ | 113 | }; /* namespace Extension */ |
238 | 123 | 114 | ||
239 | === modified file 'src/extension/param/color.h' | |||
240 | --- src/extension/param/color.h 2012-02-29 01:16:51 +0000 | |||
241 | +++ src/extension/param/color.h 2015-05-17 11:43:43 +0000 | |||
242 | @@ -9,6 +9,7 @@ | |||
243 | 9 | */ | 9 | */ |
244 | 10 | 10 | ||
245 | 11 | #include "parameter.h" | 11 | #include "parameter.h" |
246 | 12 | #include "ui/selected-color.h" | ||
247 | 12 | 13 | ||
248 | 13 | class SPDocument; | 14 | class SPDocument; |
249 | 14 | 15 | ||
250 | @@ -25,14 +26,17 @@ | |||
251 | 25 | 26 | ||
252 | 26 | class ParamColor : public Parameter { | 27 | class ParamColor : public Parameter { |
253 | 27 | private: | 28 | private: |
255 | 28 | guint32 _value; | 29 | void _onColorChanged(); |
256 | 30 | |||
257 | 31 | Inkscape::UI::SelectedColor _color; | ||
258 | 32 | sigc::connection _color_changed; | ||
259 | 29 | public: | 33 | public: |
260 | 30 | ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); | 34 | ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); |
261 | 31 | 35 | ||
262 | 32 | virtual ~ParamColor(void); | 36 | virtual ~ParamColor(void); |
263 | 33 | 37 | ||
264 | 34 | /** Returns \c _value, with a \i const to protect it. */ | 38 | /** Returns \c _value, with a \i const to protect it. */ |
266 | 35 | guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _value; } | 39 | guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _color.value(); } |
267 | 36 | 40 | ||
268 | 37 | guint32 set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); | 41 | guint32 set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); |
269 | 38 | 42 | ||
270 | @@ -44,6 +48,7 @@ | |||
271 | 44 | virtual void string (std::string &string) const; | 48 | virtual void string (std::string &string) const; |
272 | 45 | 49 | ||
273 | 46 | sigc::signal<void> * _changeSignal; | 50 | sigc::signal<void> * _changeSignal; |
274 | 51 | |||
275 | 47 | }; // class ParamColor | 52 | }; // class ParamColor |
276 | 48 | 53 | ||
277 | 49 | } // namespace Extension | 54 | } // namespace Extension |
278 | 50 | 55 | ||
279 | === modified file 'src/extension/param/parameter.cpp' | |||
280 | --- src/extension/param/parameter.cpp 2014-03-27 01:33:44 +0000 | |||
281 | +++ src/extension/param/parameter.cpp 2015-05-17 11:43:43 +0000 | |||
282 | @@ -15,6 +15,10 @@ | |||
283 | 15 | # include "config.h" | 15 | # include "config.h" |
284 | 16 | #endif | 16 | #endif |
285 | 17 | 17 | ||
286 | 18 | #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H | ||
287 | 19 | #include <glibmm/threads.h> | ||
288 | 20 | #endif | ||
289 | 21 | |||
290 | 18 | #ifdef linux // does the dollar sign need escaping when passed as string parameter? | 22 | #ifdef linux // does the dollar sign need escaping when passed as string parameter? |
291 | 19 | # define ESCAPE_DOLLAR_COMMANDLINE | 23 | # define ESCAPE_DOLLAR_COMMANDLINE |
292 | 20 | #endif | 24 | #endif |
293 | @@ -26,8 +30,7 @@ | |||
294 | 26 | #include "document-private.h" | 30 | #include "document-private.h" |
295 | 27 | #include "sp-object.h" | 31 | #include "sp-object.h" |
296 | 28 | #include <color.h> | 32 | #include <color.h> |
299 | 29 | #include "widgets/sp-color-selector.h" | 33 | #include "ui/widget/color-notebook.h" |
298 | 30 | #include "widgets/sp-color-notebook.h" | ||
300 | 31 | 34 | ||
301 | 32 | #include "parameter.h" | 35 | #include "parameter.h" |
302 | 33 | #include "bool.h" | 36 | #include "bool.h" |
303 | 34 | 37 | ||
304 | === modified file 'src/knot-holder-entity.cpp' | |||
305 | --- src/knot-holder-entity.cpp 2014-08-04 16:10:37 +0000 | |||
306 | +++ src/knot-holder-entity.cpp 2015-05-17 11:43:43 +0000 | |||
307 | @@ -140,19 +140,19 @@ | |||
308 | 140 | 140 | ||
309 | 141 | static gdouble sp_pattern_extract_theta(SPPattern const *pat) | 141 | static gdouble sp_pattern_extract_theta(SPPattern const *pat) |
310 | 142 | { | 142 | { |
312 | 143 | Geom::Affine transf = pat->patternTransform; | 143 | Geom::Affine transf = pat->getTransform(); |
313 | 144 | return Geom::atan2(transf.xAxis()); | 144 | return Geom::atan2(transf.xAxis()); |
314 | 145 | } | 145 | } |
315 | 146 | 146 | ||
316 | 147 | static Geom::Point sp_pattern_extract_scale(SPPattern const *pat) | 147 | static Geom::Point sp_pattern_extract_scale(SPPattern const *pat) |
317 | 148 | { | 148 | { |
319 | 149 | Geom::Affine transf = pat->patternTransform; | 149 | Geom::Affine transf = pat->getTransform(); |
320 | 150 | return Geom::Point( transf.expansionX(), transf.expansionY() ); | 150 | return Geom::Point( transf.expansionX(), transf.expansionY() ); |
321 | 151 | } | 151 | } |
322 | 152 | 152 | ||
323 | 153 | static Geom::Point sp_pattern_extract_trans(SPPattern const *pat) | 153 | static Geom::Point sp_pattern_extract_trans(SPPattern const *pat) |
324 | 154 | { | 154 | { |
326 | 155 | return Geom::Point(pat->patternTransform[4], pat->patternTransform[5]); | 155 | return Geom::Point(pat->getTransform()[4], pat->getTransform()[5]); |
327 | 156 | } | 156 | } |
328 | 157 | 157 | ||
329 | 158 | void | 158 | void |
330 | @@ -191,7 +191,7 @@ | |||
331 | 191 | { | 191 | { |
332 | 192 | SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer()); | 192 | SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer()); |
333 | 193 | 193 | ||
335 | 194 | gdouble x = pattern_width(pat); | 194 | gdouble x = pat->width(); |
336 | 195 | gdouble y = 0; | 195 | gdouble y = 0; |
337 | 196 | Geom::Point delta = Geom::Point(x,y); | 196 | Geom::Point delta = Geom::Point(x,y); |
338 | 197 | Geom::Point scale = sp_pattern_extract_scale(pat); | 197 | Geom::Point scale = sp_pattern_extract_scale(pat); |
339 | @@ -240,8 +240,8 @@ | |||
340 | 240 | 240 | ||
341 | 241 | // Get the new scale from the position of the knotholder | 241 | // Get the new scale from the position of the knotholder |
342 | 242 | Geom::Point d = p_snapped - sp_pattern_extract_trans(pat); | 242 | Geom::Point d = p_snapped - sp_pattern_extract_trans(pat); |
345 | 243 | gdouble pat_x = pattern_width(pat); | 243 | gdouble pat_x = pat->width(); |
346 | 244 | gdouble pat_y = pattern_height(pat); | 244 | gdouble pat_y = pat->height(); |
347 | 245 | Geom::Scale scl(1); | 245 | Geom::Scale scl(1); |
348 | 246 | if ( state & GDK_CONTROL_MASK ) { | 246 | if ( state & GDK_CONTROL_MASK ) { |
349 | 247 | // if ctrl is pressed: use 1:1 scaling | 247 | // if ctrl is pressed: use 1:1 scaling |
350 | @@ -267,10 +267,10 @@ | |||
351 | 267 | { | 267 | { |
352 | 268 | SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer()); | 268 | SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer()); |
353 | 269 | 269 | ||
356 | 270 | gdouble x = pattern_width(pat); | 270 | gdouble x = pat->width(); |
357 | 271 | gdouble y = pattern_height(pat); | 271 | gdouble y = pat->height(); |
358 | 272 | Geom::Point delta = Geom::Point(x,y); | 272 | Geom::Point delta = Geom::Point(x,y); |
360 | 273 | Geom::Affine a = pat->patternTransform; | 273 | Geom::Affine a = pat->getTransform(); |
361 | 274 | a[4] = 0; | 274 | a[4] = 0; |
362 | 275 | a[5] = 0; | 275 | a[5] = 0; |
363 | 276 | delta = delta * a; | 276 | delta = delta * a; |
364 | 277 | 277 | ||
365 | === modified file 'src/selection-chemistry.cpp' | |||
366 | --- src/selection-chemistry.cpp 2015-05-09 12:59:00 +0000 | |||
367 | +++ src/selection-chemistry.cpp 2015-05-17 11:43:43 +0000 | |||
368 | @@ -1963,8 +1963,8 @@ | |||
369 | 1963 | } | 1963 | } |
370 | 1964 | 1964 | ||
371 | 1965 | } else if (dynamic_cast<SPPattern *>(sel_server) && dynamic_cast<SPPattern *>(iter_server)) { | 1965 | } else if (dynamic_cast<SPPattern *>(sel_server) && dynamic_cast<SPPattern *>(iter_server)) { |
374 | 1966 | SPPattern *sel_pat = pattern_getroot(dynamic_cast<SPPattern *>(sel_server)); | 1966 | SPPattern *sel_pat = dynamic_cast<SPPattern *>(sel_server)->rootPattern(); |
375 | 1967 | SPPattern *iter_pat = pattern_getroot(dynamic_cast<SPPattern *>(iter_server)); | 1967 | SPPattern *iter_pat = dynamic_cast<SPPattern *>(iter_server)->rootPattern(); |
376 | 1968 | if (sel_pat == iter_pat) { | 1968 | if (sel_pat == iter_pat) { |
377 | 1969 | match = true; | 1969 | match = true; |
378 | 1970 | } | 1970 | } |
379 | @@ -3312,7 +3312,7 @@ | |||
380 | 3312 | int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); | 3312 | int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); |
381 | 3313 | prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); | 3313 | prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); |
382 | 3314 | 3314 | ||
384 | 3315 | gchar const *pat_id = pattern_tile(repr_copies, bbox, doc, | 3315 | gchar const *pat_id = SPPattern::produce(repr_copies, bbox, doc, |
385 | 3316 | ( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X], | 3316 | ( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X], |
386 | 3317 | r->max()[Geom::Y])))) | 3317 | r->max()[Geom::Y])))) |
387 | 3318 | * parent_transform.inverse() ), | 3318 | * parent_transform.inverse() ), |
388 | @@ -3390,9 +3390,9 @@ | |||
389 | 3390 | 3390 | ||
390 | 3391 | did = true; | 3391 | did = true; |
391 | 3392 | 3392 | ||
393 | 3393 | SPPattern *pattern = pattern_getroot(basePat); | 3393 | SPPattern *pattern = basePat->rootPattern(); |
394 | 3394 | 3394 | ||
396 | 3395 | Geom::Affine pat_transform = pattern_patternTransform(basePat); | 3395 | Geom::Affine pat_transform = basePat->getTransform(); |
397 | 3396 | pat_transform *= item->transform; | 3396 | pat_transform *= item->transform; |
398 | 3397 | 3397 | ||
399 | 3398 | for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) { | 3398 | for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) { |
400 | 3399 | 3399 | ||
401 | === modified file 'src/sp-item.cpp' | |||
402 | --- src/sp-item.cpp 2015-05-10 21:55:55 +0000 | |||
403 | +++ src/sp-item.cpp 2015-05-17 11:43:43 +0000 | |||
404 | @@ -1222,8 +1222,8 @@ | |||
405 | 1222 | SPObject *server = style->getFillPaintServer(); | 1222 | SPObject *server = style->getFillPaintServer(); |
406 | 1223 | SPPattern *serverPatt = dynamic_cast<SPPattern *>(server); | 1223 | SPPattern *serverPatt = dynamic_cast<SPPattern *>(server); |
407 | 1224 | if ( serverPatt ) { | 1224 | if ( serverPatt ) { |
410 | 1225 | SPPattern *pattern = sp_pattern_clone_if_necessary(this, serverPatt, "fill"); | 1225 | SPPattern *pattern = serverPatt->clone_if_necessary(this, "fill"); |
411 | 1226 | sp_pattern_transform_multiply(pattern, postmul, set); | 1226 | pattern->transform_multiply(postmul, set); |
412 | 1227 | } | 1227 | } |
413 | 1228 | } | 1228 | } |
414 | 1229 | 1229 | ||
415 | @@ -1232,8 +1232,8 @@ | |||
416 | 1232 | SPObject *server = style->getStrokePaintServer(); | 1232 | SPObject *server = style->getStrokePaintServer(); |
417 | 1233 | SPPattern *serverPatt = dynamic_cast<SPPattern *>(server); | 1233 | SPPattern *serverPatt = dynamic_cast<SPPattern *>(server); |
418 | 1234 | if ( serverPatt ) { | 1234 | if ( serverPatt ) { |
421 | 1235 | SPPattern *pattern = sp_pattern_clone_if_necessary(this, serverPatt, "stroke"); | 1235 | SPPattern *pattern = serverPatt->clone_if_necessary(this, "stroke"); |
422 | 1236 | sp_pattern_transform_multiply(pattern, postmul, set); | 1236 | pattern->transform_multiply(postmul, set); |
423 | 1237 | } | 1237 | } |
424 | 1238 | } | 1238 | } |
425 | 1239 | } | 1239 | } |
426 | 1240 | 1240 | ||
427 | === modified file 'src/sp-pattern.cpp' | |||
428 | --- src/sp-pattern.cpp 2015-04-26 09:44:42 +0000 | |||
429 | +++ src/sp-pattern.cpp 2015-05-17 11:43:43 +0000 | |||
430 | @@ -5,7 +5,7 @@ | |||
431 | 5 | * Lauris Kaplinski <lauris@kaplinski.com> | 5 | * Lauris Kaplinski <lauris@kaplinski.com> |
432 | 6 | * bulia byak <buliabyak@users.sf.net> | 6 | * bulia byak <buliabyak@users.sf.net> |
433 | 7 | * Jon A. Cruz <jon@joncruz.org> | 7 | * Jon A. Cruz <jon@joncruz.org> |
435 | 8 | * Abhishek Sharma | 8 | * Abhishek Sharma |
436 | 9 | * | 9 | * |
437 | 10 | * Copyright (C) 2002 Lauris Kaplinski | 10 | * Copyright (C) 2002 Lauris Kaplinski |
438 | 11 | * | 11 | * |
439 | @@ -13,15 +13,15 @@ | |||
440 | 13 | */ | 13 | */ |
441 | 14 | 14 | ||
442 | 15 | #ifdef HAVE_CONFIG_H | 15 | #ifdef HAVE_CONFIG_H |
444 | 16 | # include "config.h" | 16 | #include "config.h" |
445 | 17 | #endif | 17 | #endif |
446 | 18 | 18 | ||
447 | 19 | #include <cstring> | 19 | #include <cstring> |
448 | 20 | #include <string> | 20 | #include <string> |
449 | 21 | #include <glibmm.h> | 21 | #include <glibmm.h> |
450 | 22 | #include <2geom/transforms.h> | 22 | #include <2geom/transforms.h> |
451 | 23 | #include <sigc++/functors/mem_fun.h> | ||
452 | 23 | 24 | ||
453 | 24 | #include "macros.h" | ||
454 | 25 | #include "svg/svg.h" | 25 | #include "svg/svg.h" |
455 | 26 | #include "display/cairo-utils.h" | 26 | #include "display/cairo-utils.h" |
456 | 27 | #include "display/drawing-context.h" | 27 | #include "display/drawing-context.h" |
457 | @@ -34,67 +34,61 @@ | |||
458 | 34 | #include "style.h" | 34 | #include "style.h" |
459 | 35 | #include "sp-pattern.h" | 35 | #include "sp-pattern.h" |
460 | 36 | #include "xml/repr.h" | 36 | #include "xml/repr.h" |
515 | 37 | #include "display/grayscale.h" | 37 | |
516 | 38 | 38 | #include "sp-factory.h" | |
517 | 39 | #include <sigc++/functors/ptr_fun.h> | 39 | |
518 | 40 | #include <sigc++/adaptors/bind.h> | 40 | SPPattern::SPPattern() |
519 | 41 | 41 | : SPPaintServer() | |
520 | 42 | /* | 42 | , SPViewBox() |
521 | 43 | * Pattern | 43 | { |
522 | 44 | */ | 44 | this->ref = new SPPatternReference(this); |
523 | 45 | static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat); | 45 | this->ref->changedSignal().connect(sigc::mem_fun(this, &SPPattern::_onRefChanged)); |
524 | 46 | static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern); | 46 | |
525 | 47 | 47 | this->_pattern_units = UNITS_OBJECTBOUNDINGBOX; | |
526 | 48 | SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { | 48 | this->_pattern_units_set = false; |
527 | 49 | this->href = NULL; | 49 | |
528 | 50 | 50 | this->_pattern_content_units = UNITS_USERSPACEONUSE; | |
529 | 51 | this->ref = new SPPatternReference(this); | 51 | this->_pattern_content_units_set = false; |
530 | 52 | this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(pattern_ref_changed), this)); | 52 | |
531 | 53 | 53 | this->_pattern_transform = Geom::identity(); | |
532 | 54 | this->patternUnits = SP_PATTERN_UNITS_OBJECTBOUNDINGBOX; | 54 | this->_pattern_transform_set = false; |
533 | 55 | this->patternUnits_set = FALSE; | 55 | |
534 | 56 | 56 | this->_x.unset(); | |
535 | 57 | this->patternContentUnits = SP_PATTERN_UNITS_USERSPACEONUSE; | 57 | this->_y.unset(); |
536 | 58 | this->patternContentUnits_set = FALSE; | 58 | this->_width.unset(); |
537 | 59 | 59 | this->_height.unset(); | |
538 | 60 | this->patternTransform = Geom::identity(); | 60 | } |
539 | 61 | this->patternTransform_set = FALSE; | 61 | |
540 | 62 | 62 | SPPattern::~SPPattern() {} | |
541 | 63 | this->x.unset(); | 63 | |
542 | 64 | this->y.unset(); | 64 | void SPPattern::build(SPDocument *doc, Inkscape::XML::Node *repr) |
543 | 65 | this->width.unset(); | 65 | { |
544 | 66 | this->height.unset(); | 66 | SPPaintServer::build(doc, repr); |
545 | 67 | } | 67 | |
546 | 68 | 68 | this->readAttr("patternUnits"); | |
547 | 69 | SPPattern::~SPPattern() { | 69 | this->readAttr("patternContentUnits"); |
548 | 70 | } | 70 | this->readAttr("patternTransform"); |
549 | 71 | 71 | this->readAttr("x"); | |
550 | 72 | void SPPattern::build(SPDocument* doc, Inkscape::XML::Node* repr) { | 72 | this->readAttr("y"); |
551 | 73 | SPPaintServer::build(doc, repr); | 73 | this->readAttr("width"); |
552 | 74 | 74 | this->readAttr("height"); | |
553 | 75 | this->readAttr( "patternUnits" ); | 75 | this->readAttr("viewBox"); |
554 | 76 | this->readAttr( "patternContentUnits" ); | 76 | this->readAttr("preserveAspectRatio"); |
555 | 77 | this->readAttr( "patternTransform" ); | 77 | this->readAttr("xlink:href"); |
556 | 78 | this->readAttr( "x" ); | 78 | |
557 | 79 | this->readAttr( "y" ); | 79 | /* Register ourselves */ |
558 | 80 | this->readAttr( "width" ); | 80 | doc->addResource("pattern", this); |
559 | 81 | this->readAttr( "height" ); | 81 | } |
560 | 82 | this->readAttr( "viewBox" ); | 82 | |
561 | 83 | this->readAttr( "preserveAspectRatio" ); | 83 | void SPPattern::release() |
562 | 84 | this->readAttr( "xlink:href" ); | 84 | { |
509 | 85 | |||
510 | 86 | /* Register ourselves */ | ||
511 | 87 | doc->addResource("pattern", this); | ||
512 | 88 | } | ||
513 | 89 | |||
514 | 90 | void SPPattern::release() { | ||
563 | 91 | if (this->document) { | 85 | if (this->document) { |
564 | 92 | // Unregister ourselves | 86 | // Unregister ourselves |
565 | 93 | this->document->removeResource("pattern", this); | 87 | this->document->removeResource("pattern", this); |
566 | 94 | } | 88 | } |
567 | 95 | 89 | ||
568 | 96 | if (this->ref) { | 90 | if (this->ref) { |
570 | 97 | this->modified_connection.disconnect(); | 91 | this->_modified_connection.disconnect(); |
571 | 98 | this->ref->detach(); | 92 | this->ref->detach(); |
572 | 99 | delete this->ref; | 93 | delete this->ref; |
573 | 100 | this->ref = NULL; | 94 | this->ref = NULL; |
574 | @@ -103,113 +97,121 @@ | |||
575 | 103 | SPPaintServer::release(); | 97 | SPPaintServer::release(); |
576 | 104 | } | 98 | } |
577 | 105 | 99 | ||
648 | 106 | void SPPattern::set(unsigned int key, const gchar* value) { | 100 | void SPPattern::set(unsigned int key, const gchar *value) |
649 | 107 | switch (key) { | 101 | { |
650 | 108 | case SP_ATTR_PATTERNUNITS: | 102 | switch (key) { |
651 | 109 | if (value) { | 103 | case SP_ATTR_PATTERNUNITS: |
652 | 110 | if (!strcmp (value, "userSpaceOnUse")) { | 104 | if (value) { |
653 | 111 | this->patternUnits = SP_PATTERN_UNITS_USERSPACEONUSE; | 105 | if (!strcmp(value, "userSpaceOnUse")) { |
654 | 112 | } else { | 106 | this->_pattern_units = UNITS_USERSPACEONUSE; |
655 | 113 | this->patternUnits = SP_PATTERN_UNITS_OBJECTBOUNDINGBOX; | 107 | } |
656 | 114 | } | 108 | else { |
657 | 115 | 109 | this->_pattern_units = UNITS_OBJECTBOUNDINGBOX; | |
658 | 116 | this->patternUnits_set = TRUE; | 110 | } |
659 | 117 | } else { | 111 | |
660 | 118 | this->patternUnits_set = FALSE; | 112 | this->_pattern_units_set = true; |
661 | 119 | } | 113 | } |
662 | 120 | 114 | else { | |
663 | 121 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 115 | this->_pattern_units_set = false; |
664 | 122 | break; | 116 | } |
665 | 123 | 117 | ||
666 | 124 | case SP_ATTR_PATTERNCONTENTUNITS: | 118 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
667 | 125 | if (value) { | 119 | break; |
668 | 126 | if (!strcmp (value, "userSpaceOnUse")) { | 120 | |
669 | 127 | this->patternContentUnits = SP_PATTERN_UNITS_USERSPACEONUSE; | 121 | case SP_ATTR_PATTERNCONTENTUNITS: |
670 | 128 | } else { | 122 | if (value) { |
671 | 129 | this->patternContentUnits = SP_PATTERN_UNITS_OBJECTBOUNDINGBOX; | 123 | if (!strcmp(value, "userSpaceOnUse")) { |
672 | 130 | } | 124 | this->_pattern_content_units = UNITS_USERSPACEONUSE; |
673 | 131 | 125 | } | |
674 | 132 | this->patternContentUnits_set = TRUE; | 126 | else { |
675 | 133 | } else { | 127 | this->_pattern_content_units = UNITS_OBJECTBOUNDINGBOX; |
676 | 134 | this->patternContentUnits_set = FALSE; | 128 | } |
677 | 135 | } | 129 | |
678 | 136 | 130 | this->_pattern_content_units_set = true; | |
679 | 137 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 131 | } |
680 | 138 | break; | 132 | else { |
681 | 139 | 133 | this->_pattern_content_units_set = false; | |
682 | 140 | case SP_ATTR_PATTERNTRANSFORM: { | 134 | } |
683 | 141 | Geom::Affine t; | 135 | |
684 | 142 | 136 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | |
685 | 143 | if (value && sp_svg_transform_read (value, &t)) { | 137 | break; |
686 | 144 | this->patternTransform = t; | 138 | |
687 | 145 | this->patternTransform_set = TRUE; | 139 | case SP_ATTR_PATTERNTRANSFORM: { |
688 | 146 | } else { | 140 | Geom::Affine t; |
689 | 147 | this->patternTransform = Geom::identity(); | 141 | |
690 | 148 | this->patternTransform_set = FALSE; | 142 | if (value && sp_svg_transform_read(value, &t)) { |
691 | 149 | } | 143 | this->_pattern_transform = t; |
692 | 150 | 144 | this->_pattern_transform_set = true; | |
693 | 151 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 145 | } |
694 | 152 | break; | 146 | else { |
695 | 153 | } | 147 | this->_pattern_transform = Geom::identity(); |
696 | 154 | case SP_ATTR_X: | 148 | this->_pattern_transform_set = false; |
697 | 155 | this->x.readOrUnset(value); | 149 | } |
698 | 156 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 150 | |
699 | 157 | break; | 151 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
700 | 158 | 152 | break; | |
701 | 159 | case SP_ATTR_Y: | 153 | } |
702 | 160 | this->y.readOrUnset(value); | 154 | case SP_ATTR_X: |
703 | 161 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 155 | this->_x.readOrUnset(value); |
704 | 162 | break; | 156 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
705 | 163 | 157 | break; | |
706 | 164 | case SP_ATTR_WIDTH: | 158 | |
707 | 165 | this->width.readOrUnset(value); | 159 | case SP_ATTR_Y: |
708 | 166 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 160 | this->_y.readOrUnset(value); |
709 | 167 | break; | 161 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
710 | 168 | 162 | break; | |
711 | 169 | case SP_ATTR_HEIGHT: | 163 | |
712 | 170 | this->height.readOrUnset(value); | 164 | case SP_ATTR_WIDTH: |
713 | 171 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 165 | this->_width.readOrUnset(value); |
714 | 172 | break; | 166 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
715 | 173 | 167 | break; | |
716 | 174 | case SP_ATTR_VIEWBOX: | 168 | |
717 | 175 | set_viewBox( value ); | 169 | case SP_ATTR_HEIGHT: |
718 | 170 | this->_height.readOrUnset(value); | ||
719 | 171 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | ||
720 | 172 | break; | ||
721 | 173 | |||
722 | 174 | case SP_ATTR_VIEWBOX: | ||
723 | 175 | set_viewBox(value); | ||
724 | 176 | this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); | 176 | this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); |
725 | 177 | break; | 177 | break; |
726 | 178 | 178 | ||
727 | 179 | case SP_ATTR_PRESERVEASPECTRATIO: | 179 | case SP_ATTR_PRESERVEASPECTRATIO: |
729 | 180 | set_preserveAspectRatio( value ); | 180 | set_preserveAspectRatio(value); |
730 | 181 | this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); | 181 | this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); |
731 | 182 | break; | 182 | break; |
732 | 183 | 183 | ||
762 | 184 | case SP_ATTR_XLINK_HREF: | 184 | case SP_ATTR_XLINK_HREF: |
763 | 185 | if ( value && this->href && ( strcmp(value, this->href) == 0 ) ) { | 185 | if (value && this->href == value) { |
764 | 186 | /* Href unchanged, do nothing. */ | 186 | /* Href unchanged, do nothing. */ |
765 | 187 | } else { | 187 | } |
766 | 188 | g_free(this->href); | 188 | else { |
767 | 189 | this->href = NULL; | 189 | this->href.clear(); |
768 | 190 | 190 | ||
769 | 191 | if (value) { | 191 | if (value) { |
770 | 192 | // First, set the href field; it's only used in the "unchanged" check above. | 192 | // First, set the href field; it's only used in the "unchanged" check above. |
771 | 193 | this->href = g_strdup(value); | 193 | this->href = value; |
772 | 194 | // Now do the attaching, which emits the changed signal. | 194 | // Now do the attaching, which emits the changed signal. |
773 | 195 | if (value) { | 195 | if (value) { |
774 | 196 | try { | 196 | try { |
775 | 197 | this->ref->attach(Inkscape::URI(value)); | 197 | this->ref->attach(Inkscape::URI(value)); |
776 | 198 | } catch (Inkscape::BadURIException &e) { | 198 | } |
777 | 199 | g_warning("%s", e.what()); | 199 | catch (Inkscape::BadURIException &e) { |
778 | 200 | this->ref->detach(); | 200 | g_warning("%s", e.what()); |
779 | 201 | } | 201 | this->ref->detach(); |
780 | 202 | } else { | 202 | } |
781 | 203 | this->ref->detach(); | 203 | } |
782 | 204 | } | 204 | else { |
783 | 205 | } | 205 | this->ref->detach(); |
784 | 206 | } | 206 | } |
785 | 207 | break; | 207 | } |
786 | 208 | 208 | } | |
787 | 209 | default: | 209 | break; |
788 | 210 | SPPaintServer::set(key, value); | 210 | |
789 | 211 | break; | 211 | default: |
790 | 212 | } | 212 | SPPaintServer::set(key, value); |
791 | 213 | break; | ||
792 | 214 | } | ||
793 | 213 | } | 215 | } |
794 | 214 | 216 | ||
795 | 215 | 217 | ||
796 | @@ -217,104 +219,90 @@ | |||
797 | 217 | 219 | ||
798 | 218 | /* fixme: We need ::order_changed handler too (Lauris) */ | 220 | /* fixme: We need ::order_changed handler too (Lauris) */ |
799 | 219 | 221 | ||
801 | 220 | static GSList *pattern_getchildren(SPPattern *pat) | 222 | void SPPattern::_getChildren(std::list<SPObject *> &l) |
802 | 221 | { | 223 | { |
806 | 222 | GSList *l = NULL; | 224 | for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
804 | 223 | |||
805 | 224 | for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | ||
807 | 225 | if (pat_i->firstChild()) { // find the first one with children | 225 | if (pat_i->firstChild()) { // find the first one with children |
891 | 226 | for (SPObject *child = pat->firstChild() ; child ; child = child->getNext() ) { | 226 | for (SPObject *child = pat_i->firstChild(); child; child = child->getNext()) { |
892 | 227 | l = g_slist_prepend (l, child); | 227 | l.push_back(child); |
893 | 228 | } | 228 | } |
894 | 229 | break; // do not go further up the chain if children are found | 229 | break; // do not go further up the chain if children are found |
895 | 230 | } | 230 | } |
896 | 231 | } | 231 | } |
897 | 232 | 232 | } | |
898 | 233 | return l; | 233 | |
899 | 234 | } | 234 | void SPPattern::update(SPCtx *ctx, unsigned int flags) |
900 | 235 | 235 | { | |
901 | 236 | void SPPattern::update(SPCtx* ctx, unsigned int flags) { | 236 | typedef std::list<SPObject *>::iterator SPObjectIterator; |
902 | 237 | if (flags & SP_OBJECT_MODIFIED_FLAG) { | 237 | |
903 | 238 | flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; | 238 | if (flags & SP_OBJECT_MODIFIED_FLAG) { |
904 | 239 | } | 239 | flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
905 | 240 | 240 | } | |
906 | 241 | flags &= SP_OBJECT_MODIFIED_CASCADE; | 241 | |
907 | 242 | 242 | flags &= SP_OBJECT_MODIFIED_CASCADE; | |
908 | 243 | GSList *l = pattern_getchildren (this); | 243 | |
909 | 244 | l = g_slist_reverse (l); | 244 | std::list<SPObject *> l; |
910 | 245 | 245 | _getChildren(l); | |
911 | 246 | while (l) { | 246 | |
912 | 247 | SPObject *child = SP_OBJECT (l->data); | 247 | for (SPObjectIterator it = l.begin(); it != l.end(); it++) { |
913 | 248 | 248 | SPObject *child = *it; | |
914 | 249 | sp_object_ref (child, NULL); | 249 | |
915 | 250 | l = g_slist_remove (l, child); | 250 | sp_object_ref(child, NULL); |
916 | 251 | 251 | ||
917 | 252 | if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { | 252 | if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
918 | 253 | child->updateDisplay(ctx, flags); | 253 | child->updateDisplay(ctx, flags); |
919 | 254 | } | 254 | } |
920 | 255 | 255 | ||
921 | 256 | sp_object_unref (child, NULL); | 256 | sp_object_unref(child, NULL); |
922 | 257 | } | 257 | } |
923 | 258 | } | 258 | } |
924 | 259 | 259 | ||
925 | 260 | void SPPattern::modified(unsigned int flags) { | 260 | void SPPattern::modified(unsigned int flags) |
926 | 261 | if (flags & SP_OBJECT_MODIFIED_FLAG) { | 261 | { |
927 | 262 | flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; | 262 | typedef std::list<SPObject *>::iterator SPObjectIterator; |
928 | 263 | } | 263 | |
929 | 264 | 264 | if (flags & SP_OBJECT_MODIFIED_FLAG) { | |
930 | 265 | flags &= SP_OBJECT_MODIFIED_CASCADE; | 265 | flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
931 | 266 | 266 | } | |
932 | 267 | GSList *l = pattern_getchildren (this); | 267 | |
933 | 268 | l = g_slist_reverse (l); | 268 | flags &= SP_OBJECT_MODIFIED_CASCADE; |
934 | 269 | 269 | ||
935 | 270 | while (l) { | 270 | std::list<SPObject *> l; |
936 | 271 | SPObject *child = SP_OBJECT (l->data); | 271 | _getChildren(l); |
937 | 272 | 272 | ||
938 | 273 | sp_object_ref (child, NULL); | 273 | for (SPObjectIterator it = l.begin(); it != l.end(); it++) { |
939 | 274 | l = g_slist_remove (l, child); | 274 | SPObject *child = *it; |
940 | 275 | 275 | ||
941 | 276 | if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { | 276 | sp_object_ref(child, NULL); |
942 | 277 | child->emitModified(flags); | 277 | |
943 | 278 | } | 278 | if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
944 | 279 | 279 | child->emitModified(flags); | |
945 | 280 | sp_object_unref (child, NULL); | 280 | } |
946 | 281 | } | 281 | |
947 | 282 | } | 282 | sp_object_unref(child, NULL); |
948 | 283 | 283 | } | |
949 | 284 | /** | 284 | } |
950 | 285 | Gets called when the pattern is reattached to another <pattern> | 285 | |
951 | 286 | */ | 286 | void SPPattern::_onRefChanged(SPObject *old_ref, SPObject *ref) |
952 | 287 | static void | 287 | { |
953 | 288 | pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat) | 288 | if (old_ref) { |
954 | 289 | { | 289 | _modified_connection.disconnect(); |
955 | 290 | if (old_ref) { | 290 | } |
956 | 291 | pat->modified_connection.disconnect(); | 291 | |
957 | 292 | } | 292 | if (SP_IS_PATTERN(ref)) { |
958 | 293 | 293 | _modified_connection = ref->connectModified(sigc::mem_fun(this, &SPPattern::_onRefModified)); | |
959 | 294 | if (SP_IS_PATTERN (ref)) { | 294 | } |
960 | 295 | pat->modified_connection = ref->connectModified(sigc::bind<2>(sigc::ptr_fun(&pattern_ref_modified), pat)); | 295 | |
961 | 296 | } | 296 | _onRefModified(ref, 0); |
962 | 297 | 297 | } | |
963 | 298 | pattern_ref_modified (ref, 0, pat); | 298 | |
964 | 299 | } | 299 | void SPPattern::_onRefModified(SPObject * /*ref*/, guint /*flags*/) |
965 | 300 | 300 | { | |
966 | 301 | /** | 301 | requestModified(SP_OBJECT_MODIFIED_FLAG); |
884 | 302 | Gets called when the referenced <pattern> is changed | ||
885 | 303 | */ | ||
886 | 304 | static void pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern *pattern) | ||
887 | 305 | { | ||
888 | 306 | if ( SP_IS_OBJECT(pattern) ) { | ||
889 | 307 | pattern->requestModified(SP_OBJECT_MODIFIED_FLAG); | ||
890 | 308 | } | ||
967 | 309 | // Conditional to avoid causing infinite loop if there's a cycle in the href chain. | 302 | // Conditional to avoid causing infinite loop if there's a cycle in the href chain. |
968 | 310 | } | 303 | } |
969 | 311 | 304 | ||
976 | 312 | 305 | guint SPPattern::_countHrefs(SPObject *o) const | |
971 | 313 | /** | ||
972 | 314 | Count how many times pat is used by the styles of o and its descendants | ||
973 | 315 | */ | ||
974 | 316 | static guint | ||
975 | 317 | count_pattern_hrefs(SPObject *o, SPPattern *pat) | ||
977 | 318 | { | 306 | { |
978 | 319 | if (!o) | 307 | if (!o) |
979 | 320 | return 1; | 308 | return 1; |
980 | @@ -322,84 +310,79 @@ | |||
981 | 322 | guint i = 0; | 310 | guint i = 0; |
982 | 323 | 311 | ||
983 | 324 | SPStyle *style = o->style; | 312 | SPStyle *style = o->style; |
990 | 325 | if (style | 313 | if (style && style->fill.isPaintserver() && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) && |
991 | 326 | && style->fill.isPaintserver() | 314 | SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == this) { |
992 | 327 | && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) | 315 | i++; |
987 | 328 | && SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == pat) | ||
988 | 329 | { | ||
989 | 330 | i ++; | ||
993 | 331 | } | 316 | } |
1000 | 332 | if (style | 317 | if (style && style->stroke.isPaintserver() && SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) && |
1001 | 333 | && style->stroke.isPaintserver() | 318 | SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == this) { |
1002 | 334 | && SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) | 319 | i++; |
997 | 335 | && SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == pat) | ||
998 | 336 | { | ||
999 | 337 | i ++; | ||
1003 | 338 | } | 320 | } |
1004 | 339 | 321 | ||
1007 | 340 | for ( SPObject *child = o->firstChild(); child != NULL; child = child->next ) { | 322 | for (SPObject *child = o->firstChild(); child != NULL; child = child->next) { |
1008 | 341 | i += count_pattern_hrefs(child, pat); | 323 | i += _countHrefs(child); |
1009 | 342 | } | 324 | } |
1010 | 343 | 325 | ||
1011 | 344 | return i; | 326 | return i; |
1012 | 345 | } | 327 | } |
1013 | 346 | 328 | ||
1015 | 347 | SPPattern *pattern_chain(SPPattern *pattern) | 329 | SPPattern *SPPattern::_chain() const |
1016 | 348 | { | 330 | { |
1019 | 349 | SPDocument *document = pattern->document; | 331 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); |
1018 | 350 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); | ||
1020 | 351 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); | 332 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); |
1021 | 352 | 333 | ||
1022 | 353 | Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); | 334 | Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); |
1023 | 354 | repr->setAttribute("inkscape:collect", "always"); | 335 | repr->setAttribute("inkscape:collect", "always"); |
1027 | 355 | gchar *parent_ref = g_strconcat("#", pattern->getRepr()->attribute("id"), NULL); | 336 | Glib::ustring parent_ref = Glib::ustring::compose("#%1", getRepr()->attribute("id")); |
1028 | 356 | repr->setAttribute("xlink:href", parent_ref); | 337 | repr->setAttribute("xlink:href", parent_ref); |
1026 | 357 | g_free (parent_ref); | ||
1029 | 358 | 338 | ||
1030 | 359 | defsrepr->addChild(repr, NULL); | 339 | defsrepr->addChild(repr, NULL); |
1031 | 360 | const gchar *child_id = repr->attribute("id"); | 340 | const gchar *child_id = repr->attribute("id"); |
1032 | 361 | SPObject *child = document->getObjectById(child_id); | 341 | SPObject *child = document->getObjectById(child_id); |
1034 | 362 | g_assert (SP_IS_PATTERN (child)); | 342 | g_assert(SP_IS_PATTERN(child)); |
1035 | 363 | 343 | ||
1037 | 364 | return SP_PATTERN (child); | 344 | return SP_PATTERN(child); |
1038 | 365 | } | 345 | } |
1039 | 366 | 346 | ||
1042 | 367 | SPPattern * | 347 | SPPattern *SPPattern::clone_if_necessary(SPItem *item, const gchar *property) |
1041 | 368 | sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property) | ||
1043 | 369 | { | 348 | { |
1047 | 370 | if (!pattern->href || pattern->hrefcount > count_pattern_hrefs(item, pattern)) { | 349 | SPPattern *pattern = this; |
1048 | 371 | pattern = pattern_chain (pattern); | 350 | if (pattern->href.empty() || pattern->hrefcount > _countHrefs(item)) { |
1049 | 372 | gchar *href = g_strconcat("url(#", pattern->getRepr()->attribute("id"), ")", NULL); | 351 | pattern = _chain(); |
1050 | 352 | Glib::ustring href = Glib::ustring::compose("url(#%1)", pattern->getRepr()->attribute("id")); | ||
1051 | 373 | 353 | ||
1054 | 374 | SPCSSAttr *css = sp_repr_css_attr_new (); | 354 | SPCSSAttr *css = sp_repr_css_attr_new(); |
1055 | 375 | sp_repr_css_set_property (css, property, href); | 355 | sp_repr_css_set_property(css, property, href.c_str()); |
1056 | 376 | sp_repr_css_change_recursive(item->getRepr(), css, "style"); | 356 | sp_repr_css_change_recursive(item->getRepr(), css, "style"); |
1057 | 377 | } | 357 | } |
1058 | 378 | return pattern; | 358 | return pattern; |
1059 | 379 | } | 359 | } |
1060 | 380 | 360 | ||
1063 | 381 | void | 361 | void SPPattern::transform_multiply(Geom::Affine postmul, bool set) |
1062 | 382 | sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set) | ||
1064 | 383 | { | 362 | { |
1065 | 384 | // this formula is for a different interpretation of pattern transforms as described in (*) in sp-pattern.cpp | 363 | // this formula is for a different interpretation of pattern transforms as described in (*) in sp-pattern.cpp |
1066 | 385 | // for it to work, we also need sp_object_read_attr( item, "transform"); | 364 | // for it to work, we also need sp_object_read_attr( item, "transform"); |
1068 | 386 | //pattern->patternTransform = premul * item->transform * pattern->patternTransform * item->transform.inverse() * postmul; | 365 | // pattern->patternTransform = premul * item->transform * pattern->patternTransform * item->transform.inverse() * |
1069 | 366 | // postmul; | ||
1070 | 387 | 367 | ||
1071 | 388 | // otherwise the formula is much simpler | 368 | // otherwise the formula is much simpler |
1072 | 389 | if (set) { | 369 | if (set) { |
1078 | 390 | pattern->patternTransform = postmul; | 370 | _pattern_transform = postmul; |
1079 | 391 | } else { | 371 | } |
1080 | 392 | pattern->patternTransform = pattern_patternTransform(pattern) * postmul; | 372 | else { |
1081 | 393 | } | 373 | _pattern_transform = getTransform() * postmul; |
1082 | 394 | pattern->patternTransform_set = TRUE; | 374 | } |
1083 | 375 | _pattern_transform_set = true; | ||
1084 | 395 | 376 | ||
1088 | 396 | gchar *c=sp_svg_transform_write(pattern->patternTransform); | 377 | Glib::ustring c = sp_svg_transform_write(_pattern_transform); |
1089 | 397 | pattern->getRepr()->setAttribute("patternTransform", c); | 378 | getRepr()->setAttribute("patternTransform", c); |
1087 | 398 | g_free(c); | ||
1090 | 399 | } | 379 | } |
1091 | 400 | 380 | ||
1093 | 401 | const gchar *pattern_tile(const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) | 381 | const gchar *SPPattern::produce(const std::vector<Inkscape::XML::Node *> &reprs, Geom::Rect bounds, |
1094 | 382 | SPDocument *document, Geom::Affine transform, Geom::Affine move) | ||
1095 | 402 | { | 383 | { |
1096 | 384 | typedef std::vector<Inkscape::XML::Node *>::const_iterator NodePtrIterator; | ||
1097 | 385 | |||
1098 | 403 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); | 386 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); |
1099 | 404 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); | 387 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); |
1100 | 405 | 388 | ||
1101 | @@ -408,20 +391,19 @@ | |||
1102 | 408 | sp_repr_set_svg_double(repr, "width", bounds.dimensions()[Geom::X]); | 391 | sp_repr_set_svg_double(repr, "width", bounds.dimensions()[Geom::X]); |
1103 | 409 | sp_repr_set_svg_double(repr, "height", bounds.dimensions()[Geom::Y]); | 392 | sp_repr_set_svg_double(repr, "height", bounds.dimensions()[Geom::Y]); |
1104 | 410 | 393 | ||
1106 | 411 | gchar *t=sp_svg_transform_write(transform); | 394 | Glib::ustring t = sp_svg_transform_write(transform); |
1107 | 412 | repr->setAttribute("patternTransform", t); | 395 | repr->setAttribute("patternTransform", t); |
1108 | 413 | g_free(t); | ||
1109 | 414 | 396 | ||
1110 | 415 | defsrepr->appendChild(repr); | 397 | defsrepr->appendChild(repr); |
1111 | 416 | const gchar *pat_id = repr->attribute("id"); | 398 | const gchar *pat_id = repr->attribute("id"); |
1112 | 417 | SPObject *pat_object = document->getObjectById(pat_id); | 399 | SPObject *pat_object = document->getObjectById(pat_id); |
1113 | 418 | 400 | ||
1115 | 419 | for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ | 401 | for (NodePtrIterator i = reprs.begin(); i != reprs.end(); i++) { |
1116 | 420 | Inkscape::XML::Node *node = *i; | 402 | Inkscape::XML::Node *node = *i; |
1117 | 421 | SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); | 403 | SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); |
1118 | 422 | 404 | ||
1119 | 423 | Geom::Affine dup_transform; | 405 | Geom::Affine dup_transform; |
1121 | 424 | if (!sp_svg_transform_read (node->attribute("transform"), &dup_transform)) | 406 | if (!sp_svg_transform_read(node->attribute("transform"), &dup_transform)) |
1122 | 425 | dup_transform = Geom::identity(); | 407 | dup_transform = Geom::identity(); |
1123 | 426 | dup_transform *= move; | 408 | dup_transform *= move; |
1124 | 427 | 409 | ||
1125 | @@ -432,14 +414,15 @@ | |||
1126 | 432 | return pat_id; | 414 | return pat_id; |
1127 | 433 | } | 415 | } |
1128 | 434 | 416 | ||
1130 | 435 | SPPattern *pattern_getroot(SPPattern *pat) | 417 | SPPattern *SPPattern::rootPattern() |
1131 | 436 | { | 418 | { |
1134 | 437 | for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 419 | for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1135 | 438 | if ( pat_i->firstChild() ) { // find the first one with children | 420 | if (pat_i->firstChild()) { // find the first one with children |
1136 | 439 | return pat_i; | 421 | return pat_i; |
1137 | 440 | } | 422 | } |
1138 | 441 | } | 423 | } |
1140 | 442 | return pat; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid pattern | 424 | return this; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid |
1141 | 425 | // pattern | ||
1142 | 443 | } | 426 | } |
1143 | 444 | 427 | ||
1144 | 445 | 428 | ||
1145 | @@ -447,73 +430,73 @@ | |||
1146 | 447 | // Access functions that look up fields up the chain of referenced patterns and return the first one which is set | 430 | // Access functions that look up fields up the chain of referenced patterns and return the first one which is set |
1147 | 448 | // FIXME: all of them must use chase_hrefs the same as in SPGradient, to avoid lockup on circular refs | 431 | // FIXME: all of them must use chase_hrefs the same as in SPGradient, to avoid lockup on circular refs |
1148 | 449 | 432 | ||
1213 | 450 | guint pattern_patternUnits (SPPattern const *pat) | 433 | SPPattern::PatternUnits SPPattern::patternUnits() const |
1214 | 451 | { | 434 | { |
1215 | 452 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 435 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1216 | 453 | if (pat_i->patternUnits_set) | 436 | if (pat_i->_pattern_units_set) |
1217 | 454 | return pat_i->patternUnits; | 437 | return pat_i->_pattern_units; |
1218 | 455 | } | 438 | } |
1219 | 456 | return pat->patternUnits; | 439 | return _pattern_units; |
1220 | 457 | } | 440 | } |
1221 | 458 | 441 | ||
1222 | 459 | guint pattern_patternContentUnits (SPPattern const *pat) | 442 | SPPattern::PatternUnits SPPattern::patternContentUnits() const |
1223 | 460 | { | 443 | { |
1224 | 461 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 444 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1225 | 462 | if (pat_i->patternContentUnits_set) | 445 | if (pat_i->_pattern_content_units_set) |
1226 | 463 | return pat_i->patternContentUnits; | 446 | return pat_i->_pattern_content_units; |
1227 | 464 | } | 447 | } |
1228 | 465 | return pat->patternContentUnits; | 448 | return _pattern_content_units; |
1229 | 466 | } | 449 | } |
1230 | 467 | 450 | ||
1231 | 468 | Geom::Affine const &pattern_patternTransform(SPPattern const *pat) | 451 | Geom::Affine const &SPPattern::getTransform() const |
1232 | 469 | { | 452 | { |
1233 | 470 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 453 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1234 | 471 | if (pat_i->patternTransform_set) | 454 | if (pat_i->_pattern_transform_set) |
1235 | 472 | return pat_i->patternTransform; | 455 | return pat_i->_pattern_transform; |
1236 | 473 | } | 456 | } |
1237 | 474 | return pat->patternTransform; | 457 | return _pattern_transform; |
1238 | 475 | } | 458 | } |
1239 | 476 | 459 | ||
1240 | 477 | gdouble pattern_x (SPPattern const *pat) | 460 | gdouble SPPattern::x() const |
1241 | 478 | { | 461 | { |
1242 | 479 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 462 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1243 | 480 | if (pat_i->x._set) | 463 | if (pat_i->_x._set) |
1244 | 481 | return pat_i->x.computed; | 464 | return pat_i->_x.computed; |
1245 | 482 | } | 465 | } |
1246 | 483 | return 0; | 466 | return 0; |
1247 | 484 | } | 467 | } |
1248 | 485 | 468 | ||
1249 | 486 | gdouble pattern_y (SPPattern const *pat) | 469 | gdouble SPPattern::y() const |
1250 | 487 | { | 470 | { |
1251 | 488 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 471 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1252 | 489 | if (pat_i->y._set) | 472 | if (pat_i->_y._set) |
1253 | 490 | return pat_i->y.computed; | 473 | return pat_i->_y.computed; |
1254 | 491 | } | 474 | } |
1255 | 492 | return 0; | 475 | return 0; |
1256 | 493 | } | 476 | } |
1257 | 494 | 477 | ||
1258 | 495 | gdouble pattern_width (SPPattern const* pat) | 478 | gdouble SPPattern::width() const |
1259 | 496 | { | 479 | { |
1260 | 497 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 480 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1261 | 498 | if (pat_i->width._set) | 481 | if (pat_i->_width._set) |
1262 | 499 | return pat_i->width.computed; | 482 | return pat_i->_width.computed; |
1263 | 500 | } | 483 | } |
1264 | 501 | return 0; | 484 | return 0; |
1265 | 502 | } | 485 | } |
1266 | 503 | 486 | ||
1267 | 504 | gdouble pattern_height (SPPattern const *pat) | 487 | gdouble SPPattern::height() const |
1268 | 505 | { | 488 | { |
1269 | 506 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 489 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1270 | 507 | if (pat_i->height._set) | 490 | if (pat_i->_height._set) |
1271 | 508 | return pat_i->height.computed; | 491 | return pat_i->_height.computed; |
1272 | 509 | } | 492 | } |
1273 | 510 | return 0; | 493 | return 0; |
1274 | 511 | } | 494 | } |
1275 | 512 | 495 | ||
1276 | 513 | Geom::OptRect pattern_viewBox (SPPattern const *pat) | 496 | Geom::OptRect SPPattern::viewbox() const |
1277 | 514 | { | 497 | { |
1278 | 515 | Geom::OptRect viewbox; | 498 | Geom::OptRect viewbox; |
1280 | 516 | for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 499 | for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1281 | 517 | if (pat_i->viewBox_set) { | 500 | if (pat_i->viewBox_set) { |
1282 | 518 | viewbox = pat_i->viewBox; | 501 | viewbox = pat_i->viewBox; |
1283 | 519 | break; | 502 | break; |
1284 | @@ -522,10 +505,10 @@ | |||
1285 | 522 | return viewbox; | 505 | return viewbox; |
1286 | 523 | } | 506 | } |
1287 | 524 | 507 | ||
1289 | 525 | static bool pattern_hasItemChildren (SPPattern const *pat) | 508 | bool SPPattern::_hasItemChildren() const |
1290 | 526 | { | 509 | { |
1291 | 527 | bool hasChildren = false; | 510 | bool hasChildren = false; |
1293 | 528 | for (SPObject const *child = pat->firstChild() ; child && !hasChildren ; child = child->getNext() ) { | 511 | for (SPObject const *child = firstChild(); child && !hasChildren; child = child->getNext()) { |
1294 | 529 | if (SP_IS_ITEM(child)) { | 512 | if (SP_IS_ITEM(child)) { |
1295 | 530 | hasChildren = true; | 513 | hasChildren = true; |
1296 | 531 | } | 514 | } |
1297 | @@ -535,15 +518,16 @@ | |||
1298 | 535 | 518 | ||
1299 | 536 | bool SPPattern::isValid() const | 519 | bool SPPattern::isValid() const |
1300 | 537 | { | 520 | { |
1303 | 538 | double tile_width = pattern_width(this); | 521 | double tile_width = width(); |
1304 | 539 | double tile_height = pattern_height(this); | 522 | double tile_height = height(); |
1305 | 540 | 523 | ||
1309 | 541 | if (tile_width <= 0 || tile_height <= 0) | 524 | if (tile_width <= 0 || tile_height <= 0) |
1310 | 542 | return false; | 525 | return false; |
1311 | 543 | return true; | 526 | return true; |
1312 | 544 | } | 527 | } |
1313 | 545 | 528 | ||
1315 | 546 | cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &bbox, double opacity) { | 529 | cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &bbox, double opacity) |
1316 | 530 | { | ||
1317 | 547 | 531 | ||
1318 | 548 | bool needs_opacity = (1.0 - opacity) >= 1e-3; | 532 | bool needs_opacity = (1.0 - opacity) >= 1e-3; |
1319 | 549 | bool visible = opacity >= 1e-3; | 533 | bool visible = opacity >= 1e-3; |
1320 | @@ -557,28 +541,28 @@ | |||
1321 | 557 | 541 | ||
1322 | 558 | for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { | 542 | for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { |
1323 | 559 | // find the first one with item children | 543 | // find the first one with item children |
1325 | 560 | if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { | 544 | if (pat_i && SP_IS_OBJECT(pat_i) && pat_i->_hasItemChildren()) { |
1326 | 561 | shown = pat_i; | 545 | shown = pat_i; |
1327 | 562 | break; // do not go further up the chain if children are found | 546 | break; // do not go further up the chain if children are found |
1328 | 563 | } | 547 | } |
1329 | 564 | } | 548 | } |
1330 | 565 | 549 | ||
1331 | 566 | if (!shown) { | 550 | if (!shown) { |
1333 | 567 | return cairo_pattern_create_rgba(0,0,0,0); | 551 | return cairo_pattern_create_rgba(0, 0, 0, 0); |
1334 | 568 | } | 552 | } |
1335 | 569 | 553 | ||
1336 | 570 | /* Create drawing for rendering */ | 554 | /* Create drawing for rendering */ |
1337 | 571 | Inkscape::Drawing drawing; | 555 | Inkscape::Drawing drawing; |
1339 | 572 | unsigned int dkey = SPItem::display_key_new (1); | 556 | unsigned int dkey = SPItem::display_key_new(1); |
1340 | 573 | Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); | 557 | Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); |
1341 | 574 | drawing.setRoot(root); | 558 | drawing.setRoot(root); |
1342 | 575 | 559 | ||
1345 | 576 | for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext() ) { | 560 | for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { |
1346 | 577 | if (SP_IS_ITEM (child)) { | 561 | if (SP_IS_ITEM(child)) { |
1347 | 578 | // for each item in pattern, show it on our drawing, add to the group, | 562 | // for each item in pattern, show it on our drawing, add to the group, |
1348 | 579 | // and connect to the release signal in case the item gets deleted | 563 | // and connect to the release signal in case the item gets deleted |
1349 | 580 | Inkscape::DrawingItem *cai; | 564 | Inkscape::DrawingItem *cai; |
1351 | 581 | cai = SP_ITEM(child)->invoke_show (drawing, dkey, SP_ITEM_SHOW_DISPLAY); | 565 | cai = SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); |
1352 | 582 | root->appendChild(cai); | 566 | root->appendChild(cai); |
1353 | 583 | } | 567 | } |
1354 | 584 | } | 568 | } |
1355 | @@ -591,40 +575,41 @@ | |||
1356 | 591 | // * "x", "y", and "patternTransform" transform tile to user space after tile is generated. | 575 | // * "x", "y", and "patternTransform" transform tile to user space after tile is generated. |
1357 | 592 | 576 | ||
1358 | 593 | // These functions recursively search up the tree to find the values. | 577 | // These functions recursively search up the tree to find the values. |
1367 | 594 | double tile_x = pattern_x(this); | 578 | double tile_x = x(); |
1368 | 595 | double tile_y = pattern_y(this); | 579 | double tile_y = y(); |
1369 | 596 | double tile_width = pattern_width(this); | 580 | double tile_width = width(); |
1370 | 597 | double tile_height = pattern_height(this); | 581 | double tile_height = height(); |
1371 | 598 | if ( bbox && (pattern_patternUnits(this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) ) { | 582 | if (bbox && (patternUnits() == UNITS_OBJECTBOUNDINGBOX)) { |
1372 | 599 | tile_x *= bbox->width(); | 583 | tile_x *= bbox->width(); |
1373 | 600 | tile_y *= bbox->height(); | 584 | tile_y *= bbox->height(); |
1374 | 601 | tile_width *= bbox->width(); | 585 | tile_width *= bbox->width(); |
1375 | 602 | tile_height *= bbox->height(); | 586 | tile_height *= bbox->height(); |
1376 | 603 | } | 587 | } |
1377 | 604 | 588 | ||
1378 | 605 | // Pattern size in pattern space | 589 | // Pattern size in pattern space |
1379 | 606 | Geom::Rect pattern_tile = Geom::Rect::from_xywh(0, 0, tile_width, tile_height); | 590 | Geom::Rect pattern_tile = Geom::Rect::from_xywh(0, 0, tile_width, tile_height); |
1381 | 607 | 591 | ||
1382 | 608 | // Content to tile (pattern space) | 592 | // Content to tile (pattern space) |
1383 | 609 | Geom::Affine content2ps; | 593 | Geom::Affine content2ps; |
1385 | 610 | Geom::OptRect effective_view_box = pattern_viewBox(this); | 594 | Geom::OptRect effective_view_box = viewbox(); |
1386 | 611 | if (effective_view_box) { | 595 | if (effective_view_box) { |
1388 | 612 | // viewBox to pattern server (using SPViewBox) | 596 | // viewBox to pattern server (using SPViewBox) |
1389 | 613 | viewBox = *effective_view_box; | 597 | viewBox = *effective_view_box; |
1390 | 614 | c2p.setIdentity(); | 598 | c2p.setIdentity(); |
1392 | 615 | apply_viewbox( pattern_tile ); | 599 | apply_viewbox(pattern_tile); |
1393 | 616 | content2ps = c2p; | 600 | content2ps = c2p; |
1395 | 617 | } else { | 601 | } |
1396 | 602 | else { | ||
1397 | 618 | 603 | ||
1398 | 619 | // Content to bbox | 604 | // Content to bbox |
1401 | 620 | if (bbox && (pattern_patternContentUnits(this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) ) { | 605 | if (bbox && (patternContentUnits() == UNITS_OBJECTBOUNDINGBOX)) { |
1402 | 621 | content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0,0); | 606 | content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0, 0); |
1403 | 622 | } | 607 | } |
1404 | 623 | } | 608 | } |
1405 | 624 | 609 | ||
1406 | 625 | 610 | ||
1407 | 626 | // Tile (pattern space) to user. | 611 | // Tile (pattern space) to user. |
1409 | 627 | Geom::Affine ps2user = Geom::Translate(tile_x,tile_y) * pattern_patternTransform(this); | 612 | Geom::Affine ps2user = Geom::Translate(tile_x, tile_y) * getTransform(); |
1410 | 628 | 613 | ||
1411 | 629 | 614 | ||
1412 | 630 | // Transform of object with pattern (includes screen scaling) | 615 | // Transform of object with pattern (includes screen scaling) |
1413 | @@ -644,7 +629,7 @@ | |||
1414 | 644 | // to find the optimum tile size for rendering | 629 | // to find the optimum tile size for rendering |
1415 | 645 | // c is number of pixels in buffer x and y. | 630 | // c is number of pixels in buffer x and y. |
1416 | 646 | // Scale factor of 1.1 is too small... see bug #1251039 | 631 | // Scale factor of 1.1 is too small... see bug #1251039 |
1418 | 647 | Geom::Point c(pattern_tile.dimensions()*ps2user.descrim()*full.descrim()*2.0); | 632 | Geom::Point c(pattern_tile.dimensions() * ps2user.descrim() * full.descrim() * 2.0); |
1419 | 648 | 633 | ||
1420 | 649 | // Create drawing surface with size of pattern tile (in pattern space) but with number of pixels | 634 | // Create drawing surface with size of pattern tile (in pattern space) but with number of pixels |
1421 | 650 | // based on required resolution (c). | 635 | // based on required resolution (c). |
1422 | @@ -660,16 +645,16 @@ | |||
1423 | 660 | } | 645 | } |
1424 | 661 | 646 | ||
1425 | 662 | // TODO: make sure there are no leaks. | 647 | // TODO: make sure there are no leaks. |
1427 | 663 | Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm! | 648 | Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm! |
1428 | 664 | ctx.ctm = content2ps * pattern_surface.drawingTransform(); | 649 | ctx.ctm = content2ps * pattern_surface.drawingTransform(); |
1430 | 665 | dc.transform( pattern_surface.drawingTransform().inverse() ); | 650 | dc.transform(pattern_surface.drawingTransform().inverse()); |
1431 | 666 | drawing.update(Geom::IntRect::infinite(), ctx); | 651 | drawing.update(Geom::IntRect::infinite(), ctx); |
1432 | 667 | 652 | ||
1433 | 668 | // Render drawing to pattern_surface via drawing context, this calls root->render | 653 | // Render drawing to pattern_surface via drawing context, this calls root->render |
1434 | 669 | // which is really DrawingItem->render(). | 654 | // which is really DrawingItem->render(). |
1435 | 670 | drawing.render(dc, one_tile); | 655 | drawing.render(dc, one_tile); |
1438 | 671 | for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) { | 656 | for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { |
1439 | 672 | if (SP_IS_ITEM (child)) { | 657 | if (SP_IS_ITEM(child)) { |
1440 | 673 | SP_ITEM(child)->invoke_hide(dkey); | 658 | SP_ITEM(child)->invoke_hide(dkey); |
1441 | 674 | } | 659 | } |
1442 | 675 | } | 660 | } |
1443 | @@ -685,12 +670,12 @@ | |||
1444 | 685 | 670 | ||
1445 | 686 | if (needs_opacity) { | 671 | if (needs_opacity) { |
1446 | 687 | dc.popGroupToSource(); // pop raw pattern | 672 | dc.popGroupToSource(); // pop raw pattern |
1448 | 688 | dc.paint(opacity); // apply opacity | 673 | dc.paint(opacity); // apply opacity |
1449 | 689 | } | 674 | } |
1450 | 690 | 675 | ||
1451 | 691 | cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); | 676 | cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); |
1452 | 692 | // Apply transformation to user space. Also compensate for oversampling. | 677 | // Apply transformation to user space. Also compensate for oversampling. |
1454 | 693 | ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * pattern_surface.drawingTransform() ); | 678 | ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * pattern_surface.drawingTransform()); |
1455 | 694 | 679 | ||
1456 | 695 | cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); | 680 | cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); |
1457 | 696 | 681 | ||
1458 | 697 | 682 | ||
1459 | === modified file 'src/sp-pattern.h' | |||
1460 | --- src/sp-pattern.h 2015-02-19 03:25:21 +0000 | |||
1461 | +++ src/sp-pattern.h 2015-05-17 11:43:43 +0000 | |||
1462 | @@ -1,9 +1,6 @@ | |||
1467 | 1 | #ifndef SEEN_SP_PATTERN_H | 1 | /** @file |
1464 | 2 | #define SEEN_SP_PATTERN_H | ||
1465 | 3 | |||
1466 | 4 | /* | ||
1468 | 5 | * SVG <pattern> implementation | 2 | * SVG <pattern> implementation |
1470 | 6 | * | 3 | *//* |
1471 | 7 | * Author: | 4 | * Author: |
1472 | 8 | * Lauris Kaplinski <lauris@kaplinski.com> | 5 | * Lauris Kaplinski <lauris@kaplinski.com> |
1473 | 9 | * Abhishek Sharma | 6 | * Abhishek Sharma |
1474 | @@ -13,95 +10,131 @@ | |||
1475 | 13 | * Released under GNU GPL, read the file 'COPYING' for more information | 10 | * Released under GNU GPL, read the file 'COPYING' for more information |
1476 | 14 | */ | 11 | */ |
1477 | 15 | 12 | ||
1480 | 16 | #define SP_PATTERN(obj) (dynamic_cast<SPPattern*>((SPObject*)obj)) | 13 | #ifndef SEEN_SP_PATTERN_H |
1481 | 17 | #define SP_IS_PATTERN(obj) (dynamic_cast<const SPPattern*>((SPObject*)obj) != NULL) | 14 | #define SEEN_SP_PATTERN_H |
1482 | 18 | 15 | ||
1486 | 19 | class SPPatternReference; | 16 | #include <list> |
1487 | 20 | class SPItem; | 17 | #include <stddef.h> |
1488 | 21 | typedef struct _GSList GSList; | 18 | #include <glibmm/ustring.h> |
1489 | 19 | #include <sigc++/connection.h> | ||
1490 | 22 | 20 | ||
1491 | 23 | #include "svg/svg-length.h" | 21 | #include "svg/svg-length.h" |
1492 | 24 | #include "sp-paint-server.h" | 22 | #include "sp-paint-server.h" |
1493 | 25 | #include "uri-references.h" | 23 | #include "uri-references.h" |
1494 | 26 | #include "viewbox.h" | 24 | #include "viewbox.h" |
1495 | 27 | 25 | ||
1498 | 28 | #include <sigc++/connection.h> | 26 | class SPPatternReference; |
1499 | 29 | 27 | class SPItem; | |
1500 | 28 | |||
1501 | 29 | namespace Inkscape { | ||
1502 | 30 | namespace XML { | ||
1503 | 31 | |||
1504 | 32 | class Node; | ||
1505 | 33 | } | ||
1506 | 34 | } | ||
1507 | 35 | |||
1508 | 36 | #define SP_PATTERN(obj) (dynamic_cast<SPPattern *>((SPObject *)obj)) | ||
1509 | 37 | #define SP_IS_PATTERN(obj) (dynamic_cast<const SPPattern *>((SPObject *)obj) != NULL) | ||
1510 | 30 | 38 | ||
1511 | 31 | class SPPattern : public SPPaintServer, public SPViewBox { | 39 | class SPPattern : public SPPaintServer, public SPViewBox { |
1512 | 32 | public: | 40 | public: |
1515 | 33 | SPPattern(); | 41 | enum PatternUnits { UNITS_USERSPACEONUSE, UNITS_OBJECTBOUNDINGBOX }; |
1516 | 34 | virtual ~SPPattern(); | 42 | |
1517 | 43 | SPPattern(); | ||
1518 | 44 | virtual ~SPPattern(); | ||
1519 | 35 | 45 | ||
1520 | 36 | /* Reference (href) */ | 46 | /* Reference (href) */ |
1522 | 37 | char *href; | 47 | Glib::ustring href; |
1523 | 38 | SPPatternReference *ref; | 48 | SPPatternReference *ref; |
1524 | 39 | 49 | ||
1525 | 50 | gdouble x() const; | ||
1526 | 51 | gdouble y() const; | ||
1527 | 52 | gdouble width() const; | ||
1528 | 53 | gdouble height() const; | ||
1529 | 54 | Geom::OptRect viewbox() const; | ||
1530 | 55 | SPPattern::PatternUnits patternUnits() const; | ||
1531 | 56 | SPPattern::PatternUnits patternContentUnits() const; | ||
1532 | 57 | Geom::Affine const &getTransform() const; | ||
1533 | 58 | SPPattern *rootPattern(); // TODO: const | ||
1534 | 59 | |||
1535 | 60 | SPPattern *clone_if_necessary(SPItem *item, const gchar *property); | ||
1536 | 61 | void transform_multiply(Geom::Affine postmul, bool set); | ||
1537 | 62 | |||
1538 | 63 | /** | ||
1539 | 64 | * @brief create a new pattern in XML tree | ||
1540 | 65 | * @return created pattern id | ||
1541 | 66 | */ | ||
1542 | 67 | static const gchar *produce(const std::vector<Inkscape::XML::Node *> &reprs, Geom::Rect bounds, | ||
1543 | 68 | SPDocument *document, Geom::Affine transform, Geom::Affine move); | ||
1544 | 69 | |||
1545 | 70 | bool isValid() const; | ||
1546 | 71 | |||
1547 | 72 | virtual cairo_pattern_t *pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); | ||
1548 | 73 | |||
1549 | 74 | protected: | ||
1550 | 75 | virtual void build(SPDocument *doc, Inkscape::XML::Node *repr); | ||
1551 | 76 | virtual void release(); | ||
1552 | 77 | virtual void set(unsigned int key, const gchar *value); | ||
1553 | 78 | virtual void update(SPCtx *ctx, unsigned int flags); | ||
1554 | 79 | virtual void modified(unsigned int flags); | ||
1555 | 80 | |||
1556 | 81 | private: | ||
1557 | 82 | bool _hasItemChildren() const; | ||
1558 | 83 | void _getChildren(std::list<SPObject *> &l); | ||
1559 | 84 | SPPattern *_chain() const; | ||
1560 | 85 | |||
1561 | 86 | /** | ||
1562 | 87 | Count how many times pattern is used by the styles of o and its descendants | ||
1563 | 88 | */ | ||
1564 | 89 | guint _countHrefs(SPObject *o) const; | ||
1565 | 90 | |||
1566 | 91 | /** | ||
1567 | 92 | Gets called when the pattern is reattached to another <pattern> | ||
1568 | 93 | */ | ||
1569 | 94 | void _onRefChanged(SPObject *old_ref, SPObject *ref); | ||
1570 | 95 | |||
1571 | 96 | /** | ||
1572 | 97 | Gets called when the referenced <pattern> is changed | ||
1573 | 98 | */ | ||
1574 | 99 | void _onRefModified(SPObject *ref, guint flags); | ||
1575 | 100 | |||
1576 | 40 | /* patternUnits and patternContentUnits attribute */ | 101 | /* patternUnits and patternContentUnits attribute */ |
1581 | 41 | unsigned int patternUnits : 1; | 102 | PatternUnits _pattern_units : 1; |
1582 | 42 | unsigned int patternUnits_set : 1; | 103 | bool _pattern_units_set : 1; |
1583 | 43 | unsigned int patternContentUnits : 1; | 104 | PatternUnits _pattern_content_units : 1; |
1584 | 44 | unsigned int patternContentUnits_set : 1; | 105 | bool _pattern_content_units_set : 1; |
1585 | 45 | /* patternTransform attribute */ | 106 | /* patternTransform attribute */ |
1588 | 46 | Geom::Affine patternTransform; | 107 | Geom::Affine _pattern_transform; |
1589 | 47 | unsigned int patternTransform_set : 1; | 108 | bool _pattern_transform_set : 1; |
1590 | 48 | /* Tile rectangle */ | 109 | /* Tile rectangle */ |
1608 | 49 | SVGLength x; | 110 | SVGLength _x; |
1609 | 50 | SVGLength y; | 111 | SVGLength _y; |
1610 | 51 | SVGLength width; | 112 | SVGLength _width; |
1611 | 52 | SVGLength height; | 113 | SVGLength _height; |
1612 | 53 | 114 | ||
1613 | 54 | sigc::connection modified_connection; | 115 | sigc::connection _modified_connection; |
1597 | 55 | |||
1598 | 56 | bool isValid() const; | ||
1599 | 57 | |||
1600 | 58 | virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); | ||
1601 | 59 | |||
1602 | 60 | protected: | ||
1603 | 61 | virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); | ||
1604 | 62 | virtual void release(); | ||
1605 | 63 | virtual void set(unsigned int key, const gchar* value); | ||
1606 | 64 | virtual void update(SPCtx* ctx, unsigned int flags); | ||
1607 | 65 | virtual void modified(unsigned int flags); | ||
1614 | 66 | }; | 116 | }; |
1615 | 67 | 117 | ||
1616 | 68 | 118 | ||
1617 | 69 | class SPPatternReference : public Inkscape::URIReference { | 119 | class SPPatternReference : public Inkscape::URIReference { |
1618 | 70 | public: | 120 | public: |
1621 | 71 | SPPatternReference (SPObject *obj) : URIReference(obj) {} | 121 | SPPatternReference(SPObject *obj) |
1622 | 72 | SPPattern *getObject() const { | 122 | : URIReference(obj) |
1623 | 123 | { | ||
1624 | 124 | } | ||
1625 | 125 | |||
1626 | 126 | SPPattern *getObject() const | ||
1627 | 127 | { | ||
1628 | 73 | return reinterpret_cast<SPPattern *>(URIReference::getObject()); | 128 | return reinterpret_cast<SPPattern *>(URIReference::getObject()); |
1629 | 74 | } | 129 | } |
1630 | 75 | 130 | ||
1631 | 76 | protected: | 131 | protected: |
1634 | 77 | virtual bool _acceptObject(SPObject *obj) const { | 132 | virtual bool _acceptObject(SPObject *obj) const |
1635 | 78 | return SP_IS_PATTERN (obj); | 133 | { |
1636 | 134 | return SP_IS_PATTERN(obj); | ||
1637 | 79 | } | 135 | } |
1638 | 80 | }; | 136 | }; |
1639 | 81 | 137 | ||
1640 | 82 | enum { | ||
1641 | 83 | SP_PATTERN_UNITS_USERSPACEONUSE, | ||
1642 | 84 | SP_PATTERN_UNITS_OBJECTBOUNDINGBOX | ||
1643 | 85 | }; | ||
1644 | 86 | |||
1645 | 87 | unsigned int pattern_users (SPPattern *pattern); | ||
1646 | 88 | SPPattern *pattern_chain (SPPattern *pattern); | ||
1647 | 89 | SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); | ||
1648 | 90 | void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); | ||
1649 | 91 | |||
1650 | 92 | const char *pattern_tile (const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); | ||
1651 | 93 | |||
1652 | 94 | SPPattern *pattern_getroot (SPPattern *pat); | ||
1653 | 95 | |||
1654 | 96 | unsigned int pattern_patternUnits (SPPattern const *pat); | ||
1655 | 97 | unsigned int pattern_patternContentUnits (SPPattern const *pat); | ||
1656 | 98 | Geom::Affine const &pattern_patternTransform(SPPattern const *pat); | ||
1657 | 99 | double pattern_x (SPPattern const *pat); | ||
1658 | 100 | double pattern_y (SPPattern const *pat); | ||
1659 | 101 | double pattern_width (SPPattern const *pat); | ||
1660 | 102 | double pattern_height (SPPattern const *pat); | ||
1661 | 103 | Geom::OptRect pattern_viewBox (SPPattern const *pat); | ||
1662 | 104 | |||
1663 | 105 | #endif // SEEN_SP_PATTERN_H | 138 | #endif // SEEN_SP_PATTERN_H |
1664 | 106 | 139 | ||
1665 | 107 | /* | 140 | /* |
1666 | 108 | 141 | ||
1667 | === modified file 'src/ui/CMakeLists.txt' | |||
1668 | --- src/ui/CMakeLists.txt 2015-05-12 20:23:05 +0000 | |||
1669 | +++ src/ui/CMakeLists.txt 2015-05-17 11:43:43 +0000 | |||
1670 | @@ -6,6 +6,7 @@ | |||
1671 | 6 | interface.cpp | 6 | interface.cpp |
1672 | 7 | object-edit.cpp | 7 | object-edit.cpp |
1673 | 8 | previewholder.cpp | 8 | previewholder.cpp |
1674 | 9 | selected-color.cpp | ||
1675 | 9 | shape-editor.cpp | 10 | shape-editor.cpp |
1676 | 10 | tool-factory.cpp | 11 | tool-factory.cpp |
1677 | 11 | tools-switch.cpp | 12 | tools-switch.cpp |
1678 | @@ -115,8 +116,14 @@ | |||
1679 | 115 | widget/anchor-selector.cpp | 116 | widget/anchor-selector.cpp |
1680 | 116 | widget/button.cpp | 117 | widget/button.cpp |
1681 | 117 | widget/clipmaskicon.cpp | 118 | widget/clipmaskicon.cpp |
1682 | 119 | widget/color-entry.cpp | ||
1683 | 120 | widget/color-icc-selector.cpp | ||
1684 | 121 | widget/color-notebook.cpp | ||
1685 | 118 | widget/color-picker.cpp | 122 | widget/color-picker.cpp |
1686 | 119 | widget/color-preview.cpp | 123 | widget/color-preview.cpp |
1687 | 124 | widget/color-scales.cpp | ||
1688 | 125 | widget/color-slider.cpp | ||
1689 | 126 | widget/color-wheel-selector.cpp | ||
1690 | 120 | widget/dock-item.cpp | 127 | widget/dock-item.cpp |
1691 | 121 | widget/dock.cpp | 128 | widget/dock.cpp |
1692 | 122 | widget/entity-entry.cpp | 129 | widget/entity-entry.cpp |
1693 | @@ -175,6 +182,7 @@ | |||
1694 | 175 | previewable.h | 182 | previewable.h |
1695 | 176 | previewfillable.h | 183 | previewfillable.h |
1696 | 177 | previewholder.h | 184 | previewholder.h |
1697 | 185 | selected-color.h | ||
1698 | 178 | shape-editor.h | 186 | shape-editor.h |
1699 | 179 | tool-factory.h | 187 | tool-factory.h |
1700 | 180 | tools-switch.h | 188 | tools-switch.h |
1701 | @@ -288,8 +296,14 @@ | |||
1702 | 288 | widget/anchor-selector.h | 296 | widget/anchor-selector.h |
1703 | 289 | widget/attr-widget.h | 297 | widget/attr-widget.h |
1704 | 290 | widget/button.h | 298 | widget/button.h |
1705 | 299 | widget/color-entry.h | ||
1706 | 300 | widget/color-icc-selector.h | ||
1707 | 301 | widget/color-notebook.h | ||
1708 | 291 | widget/color-picker.h | 302 | widget/color-picker.h |
1709 | 292 | widget/color-preview.h | 303 | widget/color-preview.h |
1710 | 304 | widget/color-scales.h | ||
1711 | 305 | widget/color-slider.h | ||
1712 | 306 | widget/color-wheel-selector.h | ||
1713 | 293 | widget/combo-enums.h | 307 | widget/combo-enums.h |
1714 | 294 | widget/dock-item.h | 308 | widget/dock-item.h |
1715 | 295 | widget/dock.h | 309 | widget/dock.h |
1716 | 296 | 310 | ||
1717 | === modified file 'src/ui/Makefile_insert' | |||
1718 | --- src/ui/Makefile_insert 2015-02-25 01:04:28 +0000 | |||
1719 | +++ src/ui/Makefile_insert 2015-05-17 11:43:43 +0000 | |||
1720 | @@ -19,6 +19,8 @@ | |||
1721 | 19 | ui/previewfillable.h \ | 19 | ui/previewfillable.h \ |
1722 | 20 | ui/previewholder.cpp \ | 20 | ui/previewholder.cpp \ |
1723 | 21 | ui/previewholder.h \ | 21 | ui/previewholder.h \ |
1724 | 22 | ui/selected-color.h \ | ||
1725 | 23 | ui/selected-color.cpp \ | ||
1726 | 22 | ui/shape-editor.cpp \ | 24 | ui/shape-editor.cpp \ |
1727 | 23 | ui/shape-editor.h \ | 25 | ui/shape-editor.h \ |
1728 | 24 | ui/tool-factory.cpp \ | 26 | ui/tool-factory.cpp \ |
1729 | 25 | 27 | ||
1730 | === modified file 'src/ui/dialog/objects.cpp' | |||
1731 | --- src/ui/dialog/objects.cpp 2015-02-27 02:10:36 +0000 | |||
1732 | +++ src/ui/dialog/objects.cpp 2015-05-17 11:43:43 +0000 | |||
1733 | @@ -45,6 +45,7 @@ | |||
1734 | 45 | #include "style.h" | 45 | #include "style.h" |
1735 | 46 | #include "ui/tools-switch.h" | 46 | #include "ui/tools-switch.h" |
1736 | 47 | #include "ui/icon-names.h" | 47 | #include "ui/icon-names.h" |
1737 | 48 | #include "ui/selected-color.h" | ||
1738 | 48 | #include "ui/widget/imagetoggler.h" | 49 | #include "ui/widget/imagetoggler.h" |
1739 | 49 | #include "ui/widget/layertypeicon.h" | 50 | #include "ui/widget/layertypeicon.h" |
1740 | 50 | #include "ui/widget/insertordericon.h" | 51 | #include "ui/widget/insertordericon.h" |
1741 | @@ -53,7 +54,7 @@ | |||
1742 | 53 | #include "ui/tools/node-tool.h" | 54 | #include "ui/tools/node-tool.h" |
1743 | 54 | #include "ui/tools/tool-base.h" | 55 | #include "ui/tools/tool-base.h" |
1744 | 55 | #include "verbs.h" | 56 | #include "verbs.h" |
1746 | 56 | #include "widgets/sp-color-notebook.h" | 57 | #include "ui/widget/color-notebook.h" |
1747 | 57 | #include "widgets/icon.h" | 58 | #include "widgets/icon.h" |
1748 | 58 | #include "xml/node.h" | 59 | #include "xml/node.h" |
1749 | 59 | #include "xml/node-observer.h" | 60 | #include "xml/node-observer.h" |
1750 | @@ -928,12 +929,12 @@ | |||
1751 | 928 | //If the current item is not selected, store only it in the highlight source | 929 | //If the current item is not selected, store only it in the highlight source |
1752 | 929 | _storeHighlightTarget(iter); | 930 | _storeHighlightTarget(iter); |
1753 | 930 | } | 931 | } |
1755 | 931 | if (_colorSelector) | 932 | if (_selectedColor) |
1756 | 932 | { | 933 | { |
1757 | 933 | //Set up the color selector | 934 | //Set up the color selector |
1758 | 934 | SPColor color; | 935 | SPColor color; |
1759 | 935 | color.set( row[_model->_colHighlight] ); | 936 | color.set( row[_model->_colHighlight] ); |
1761 | 936 | _colorSelector->base->setColorAlpha(color, SP_RGBA32_A_F(row[_model->_colHighlight])); | 937 | _selectedColor->setColorAlpha(color, SP_RGBA32_A_F(row[_model->_colHighlight])); |
1762 | 937 | } | 938 | } |
1763 | 938 | //Show the color selector dialog | 939 | //Show the color selector dialog |
1764 | 939 | _colorSelectorDialog.show(); | 940 | _colorSelectorDialog.show(); |
1765 | @@ -1440,17 +1441,16 @@ | |||
1766 | 1440 | * @param csel Color selector | 1441 | * @param csel Color selector |
1767 | 1441 | * @param cp Objects panel | 1442 | * @param cp Objects panel |
1768 | 1442 | */ | 1443 | */ |
1770 | 1443 | void sp_highlight_picker_color_mod(SPColorSelector *csel, GObject * cp) | 1444 | void ObjectsPanel::_highlightPickerColorMod() |
1771 | 1444 | { | 1445 | { |
1772 | 1445 | SPColor color; | 1446 | SPColor color; |
1773 | 1446 | float alpha = 0; | 1447 | float alpha = 0; |
1775 | 1447 | csel->base->getColorAlpha(color, alpha); | 1448 | _selectedColor->colorAlpha(color, alpha); |
1776 | 1449 | |||
1777 | 1448 | guint32 rgba = color.toRGBA32( alpha ); | 1450 | guint32 rgba = color.toRGBA32( alpha ); |
1778 | 1449 | |||
1779 | 1450 | ObjectsPanel *ptr = reinterpret_cast<ObjectsPanel *>(cp); | ||
1780 | 1451 | 1451 | ||
1781 | 1452 | //Set the highlight color for all items in the _highlight_target (all selected items) | 1452 | //Set the highlight color for all items in the _highlight_target (all selected items) |
1783 | 1453 | for (std::vector<SPItem *>::iterator iter = ptr->_highlight_target.begin(); iter != ptr->_highlight_target.end(); ++iter) | 1453 | for (std::vector<SPItem *>::iterator iter = _highlight_target.begin(); iter != _highlight_target.end(); ++iter) |
1784 | 1454 | { | 1454 | { |
1785 | 1455 | SPItem * target = *iter; | 1455 | SPItem * target = *iter; |
1786 | 1456 | target->setHighlightColor(rgba); | 1456 | target->setHighlightColor(rgba); |
1787 | @@ -1922,18 +1922,16 @@ | |||
1788 | 1922 | _colorSelectorDialog.set_title (_("Select Highlight Color")); | 1922 | _colorSelectorDialog.set_title (_("Select Highlight Color")); |
1789 | 1923 | _colorSelectorDialog.set_border_width (4); | 1923 | _colorSelectorDialog.set_border_width (4); |
1790 | 1924 | _colorSelectorDialog.property_modal() = true; | 1924 | _colorSelectorDialog.property_modal() = true; |
1792 | 1925 | _colorSelector = SP_COLOR_SELECTOR(sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK)); | 1925 | _selectedColor.reset(new Inkscape::UI::SelectedColor); |
1793 | 1926 | Gtk::Widget *color_selector = Gtk::manage(new Inkscape::UI::Widget::ColorNotebook(*_selectedColor)); | ||
1794 | 1926 | _colorSelectorDialog.get_vbox()->pack_start ( | 1927 | _colorSelectorDialog.get_vbox()->pack_start ( |
1805 | 1927 | *Glib::wrap(&_colorSelector->vbox), true, true, 0); | 1928 | *color_selector, true, true, 0); |
1806 | 1928 | 1929 | ||
1807 | 1929 | g_signal_connect(G_OBJECT(_colorSelector), "dragged", | 1930 | _selectedColor->signal_dragged.connect(sigc::mem_fun(*this, &ObjectsPanel::_highlightPickerColorMod)); |
1808 | 1930 | G_CALLBACK(sp_highlight_picker_color_mod), (void *)this); | 1931 | _selectedColor->signal_released.connect(sigc::mem_fun(*this, &ObjectsPanel::_highlightPickerColorMod)); |
1809 | 1931 | g_signal_connect(G_OBJECT(_colorSelector), "released", | 1932 | _selectedColor->signal_changed.connect(sigc::mem_fun(*this, &ObjectsPanel::_highlightPickerColorMod)); |
1810 | 1932 | G_CALLBACK(sp_highlight_picker_color_mod), (void *)this); | 1933 | |
1811 | 1933 | g_signal_connect(G_OBJECT(_colorSelector), "changed", | 1934 | color_selector->show(); |
1802 | 1934 | G_CALLBACK(sp_highlight_picker_color_mod), (void *)this); | ||
1803 | 1935 | |||
1804 | 1936 | gtk_widget_show(GTK_WIDGET(_colorSelector)); | ||
1812 | 1937 | 1935 | ||
1813 | 1938 | setDesktop( targetDesktop ); | 1936 | setDesktop( targetDesktop ); |
1814 | 1939 | 1937 | ||
1815 | @@ -1951,7 +1949,6 @@ | |||
1816 | 1951 | { | 1949 | { |
1817 | 1952 | //Close the highlight selection dialog | 1950 | //Close the highlight selection dialog |
1818 | 1953 | _colorSelectorDialog.hide(); | 1951 | _colorSelectorDialog.hide(); |
1819 | 1954 | _colorSelector = NULL; | ||
1820 | 1955 | 1952 | ||
1821 | 1956 | //Set the desktop to null, which will disconnect all object watchers | 1953 | //Set the desktop to null, which will disconnect all object watchers |
1822 | 1957 | setDesktop(NULL); | 1954 | setDesktop(NULL); |
1823 | 1958 | 1955 | ||
1824 | === modified file 'src/ui/dialog/objects.h' | |||
1825 | --- src/ui/dialog/objects.h 2015-04-27 23:38:31 +0000 | |||
1826 | +++ src/ui/dialog/objects.h 2015-05-17 11:43:43 +0000 | |||
1827 | @@ -16,6 +16,7 @@ | |||
1828 | 16 | # include <config.h> | 16 | # include <config.h> |
1829 | 17 | #endif | 17 | #endif |
1830 | 18 | 18 | ||
1831 | 19 | #include <boost/scoped_ptr.hpp> | ||
1832 | 19 | #include <gtkmm/box.h> | 20 | #include <gtkmm/box.h> |
1833 | 20 | #include <gtkmm/treeview.h> | 21 | #include <gtkmm/treeview.h> |
1834 | 21 | #include <gtkmm/treestore.h> | 22 | #include <gtkmm/treestore.h> |
1835 | @@ -36,6 +37,9 @@ | |||
1836 | 36 | namespace Inkscape { | 37 | namespace Inkscape { |
1837 | 37 | 38 | ||
1838 | 38 | namespace UI { | 39 | namespace UI { |
1839 | 40 | |||
1840 | 41 | class SelectedColor; | ||
1841 | 42 | |||
1842 | 39 | namespace Dialog { | 43 | namespace Dialog { |
1843 | 40 | 44 | ||
1844 | 41 | 45 | ||
1845 | @@ -166,8 +170,7 @@ | |||
1846 | 166 | Gtk::Alignment _blur_alignment; | 170 | Gtk::Alignment _blur_alignment; |
1847 | 167 | 171 | ||
1848 | 168 | Gtk::Dialog _colorSelectorDialog; | 172 | Gtk::Dialog _colorSelectorDialog; |
1851 | 169 | SPColorSelector *_colorSelector; | 173 | boost::scoped_ptr<Inkscape::UI::SelectedColor> _selectedColor; |
1850 | 170 | |||
1852 | 171 | 174 | ||
1853 | 172 | //Methods: | 175 | //Methods: |
1854 | 173 | 176 | ||
1855 | @@ -233,7 +236,7 @@ | |||
1856 | 233 | 236 | ||
1857 | 234 | void setupDialog(const Glib::ustring &title); | 237 | void setupDialog(const Glib::ustring &title); |
1858 | 235 | 238 | ||
1860 | 236 | friend void sp_highlight_picker_color_mod(SPColorSelector *csel, GObject *cp); | 239 | void _highlightPickerColorMod(); |
1861 | 237 | 240 | ||
1862 | 238 | }; | 241 | }; |
1863 | 239 | 242 | ||
1864 | 240 | 243 | ||
1865 | === modified file 'src/ui/dialog/tags.cpp' | |||
1866 | --- src/ui/dialog/tags.cpp 2015-02-27 03:21:48 +0000 | |||
1867 | +++ src/ui/dialog/tags.cpp 2015-05-17 11:43:43 +0000 | |||
1868 | @@ -51,7 +51,7 @@ | |||
1869 | 51 | #include "ui/tools/tool-base.h" //"event-context.h" | 51 | #include "ui/tools/tool-base.h" //"event-context.h" |
1870 | 52 | #include "selection.h" | 52 | #include "selection.h" |
1871 | 53 | //#include "dialogs/dialog-events.h" | 53 | //#include "dialogs/dialog-events.h" |
1873 | 54 | #include "widgets/sp-color-notebook.h" | 54 | #include "ui/widget/color-notebook.h" |
1874 | 55 | #include "style.h" | 55 | #include "style.h" |
1875 | 56 | #include "filter-chemistry.h" | 56 | #include "filter-chemistry.h" |
1876 | 57 | #include "filters/blend.h" | 57 | #include "filters/blend.h" |
1877 | 58 | 58 | ||
1878 | === added file 'src/ui/selected-color.cpp' | |||
1879 | --- src/ui/selected-color.cpp 1970-01-01 00:00:00 +0000 | |||
1880 | +++ src/ui/selected-color.cpp 2015-05-17 11:43:43 +0000 | |||
1881 | @@ -0,0 +1,163 @@ | |||
1882 | 1 | /** @file | ||
1883 | 2 | * Color selected in color selector widget. | ||
1884 | 3 | * This file was created during the refactoring of SPColorSelector | ||
1885 | 4 | *//* | ||
1886 | 5 | * Authors: | ||
1887 | 6 | * bulia byak <buliabyak@users.sf.net> | ||
1888 | 7 | * Jon A. Cruz <jon@joncruz.org> | ||
1889 | 8 | * Tomasz Boczkowski <penginsbacon@gmail.com> | ||
1890 | 9 | * | ||
1891 | 10 | * Copyright (C) 2014 Authors | ||
1892 | 11 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
1893 | 12 | */ | ||
1894 | 13 | #ifdef HAVE_CONFIG_H | ||
1895 | 14 | # include "config.h" | ||
1896 | 15 | #endif | ||
1897 | 16 | |||
1898 | 17 | #include <glibmm/ustring.h> | ||
1899 | 18 | #include <cmath> | ||
1900 | 19 | |||
1901 | 20 | #include "svg/svg-icc-color.h" | ||
1902 | 21 | #include "ui/selected-color.h" | ||
1903 | 22 | |||
1904 | 23 | namespace Inkscape { | ||
1905 | 24 | namespace UI { | ||
1906 | 25 | |||
1907 | 26 | double const SelectedColor::_EPSILON = 1e-4; | ||
1908 | 27 | |||
1909 | 28 | SelectedColor::SelectedColor() | ||
1910 | 29 | : _color(0) | ||
1911 | 30 | , _alpha(1.0) | ||
1912 | 31 | , _held(false) | ||
1913 | 32 | , _virgin(true) | ||
1914 | 33 | , _updating(false) | ||
1915 | 34 | { | ||
1916 | 35 | |||
1917 | 36 | } | ||
1918 | 37 | |||
1919 | 38 | SelectedColor::~SelectedColor() { | ||
1920 | 39 | |||
1921 | 40 | } | ||
1922 | 41 | |||
1923 | 42 | void SelectedColor::setColor(SPColor const &color) | ||
1924 | 43 | { | ||
1925 | 44 | setColorAlpha( color, _alpha); | ||
1926 | 45 | } | ||
1927 | 46 | |||
1928 | 47 | SPColor SelectedColor::color() const | ||
1929 | 48 | { | ||
1930 | 49 | return _color; | ||
1931 | 50 | } | ||
1932 | 51 | |||
1933 | 52 | void SelectedColor::setAlpha(gfloat alpha) | ||
1934 | 53 | { | ||
1935 | 54 | g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); | ||
1936 | 55 | setColorAlpha( _color, alpha); | ||
1937 | 56 | } | ||
1938 | 57 | |||
1939 | 58 | gfloat SelectedColor::alpha() const | ||
1940 | 59 | { | ||
1941 | 60 | return _alpha; | ||
1942 | 61 | } | ||
1943 | 62 | |||
1944 | 63 | void SelectedColor::setValue(guint32 value) | ||
1945 | 64 | { | ||
1946 | 65 | SPColor color(value); | ||
1947 | 66 | gfloat alpha = SP_RGBA32_A_F(value); | ||
1948 | 67 | setColorAlpha(color, alpha); | ||
1949 | 68 | } | ||
1950 | 69 | |||
1951 | 70 | guint32 SelectedColor::value() const | ||
1952 | 71 | { | ||
1953 | 72 | return color().toRGBA32(_alpha); | ||
1954 | 73 | } | ||
1955 | 74 | |||
1956 | 75 | void SelectedColor::setColorAlpha(SPColor const &color, gfloat alpha, bool emit_signal) | ||
1957 | 76 | { | ||
1958 | 77 | #ifdef DUMP_CHANGE_INFO | ||
1959 | 78 | g_message("SelectedColor::setColorAlpha( this=%p, %f, %f, %f, %s, %f, %s)", this, color.v.c[0], color.v.c[1], color.v.c[2], (color.icc?color.icc->colorProfile.c_str():"<null>"), alpha, (emit_signal?"YES":"no")); | ||
1960 | 79 | #endif | ||
1961 | 80 | g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); | ||
1962 | 81 | |||
1963 | 82 | if (_updating) { | ||
1964 | 83 | return; | ||
1965 | 84 | } | ||
1966 | 85 | |||
1967 | 86 | #ifdef DUMP_CHANGE_INFO | ||
1968 | 87 | g_message("---- SelectedColor::setColorAlpha virgin:%s !close:%s alpha is:%s", | ||
1969 | 88 | (_virgin?"YES":"no"), | ||
1970 | 89 | (!color.isClose( _color, _EPSILON )?"YES":"no"), | ||
1971 | 90 | ((fabs((_alpha) - (alpha)) >= _EPSILON )?"YES":"no") | ||
1972 | 91 | ); | ||
1973 | 92 | #endif | ||
1974 | 93 | |||
1975 | 94 | if ( _virgin || !color.isClose( _color, _EPSILON ) || | ||
1976 | 95 | (fabs((_alpha) - (alpha)) >= _EPSILON )) { | ||
1977 | 96 | |||
1978 | 97 | _virgin = false; | ||
1979 | 98 | |||
1980 | 99 | _color = color; | ||
1981 | 100 | _alpha = alpha; | ||
1982 | 101 | |||
1983 | 102 | if (emit_signal) | ||
1984 | 103 | { | ||
1985 | 104 | _updating = true; | ||
1986 | 105 | if (_held) { | ||
1987 | 106 | signal_dragged.emit(); | ||
1988 | 107 | } else { | ||
1989 | 108 | signal_changed.emit(); | ||
1990 | 109 | } | ||
1991 | 110 | _updating = false; | ||
1992 | 111 | } | ||
1993 | 112 | |||
1994 | 113 | #ifdef DUMP_CHANGE_INFO | ||
1995 | 114 | } else { | ||
1996 | 115 | g_message("++++ SelectedColor::setColorAlpha color:%08x ==> _color:%08X isClose:%s", color.toRGBA32(alpha), _color.toRGBA32(_alpha), | ||
1997 | 116 | (color.isClose( _color, _EPSILON )?"YES":"no")); | ||
1998 | 117 | #endif | ||
1999 | 118 | } | ||
2000 | 119 | } | ||
2001 | 120 | |||
2002 | 121 | void SelectedColor::colorAlpha(SPColor &color, gfloat &alpha) const { | ||
2003 | 122 | color = _color; | ||
2004 | 123 | alpha = _alpha; | ||
2005 | 124 | } | ||
2006 | 125 | |||
2007 | 126 | void SelectedColor::setHeld(bool held) { | ||
2008 | 127 | if (_updating) { | ||
2009 | 128 | return; | ||
2010 | 129 | } | ||
2011 | 130 | bool grabbed = held && !_held; | ||
2012 | 131 | bool released = !held && _held; | ||
2013 | 132 | |||
2014 | 133 | _held = held; | ||
2015 | 134 | |||
2016 | 135 | _updating = true; | ||
2017 | 136 | if (grabbed) { | ||
2018 | 137 | signal_grabbed.emit(); | ||
2019 | 138 | } | ||
2020 | 139 | |||
2021 | 140 | if (released) { | ||
2022 | 141 | signal_released.emit(); | ||
2023 | 142 | signal_changed.emit(); | ||
2024 | 143 | } | ||
2025 | 144 | _updating = false; | ||
2026 | 145 | } | ||
2027 | 146 | |||
2028 | 147 | void SelectedColor::preserveICC() { | ||
2029 | 148 | _color.icc = _color.icc ? new SVGICCColor(*_color.icc) : 0; | ||
2030 | 149 | } | ||
2031 | 150 | |||
2032 | 151 | } | ||
2033 | 152 | } | ||
2034 | 153 | |||
2035 | 154 | /* | ||
2036 | 155 | Local Variables: | ||
2037 | 156 | mode:c++ | ||
2038 | 157 | c-file-style:"stroustrup" | ||
2039 | 158 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
2040 | 159 | indent-tabs-mode:nil | ||
2041 | 160 | fill-column:99 | ||
2042 | 161 | End: | ||
2043 | 162 | */ | ||
2044 | 163 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
2045 | 0 | 164 | ||
2046 | === added file 'src/ui/selected-color.h' | |||
2047 | --- src/ui/selected-color.h 1970-01-01 00:00:00 +0000 | |||
2048 | +++ src/ui/selected-color.h 2015-05-17 11:43:43 +0000 | |||
2049 | @@ -0,0 +1,96 @@ | |||
2050 | 1 | /** @file | ||
2051 | 2 | * Color selected in color selector widget. | ||
2052 | 3 | * This file was created during the refactoring of SPColorSelector | ||
2053 | 4 | *//* | ||
2054 | 5 | * Authors: | ||
2055 | 6 | * bulia byak <buliabyak@users.sf.net> | ||
2056 | 7 | * Jon A. Cruz <jon@joncruz.org> | ||
2057 | 8 | * Tomasz Boczkowski <penginsbacon@gmail.com> | ||
2058 | 9 | * | ||
2059 | 10 | * Copyright (C) 2014 Authors | ||
2060 | 11 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
2061 | 12 | */ | ||
2062 | 13 | #ifndef SEEN_SELECTED_COLOR | ||
2063 | 14 | #define SEEN_SELECTED_COLOR | ||
2064 | 15 | |||
2065 | 16 | #include <sigc++/signal.h> | ||
2066 | 17 | #include "color.h" | ||
2067 | 18 | |||
2068 | 19 | namespace Gtk | ||
2069 | 20 | { | ||
2070 | 21 | class Widget; | ||
2071 | 22 | } | ||
2072 | 23 | |||
2073 | 24 | namespace Inkscape { | ||
2074 | 25 | namespace UI { | ||
2075 | 26 | |||
2076 | 27 | class SelectedColor { | ||
2077 | 28 | public: | ||
2078 | 29 | SelectedColor(); | ||
2079 | 30 | virtual ~SelectedColor(); | ||
2080 | 31 | |||
2081 | 32 | void setColor(SPColor const &color); | ||
2082 | 33 | SPColor color() const; | ||
2083 | 34 | |||
2084 | 35 | void setAlpha(gfloat alpha); | ||
2085 | 36 | gfloat alpha() const; | ||
2086 | 37 | |||
2087 | 38 | void setValue(guint32 value); | ||
2088 | 39 | guint32 value() const; | ||
2089 | 40 | |||
2090 | 41 | void setColorAlpha(SPColor const &color, gfloat alpha, bool emit_signal = true); | ||
2091 | 42 | void colorAlpha(SPColor &color, gfloat &alpha) const; | ||
2092 | 43 | |||
2093 | 44 | void setHeld(bool held); | ||
2094 | 45 | |||
2095 | 46 | void preserveICC(); | ||
2096 | 47 | |||
2097 | 48 | sigc::signal<void> signal_grabbed; | ||
2098 | 49 | sigc::signal<void> signal_dragged; | ||
2099 | 50 | sigc::signal<void> signal_released; | ||
2100 | 51 | sigc::signal<void> signal_changed; | ||
2101 | 52 | private: | ||
2102 | 53 | // By default, disallow copy constructor and assignment operator | ||
2103 | 54 | SelectedColor(SelectedColor const &obj); | ||
2104 | 55 | SelectedColor& operator=(SelectedColor const &obj); | ||
2105 | 56 | |||
2106 | 57 | SPColor _color; | ||
2107 | 58 | /** | ||
2108 | 59 | * Color alpha value guaranteed to be in [0, 1]. | ||
2109 | 60 | */ | ||
2110 | 61 | gfloat _alpha; | ||
2111 | 62 | |||
2112 | 63 | bool _held; | ||
2113 | 64 | /** | ||
2114 | 65 | * This flag is true if no color is set yet | ||
2115 | 66 | */ | ||
2116 | 67 | bool _virgin; | ||
2117 | 68 | |||
2118 | 69 | bool _updating; | ||
2119 | 70 | |||
2120 | 71 | static double const _EPSILON; | ||
2121 | 72 | }; | ||
2122 | 73 | |||
2123 | 74 | class ColorSelectorFactory { | ||
2124 | 75 | public: | ||
2125 | 76 | virtual ~ColorSelectorFactory() { | ||
2126 | 77 | } | ||
2127 | 78 | |||
2128 | 79 | virtual Gtk::Widget* createWidget(SelectedColor &color) const = 0; | ||
2129 | 80 | virtual Glib::ustring modeName() const = 0; | ||
2130 | 81 | }; | ||
2131 | 82 | |||
2132 | 83 | } | ||
2133 | 84 | } | ||
2134 | 85 | |||
2135 | 86 | #endif | ||
2136 | 87 | /* | ||
2137 | 88 | Local Variables: | ||
2138 | 89 | mode:c++ | ||
2139 | 90 | c-file-style:"stroustrup" | ||
2140 | 91 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
2141 | 92 | indent-tabs-mode:nil | ||
2142 | 93 | fill-column:99 | ||
2143 | 94 | End: | ||
2144 | 95 | */ | ||
2145 | 96 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
2146 | 0 | 97 | ||
2147 | === modified file 'src/ui/widget/Makefile_insert' | |||
2148 | --- src/ui/widget/Makefile_insert 2015-05-12 19:43:24 +0000 | |||
2149 | +++ src/ui/widget/Makefile_insert 2015-05-17 11:43:43 +0000 | |||
2150 | @@ -6,10 +6,22 @@ | |||
2151 | 6 | ui/widget/attr-widget.h \ | 6 | ui/widget/attr-widget.h \ |
2152 | 7 | ui/widget/button.h \ | 7 | ui/widget/button.h \ |
2153 | 8 | ui/widget/button.cpp \ | 8 | ui/widget/button.cpp \ |
2154 | 9 | ui/widget/color-entry.cpp \ | ||
2155 | 10 | ui/widget/color-entry.h \ | ||
2156 | 11 | ui/widget/color-icc-selector.cpp \ | ||
2157 | 12 | ui/widget/color-icc-selector.h \ | ||
2158 | 13 | ui/widget/color-notebook.cpp \ | ||
2159 | 14 | ui/widget/color-notebook.h \ | ||
2160 | 15 | ui/widget/color-wheel-selector.cpp \ | ||
2161 | 16 | ui/widget/color-wheel-selector.h \ | ||
2162 | 9 | ui/widget/color-picker.cpp \ | 17 | ui/widget/color-picker.cpp \ |
2163 | 10 | ui/widget/color-picker.h \ | 18 | ui/widget/color-picker.h \ |
2164 | 11 | ui/widget/color-preview.cpp \ | 19 | ui/widget/color-preview.cpp \ |
2165 | 12 | ui/widget/color-preview.h \ | 20 | ui/widget/color-preview.h \ |
2166 | 21 | ui/widget/color-slider.cpp \ | ||
2167 | 22 | ui/widget/color-slider.h \ | ||
2168 | 23 | ui/widget/color-scales.cpp \ | ||
2169 | 24 | ui/widget/color-scales.h \ | ||
2170 | 13 | ui/widget/combo-enums.h \ | 25 | ui/widget/combo-enums.h \ |
2171 | 14 | ui/widget/dock.h \ | 26 | ui/widget/dock.h \ |
2172 | 15 | ui/widget/dock.cpp \ | 27 | ui/widget/dock.cpp \ |
2173 | 16 | 28 | ||
2174 | === added file 'src/ui/widget/color-entry.cpp' | |||
2175 | --- src/ui/widget/color-entry.cpp 1970-01-01 00:00:00 +0000 | |||
2176 | +++ src/ui/widget/color-entry.cpp 2015-05-17 11:43:43 +0000 | |||
2177 | @@ -0,0 +1,104 @@ | |||
2178 | 1 | /** @file | ||
2179 | 2 | * Entry widget for typing color value in css form | ||
2180 | 3 | *//* | ||
2181 | 4 | * Authors: | ||
2182 | 5 | * Tomasz Boczkowski <penginsbacon@gmail.com> | ||
2183 | 6 | * | ||
2184 | 7 | * Copyright (C) 2014 Authors | ||
2185 | 8 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
2186 | 9 | */ | ||
2187 | 10 | #include <glibmm.h> | ||
2188 | 11 | #include <glibmm/i18n.h> | ||
2189 | 12 | #include <iomanip> | ||
2190 | 13 | |||
2191 | 14 | #include "color-entry.h" | ||
2192 | 15 | |||
2193 | 16 | namespace Inkscape { | ||
2194 | 17 | namespace UI { | ||
2195 | 18 | namespace Widget { | ||
2196 | 19 | |||
2197 | 20 | ColorEntry::ColorEntry(SelectedColor &color) | ||
2198 | 21 | : _color(color) | ||
2199 | 22 | , _updating(false) | ||
2200 | 23 | { | ||
2201 | 24 | _color_changed_connection = color.signal_changed.connect(sigc::mem_fun(this, &ColorEntry::_onColorChanged)); | ||
2202 | 25 | _color_dragged_connection = color.signal_dragged.connect(sigc::mem_fun(this, &ColorEntry::_onColorChanged)); | ||
2203 | 26 | _onColorChanged(); | ||
2204 | 27 | |||
2205 | 28 | set_max_length(8); | ||
2206 | 29 | set_width_chars(8); | ||
2207 | 30 | set_tooltip_text(_("Hexadecimal RGBA value of the color")); | ||
2208 | 31 | } | ||
2209 | 32 | |||
2210 | 33 | ColorEntry::~ColorEntry() | ||
2211 | 34 | { | ||
2212 | 35 | _color_changed_connection.disconnect(); | ||
2213 | 36 | _color_dragged_connection.disconnect(); | ||
2214 | 37 | } | ||
2215 | 38 | |||
2216 | 39 | void ColorEntry::on_changed() | ||
2217 | 40 | { | ||
2218 | 41 | if (_updating) { | ||
2219 | 42 | return; | ||
2220 | 43 | } | ||
2221 | 44 | |||
2222 | 45 | Glib::ustring text = get_text(); | ||
2223 | 46 | bool changed = false; | ||
2224 | 47 | |||
2225 | 48 | // Coerce the value format to eight hex digits | ||
2226 | 49 | if (!text.empty() && text[0] == '#') { | ||
2227 | 50 | changed = true; | ||
2228 | 51 | text.erase(0, 1); | ||
2229 | 52 | if (text.size() == 6) { | ||
2230 | 53 | // it was a standard RGB hex | ||
2231 | 54 | unsigned int alpha = SP_COLOR_F_TO_U(_color.alpha()); | ||
2232 | 55 | text += Glib::ustring::format(std::hex, std::setw(2), std::setfill(L'0'), alpha); | ||
2233 | 56 | } | ||
2234 | 57 | } | ||
2235 | 58 | |||
2236 | 59 | gchar *str = g_strdup(text.c_str()); | ||
2237 | 60 | gchar *end = 0; | ||
2238 | 61 | guint64 rgba = g_ascii_strtoull(str, &end, 16); | ||
2239 | 62 | if (end != str) { | ||
2240 | 63 | ptrdiff_t len = end - str; | ||
2241 | 64 | if (len < 8) { | ||
2242 | 65 | rgba = rgba << (4 * (8 - len)); | ||
2243 | 66 | } | ||
2244 | 67 | if (changed) { | ||
2245 | 68 | set_text(str); | ||
2246 | 69 | } | ||
2247 | 70 | SPColor color(rgba); | ||
2248 | 71 | _color.setColorAlpha(color, SP_RGBA32_A_F(rgba)); | ||
2249 | 72 | } | ||
2250 | 73 | g_free(str); | ||
2251 | 74 | } | ||
2252 | 75 | |||
2253 | 76 | |||
2254 | 77 | void ColorEntry::_onColorChanged() | ||
2255 | 78 | { | ||
2256 | 79 | SPColor color = _color.color(); | ||
2257 | 80 | gdouble alpha = _color.alpha(); | ||
2258 | 81 | |||
2259 | 82 | guint32 rgba = color.toRGBA32(alpha); | ||
2260 | 83 | Glib::ustring text = Glib::ustring::format(std::hex, std::setw(8), std::setfill(L'0'), rgba); | ||
2261 | 84 | |||
2262 | 85 | Glib::ustring old_text = get_text(); | ||
2263 | 86 | if (old_text != text) { | ||
2264 | 87 | _updating = true; | ||
2265 | 88 | set_text(text); | ||
2266 | 89 | _updating = false; | ||
2267 | 90 | } | ||
2268 | 91 | } | ||
2269 | 92 | } | ||
2270 | 93 | } | ||
2271 | 94 | } | ||
2272 | 95 | /* | ||
2273 | 96 | Local Variables: | ||
2274 | 97 | mode:c++ | ||
2275 | 98 | c-file-style:"stroustrup" | ||
2276 | 99 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
2277 | 100 | indent-tabs-mode:nil | ||
2278 | 101 | fill-column:99 | ||
2279 | 102 | End: | ||
2280 | 103 | */ | ||
2281 | 104 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
2282 | 0 | 105 | ||
2283 | === added file 'src/ui/widget/color-entry.h' | |||
2284 | --- src/ui/widget/color-entry.h 1970-01-01 00:00:00 +0000 | |||
2285 | +++ src/ui/widget/color-entry.h 2015-05-17 11:43:43 +0000 | |||
2286 | @@ -0,0 +1,53 @@ | |||
2287 | 1 | /** @file | ||
2288 | 2 | * Entry widget for typing color value in css form | ||
2289 | 3 | *//* | ||
2290 | 4 | * Authors: | ||
2291 | 5 | * Tomasz Boczkowski <penginsbacon@gmail.com> | ||
2292 | 6 | * | ||
2293 | 7 | * Copyright (C) 2014 Authors | ||
2294 | 8 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
2295 | 9 | */ | ||
2296 | 10 | |||
2297 | 11 | #ifndef SEEN_COLOR_ENTRY_H | ||
2298 | 12 | #define SEEN_COLOR_ENTRY_H_ | ||
2299 | 13 | |||
2300 | 14 | #include <gtkmm/entry.h> | ||
2301 | 15 | #include "ui/selected-color.h" | ||
2302 | 16 | |||
2303 | 17 | namespace Inkscape { | ||
2304 | 18 | namespace UI { | ||
2305 | 19 | namespace Widget { | ||
2306 | 20 | |||
2307 | 21 | class ColorEntry : public Gtk::Entry | ||
2308 | 22 | { | ||
2309 | 23 | public: | ||
2310 | 24 | ColorEntry(SelectedColor &color); | ||
2311 | 25 | virtual ~ColorEntry(); | ||
2312 | 26 | |||
2313 | 27 | protected: | ||
2314 | 28 | void on_changed(); | ||
2315 | 29 | |||
2316 | 30 | private: | ||
2317 | 31 | void _onColorChanged(); | ||
2318 | 32 | |||
2319 | 33 | SelectedColor &_color; | ||
2320 | 34 | sigc::connection _color_changed_connection; | ||
2321 | 35 | sigc::connection _color_dragged_connection; | ||
2322 | 36 | bool _updating; | ||
2323 | 37 | }; | ||
2324 | 38 | |||
2325 | 39 | } | ||
2326 | 40 | } | ||
2327 | 41 | } | ||
2328 | 42 | |||
2329 | 43 | #endif | ||
2330 | 44 | /* | ||
2331 | 45 | Local Variables: | ||
2332 | 46 | mode:c++ | ||
2333 | 47 | c-file-style:"stroustrup" | ||
2334 | 48 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
2335 | 49 | indent-tabs-mode:nil | ||
2336 | 50 | fill-column:99 | ||
2337 | 51 | End: | ||
2338 | 52 | */ | ||
2339 | 53 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
2340 | 0 | 54 | ||
2341 | === renamed file 'src/widgets/sp-color-icc-selector.cpp' => 'src/ui/widget/color-icc-selector.cpp' | |||
2342 | --- src/widgets/sp-color-icc-selector.cpp 2014-10-08 02:22:03 +0000 | |||
2343 | +++ src/ui/widget/color-icc-selector.cpp 2015-05-17 11:43:43 +0000 | |||
2344 | @@ -1,24 +1,26 @@ | |||
2345 | 1 | #ifdef HAVE_CONFIG_H | 1 | #ifdef HAVE_CONFIG_H |
2347 | 2 | # include "config.h" | 2 | #include "config.h" |
2348 | 3 | #endif | 3 | #endif |
2349 | 4 | 4 | ||
2350 | 5 | #include "gradient-vector.h" | ||
2351 | 6 | #include <math.h> | 5 | #include <math.h> |
2352 | 6 | #include <gtkmm/adjustment.h> | ||
2353 | 7 | #include <glibmm/i18n.h> | ||
2354 | 8 | |||
2355 | 7 | #include <gtk/gtk.h> | 9 | #include <gtk/gtk.h> |
2356 | 8 | #include <glibmm/i18n.h> | ||
2357 | 9 | #include <map> | 10 | #include <map> |
2358 | 10 | #include <set> | 11 | #include <set> |
2359 | 11 | #include <vector> | 12 | #include <vector> |
2360 | 12 | 13 | ||
2361 | 13 | #include "ui/dialog-events.h" | 14 | #include "ui/dialog-events.h" |
2365 | 14 | #include "sp-color-icc-selector.h" | 15 | #include "ui/widget/color-icc-selector.h" |
2366 | 15 | #include "sp-color-scales.h" | 16 | #include "ui/widget/color-scales.h" |
2367 | 16 | #include "sp-color-slider.h" | 17 | #include "ui/widget/color-slider.h" |
2368 | 17 | #include "svg/svg-icc-color.h" | 18 | #include "svg/svg-icc-color.h" |
2369 | 18 | #include "colorspace.h" | 19 | #include "colorspace.h" |
2370 | 19 | #include "document.h" | 20 | #include "document.h" |
2371 | 20 | #include "inkscape.h" | 21 | #include "inkscape.h" |
2372 | 21 | #include "profile-manager.h" | 22 | #include "profile-manager.h" |
2373 | 23 | #include "widgets/gradient-vector.h" | ||
2374 | 22 | 24 | ||
2375 | 23 | #define noDEBUG_LCMS | 25 | #define noDEBUG_LCMS |
2376 | 24 | 26 | ||
2377 | @@ -32,137 +34,32 @@ | |||
2378 | 32 | #endif // DEBUG_LCMS | 34 | #endif // DEBUG_LCMS |
2379 | 33 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 35 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2380 | 34 | 36 | ||
2381 | 35 | |||
2382 | 36 | #ifdef DEBUG_LCMS | 37 | #ifdef DEBUG_LCMS |
2383 | 37 | extern guint update_in_progress; | 38 | extern guint update_in_progress; |
2410 | 38 | #define DEBUG_MESSAGE(key, ...) \ | 39 | #define DEBUG_MESSAGE(key, ...) \ |
2411 | 39 | {\ | 40 | { \ |
2412 | 40 | Inkscape::Preferences *prefs = Inkscape::Preferences::get();\ | 41 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); \ |
2413 | 41 | bool dump = prefs->getBool("/options/scislac/" #key);\ | 42 | bool dump = prefs->getBool("/options/scislac/" #key); \ |
2414 | 42 | bool dumpD = prefs->getBool("/options/scislac/" #key "D");\ | 43 | bool dumpD = prefs->getBool("/options/scislac/" #key "D"); \ |
2415 | 43 | bool dumpD2 = prefs->getBool("/options/scislac/" #key "D2");\ | 44 | bool dumpD2 = prefs->getBool("/options/scislac/" #key "D2"); \ |
2416 | 44 | dumpD &&= ( (update_in_progress == 0) || dumpD2 );\ | 45 | dumpD && = ((update_in_progress == 0) || dumpD2); \ |
2417 | 45 | if ( dump )\ | 46 | if (dump) { \ |
2418 | 46 | {\ | 47 | g_message(__VA_ARGS__); \ |
2419 | 47 | g_message( __VA_ARGS__ );\ | 48 | } \ |
2420 | 48 | \ | 49 | if (dumpD) { \ |
2421 | 49 | }\ | 50 | GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, \ |
2422 | 50 | if ( dumpD )\ | 51 | GTK_BUTTONS_OK, __VA_ARGS__); \ |
2423 | 51 | {\ | 52 | g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog); \ |
2424 | 52 | GtkWidget *dialog = gtk_message_dialog_new(NULL,\ | 53 | gtk_widget_show_all(dialog); \ |
2425 | 53 | GTK_DIALOG_DESTROY_WITH_PARENT, \ | 54 | } \ |
2426 | 54 | GTK_MESSAGE_INFO, \ | 55 | } |
2401 | 55 | GTK_BUTTONS_OK, \ | ||
2402 | 56 | __VA_ARGS__ \ | ||
2403 | 57 | );\ | ||
2404 | 58 | g_signal_connect_swapped(dialog, "response",\ | ||
2405 | 59 | G_CALLBACK(gtk_widget_destroy), \ | ||
2406 | 60 | dialog); \ | ||
2407 | 61 | gtk_widget_show_all( dialog );\ | ||
2408 | 62 | }\ | ||
2409 | 63 | } | ||
2427 | 64 | #endif // DEBUG_LCMS | 56 | #endif // DEBUG_LCMS |
2428 | 65 | 57 | ||
2429 | 66 | 58 | ||
2430 | 67 | |||
2431 | 68 | G_BEGIN_DECLS | ||
2432 | 69 | |||
2433 | 70 | static void sp_color_icc_selector_dispose(GObject *object); | ||
2434 | 71 | static void sp_color_icc_selector_show_all (GtkWidget *widget); | ||
2435 | 72 | static void sp_color_icc_selector_hide(GtkWidget *widget); | ||
2436 | 73 | |||
2437 | 74 | G_END_DECLS | ||
2438 | 75 | |||
2439 | 76 | /** | ||
2440 | 77 | * Class containing the parts for a single color component's UI presence. | ||
2441 | 78 | */ | ||
2442 | 79 | class ComponentUI | ||
2443 | 80 | { | ||
2444 | 81 | public: | ||
2445 | 82 | ComponentUI() : | ||
2446 | 83 | _component(), | ||
2447 | 84 | _adj(0), | ||
2448 | 85 | _slider(0), | ||
2449 | 86 | _btn(0), | ||
2450 | 87 | _label(0), | ||
2451 | 88 | _map(0) | ||
2452 | 89 | { | ||
2453 | 90 | } | ||
2454 | 91 | |||
2455 | 92 | ComponentUI(colorspace::Component const &component) : | ||
2456 | 93 | _component(component), | ||
2457 | 94 | _adj(0), | ||
2458 | 95 | _slider(0), | ||
2459 | 96 | _btn(0), | ||
2460 | 97 | _label(0), | ||
2461 | 98 | _map(0) | ||
2462 | 99 | { | ||
2463 | 100 | } | ||
2464 | 101 | |||
2465 | 102 | colorspace::Component _component; | ||
2466 | 103 | GtkAdjustment *_adj; // Component adjustment | ||
2467 | 104 | GtkWidget *_slider; | ||
2468 | 105 | GtkWidget *_btn; // spinbutton | ||
2469 | 106 | GtkWidget *_label; // Label | ||
2470 | 107 | guchar *_map; | ||
2471 | 108 | }; | ||
2472 | 109 | |||
2473 | 110 | /** | ||
2474 | 111 | * Class that implements the internals of the selector. | ||
2475 | 112 | */ | ||
2476 | 113 | class ColorICCSelectorImpl | ||
2477 | 114 | { | ||
2478 | 115 | public: | ||
2479 | 116 | |||
2480 | 117 | ColorICCSelectorImpl( ColorICCSelector *owner); | ||
2481 | 118 | |||
2482 | 119 | ~ColorICCSelectorImpl(); | ||
2483 | 120 | |||
2484 | 121 | static void _adjustmentChanged ( GtkAdjustment *adjustment, SPColorICCSelector *cs ); | ||
2485 | 122 | |||
2486 | 123 | static void _sliderGrabbed( SPColorSlider *slider, SPColorICCSelector *cs ); | ||
2487 | 124 | static void _sliderReleased( SPColorSlider *slider, SPColorICCSelector *cs ); | ||
2488 | 125 | static void _sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ); | ||
2489 | 126 | |||
2490 | 127 | static void _profileSelected( GtkWidget* src, gpointer data ); | ||
2491 | 128 | static void _fixupHit( GtkWidget* src, gpointer data ); | ||
2492 | 129 | |||
2493 | 130 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
2494 | 131 | void _setProfile( SVGICCColor* profile ); | ||
2495 | 132 | void _switchToProfile( gchar const* name ); | ||
2496 | 133 | #endif | ||
2497 | 134 | void _updateSliders( gint ignore ); | ||
2498 | 135 | void _profilesChanged( std::string const & name ); | ||
2499 | 136 | |||
2500 | 137 | ColorICCSelector *_owner; | ||
2501 | 138 | |||
2502 | 139 | gboolean _updating : 1; | ||
2503 | 140 | gboolean _dragging : 1; | ||
2504 | 141 | |||
2505 | 142 | guint32 _fixupNeeded; | ||
2506 | 143 | GtkWidget* _fixupBtn; | ||
2507 | 144 | GtkWidget* _profileSel; | ||
2508 | 145 | |||
2509 | 146 | std::vector<ComponentUI> _compUI; | ||
2510 | 147 | |||
2511 | 148 | GtkAdjustment* _adj; // Channel adjustment | ||
2512 | 149 | GtkWidget* _slider; | ||
2513 | 150 | GtkWidget* _sbtn; // Spinbutton | ||
2514 | 151 | GtkWidget* _label; // Label | ||
2515 | 152 | |||
2516 | 153 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
2517 | 154 | std::string _profileName; | ||
2518 | 155 | Inkscape::ColorProfile* _prof; | ||
2519 | 156 | guint _profChannelCount; | ||
2520 | 157 | gulong _profChangedID; | ||
2521 | 158 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
2522 | 159 | }; | ||
2523 | 160 | |||
2524 | 161 | #define XPAD 4 | 59 | #define XPAD 4 |
2525 | 162 | #define YPAD 1 | 60 | #define YPAD 1 |
2526 | 163 | 61 | ||
2529 | 164 | namespace | 62 | namespace { |
2528 | 165 | { | ||
2530 | 166 | 63 | ||
2531 | 167 | size_t maxColorspaceComponentCount = 0; | 64 | size_t maxColorspaceComponentCount = 0; |
2532 | 168 | 65 | ||
2533 | @@ -187,91 +84,40 @@ | |||
2534 | 187 | /** | 84 | /** |
2535 | 188 | * Helper function to handle GTK2/GTK3 attachment #ifdef code. | 85 | * Helper function to handle GTK2/GTK3 attachment #ifdef code. |
2536 | 189 | */ | 86 | */ |
2547 | 190 | void attachToGridOrTable(GtkWidget *parent, | 87 | void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint top, guint width, guint height, |
2548 | 191 | GtkWidget *child, | 88 | bool hexpand = false, bool centered = false, guint xpadding = XPAD, guint ypadding = YPAD) |
2539 | 192 | guint left, | ||
2540 | 193 | guint top, | ||
2541 | 194 | guint width, | ||
2542 | 195 | guint height, | ||
2543 | 196 | bool hexpand = false, | ||
2544 | 197 | bool centered = false, | ||
2545 | 198 | guint xpadding = XPAD, | ||
2546 | 199 | guint ypadding = YPAD) | ||
2549 | 200 | { | 89 | { |
2558 | 201 | #if GTK_CHECK_VERSION(3,0,0) | 90 | #if GTK_CHECK_VERSION(3, 0, 0) |
2559 | 202 | #if GTK_CHECK_VERSION(3,12,0) | 91 | #if GTK_CHECK_VERSION(3, 12, 0) |
2560 | 203 | gtk_widget_set_margin_start( child, xpadding ); | 92 | gtk_widget_set_margin_start(child, xpadding); |
2561 | 204 | gtk_widget_set_margin_end( child, xpadding ); | 93 | gtk_widget_set_margin_end(child, xpadding); |
2562 | 205 | #else | 94 | #else |
2563 | 206 | gtk_widget_set_margin_left( child, xpadding ); | 95 | gtk_widget_set_margin_left(child, xpadding); |
2564 | 207 | gtk_widget_set_margin_right( child, xpadding ); | 96 | gtk_widget_set_margin_right(child, xpadding); |
2565 | 208 | #endif | 97 | #endif |
2566 | 209 | 98 | ||
2569 | 210 | gtk_widget_set_margin_top( child, ypadding ); | 99 | gtk_widget_set_margin_top(child, ypadding); |
2570 | 211 | gtk_widget_set_margin_bottom( child, ypadding ); | 100 | gtk_widget_set_margin_bottom(child, ypadding); |
2571 | 212 | if (hexpand) { | 101 | if (hexpand) { |
2572 | 213 | gtk_widget_set_hexpand(child, TRUE); | 102 | gtk_widget_set_hexpand(child, TRUE); |
2573 | 214 | } | 103 | } |
2574 | 215 | if (centered) { | 104 | if (centered) { |
2577 | 216 | gtk_widget_set_halign( child, GTK_ALIGN_CENTER ); | 105 | gtk_widget_set_halign(child, GTK_ALIGN_CENTER); |
2578 | 217 | gtk_widget_set_valign( child, GTK_ALIGN_CENTER ); | 106 | gtk_widget_set_valign(child, GTK_ALIGN_CENTER); |
2579 | 218 | } | 107 | } |
2581 | 219 | gtk_grid_attach( GTK_GRID(parent), child, left, top, width, height ); | 108 | gtk_grid_attach(GTK_GRID(parent), child, left, top, width, height); |
2582 | 220 | #else | 109 | #else |
2584 | 221 | GtkAttachOptions xoptions = centered ? static_cast<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL; | 110 | GtkAttachOptions xoptions = |
2585 | 111 | centered ? static_cast<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL; | ||
2586 | 222 | GtkAttachOptions yoptions = centered ? static_cast<GtkAttachOptions>(0) : GTK_FILL; | 112 | GtkAttachOptions yoptions = centered ? static_cast<GtkAttachOptions>(0) : GTK_FILL; |
2587 | 223 | 113 | ||
2589 | 224 | gtk_table_attach( GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding, ypadding ); | 114 | gtk_table_attach(GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding, |
2590 | 115 | ypadding); | ||
2591 | 225 | #endif | 116 | #endif |
2592 | 226 | } | 117 | } |
2593 | 227 | 118 | ||
2594 | 228 | } // namespace | 119 | } // namespace |
2595 | 229 | 120 | ||
2596 | 230 | G_DEFINE_TYPE(SPColorICCSelector, sp_color_icc_selector, SP_TYPE_COLOR_SELECTOR); | ||
2597 | 231 | |||
2598 | 232 | static void sp_color_icc_selector_class_init(SPColorICCSelectorClass *klass) | ||
2599 | 233 | { | ||
2600 | 234 | static const gchar* nameset[] = {N_("CMS"), 0}; | ||
2601 | 235 | GObjectClass *object_class = G_OBJECT_CLASS(klass); | ||
2602 | 236 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); | ||
2603 | 237 | SPColorSelectorClass *selector_class = SP_COLOR_SELECTOR_CLASS (klass); | ||
2604 | 238 | |||
2605 | 239 | selector_class->name = nameset; | ||
2606 | 240 | selector_class->submode_count = 1; | ||
2607 | 241 | |||
2608 | 242 | object_class->dispose = sp_color_icc_selector_dispose; | ||
2609 | 243 | |||
2610 | 244 | widget_class->show_all = sp_color_icc_selector_show_all; | ||
2611 | 245 | widget_class->hide = sp_color_icc_selector_hide; | ||
2612 | 246 | } | ||
2613 | 247 | |||
2614 | 248 | |||
2615 | 249 | ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) | ||
2616 | 250 | : ColorSelector( csel ), | ||
2617 | 251 | _impl(NULL) | ||
2618 | 252 | { | ||
2619 | 253 | } | ||
2620 | 254 | |||
2621 | 255 | ColorICCSelector::~ColorICCSelector() | ||
2622 | 256 | { | ||
2623 | 257 | if (_impl) | ||
2624 | 258 | { | ||
2625 | 259 | delete _impl; | ||
2626 | 260 | _impl = 0; | ||
2627 | 261 | } | ||
2628 | 262 | } | ||
2629 | 263 | |||
2630 | 264 | void sp_color_icc_selector_init(SPColorICCSelector *cs) | ||
2631 | 265 | { | ||
2632 | 266 | SP_COLOR_SELECTOR(cs)->base = new ColorICCSelector( SP_COLOR_SELECTOR(cs) ); | ||
2633 | 267 | |||
2634 | 268 | if ( SP_COLOR_SELECTOR(cs)->base ) | ||
2635 | 269 | { | ||
2636 | 270 | SP_COLOR_SELECTOR(cs)->base->init(); | ||
2637 | 271 | } | ||
2638 | 272 | } | ||
2639 | 273 | |||
2640 | 274 | |||
2641 | 275 | /* | 121 | /* |
2642 | 276 | icSigRgbData | 122 | icSigRgbData |
2643 | 277 | icSigCmykData | 123 | icSigCmykData |
2644 | @@ -283,32 +129,32 @@ | |||
2645 | 283 | 129 | ||
2646 | 284 | 130 | ||
2647 | 285 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 131 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2649 | 286 | static cmsUInt16Number* getScratch() { | 132 | static cmsUInt16Number *getScratch() |
2650 | 133 | { | ||
2651 | 287 | // bytes per pixel * input channels * width | 134 | // bytes per pixel * input channels * width |
2653 | 288 | static cmsUInt16Number* scritch = static_cast<cmsUInt16Number*>(g_new(cmsUInt16Number, 4 * 1024)); | 135 | static cmsUInt16Number *scritch = static_cast<cmsUInt16Number *>(g_new(cmsUInt16Number, 4 * 1024)); |
2654 | 289 | 136 | ||
2655 | 290 | return scritch; | 137 | return scritch; |
2656 | 291 | } | 138 | } |
2657 | 292 | 139 | ||
2673 | 293 | colorspace::Component::Component() : | 140 | colorspace::Component::Component() |
2674 | 294 | name(), | 141 | : name() |
2675 | 295 | tip(), | 142 | , tip() |
2676 | 296 | scale(1) | 143 | , scale(1) |
2677 | 297 | { | 144 | { |
2678 | 298 | } | 145 | } |
2679 | 299 | 146 | ||
2680 | 300 | colorspace::Component::Component(std::string const &name, std::string const &tip, guint scale) : | 147 | colorspace::Component::Component(std::string const &name, std::string const &tip, guint scale) |
2681 | 301 | name(name), | 148 | : name(name) |
2682 | 302 | tip(tip), | 149 | , tip(tip) |
2683 | 303 | scale(scale) | 150 | , scale(scale) |
2684 | 304 | { | 151 | { |
2685 | 305 | } | 152 | } |
2686 | 306 | 153 | ||
2687 | 307 | std::vector<colorspace::Component> colorspace::getColorSpaceInfo( uint32_t space ) | 154 | std::vector<colorspace::Component> colorspace::getColorSpaceInfo(uint32_t space) |
2688 | 308 | { | 155 | { |
2689 | 309 | static std::map<cmsUInt32Number, std::vector<Component> > sets; | 156 | static std::map<cmsUInt32Number, std::vector<Component> > sets; |
2692 | 310 | if (sets.empty()) | 157 | if (sets.empty()) { |
2691 | 311 | { | ||
2693 | 312 | sets[cmsSigXYZData].push_back(Component("_X", "X", 2)); // TYPE_XYZ_16 | 158 | sets[cmsSigXYZData].push_back(Component("_X", "X", 2)); // TYPE_XYZ_16 |
2694 | 313 | sets[cmsSigXYZData].push_back(Component("_Y", "Y", 1)); | 159 | sets[cmsSigXYZData].push_back(Component("_Y", "Y", 1)); |
2695 | 314 | sets[cmsSigXYZData].push_back(Component("_Z", "Z", 2)); | 160 | sets[cmsSigXYZData].push_back(Component("_Z", "Z", 2)); |
2696 | @@ -317,7 +163,7 @@ | |||
2697 | 317 | sets[cmsSigLabData].push_back(Component("_a", "a", 256)); | 163 | sets[cmsSigLabData].push_back(Component("_a", "a", 256)); |
2698 | 318 | sets[cmsSigLabData].push_back(Component("_b", "b", 256)); | 164 | sets[cmsSigLabData].push_back(Component("_b", "b", 256)); |
2699 | 319 | 165 | ||
2701 | 320 | //cmsSigLuvData | 166 | // cmsSigLuvData |
2702 | 321 | 167 | ||
2703 | 322 | sets[cmsSigYCbCrData].push_back(Component("_Y", "Y", 1)); // TYPE_YCbCr_16 | 168 | sets[cmsSigYCbCrData].push_back(Component("_Y", "Y", 1)); // TYPE_YCbCr_16 |
2704 | 323 | sets[cmsSigYCbCrData].push_back(Component("C_b", "Cb", 1)); | 169 | sets[cmsSigYCbCrData].push_back(Component("C_b", "Cb", 1)); |
2705 | @@ -350,8 +196,7 @@ | |||
2706 | 350 | sets[cmsSigCmyData].push_back(Component(_("_M:"), _("Magenta"), 1)); | 196 | sets[cmsSigCmyData].push_back(Component(_("_M:"), _("Magenta"), 1)); |
2707 | 351 | sets[cmsSigCmyData].push_back(Component(_("_Y:"), _("Yellow"), 1)); | 197 | sets[cmsSigCmyData].push_back(Component(_("_Y:"), _("Yellow"), 1)); |
2708 | 352 | 198 | ||
2711 | 353 | for (std::map<cmsUInt32Number, std::vector<Component> >::iterator it = sets.begin(); it != sets.end(); ++it) | 199 | for (std::map<cmsUInt32Number, std::vector<Component> >::iterator it = sets.begin(); it != sets.end(); ++it) { |
2710 | 354 | { | ||
2712 | 355 | knownColorspaces.insert(it->first); | 200 | knownColorspaces.insert(it->first); |
2713 | 356 | maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, it->second.size()); | 201 | maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, it->second.size()); |
2714 | 357 | } | 202 | } |
2715 | @@ -359,39 +204,148 @@ | |||
2716 | 359 | 204 | ||
2717 | 360 | std::vector<Component> target; | 205 | std::vector<Component> target; |
2718 | 361 | 206 | ||
2721 | 362 | if (sets.find(space) != sets.end()) | 207 | if (sets.find(space) != sets.end()) { |
2720 | 363 | { | ||
2722 | 364 | target = sets[space]; | 208 | target = sets[space]; |
2723 | 365 | } | 209 | } |
2724 | 366 | return target; | 210 | return target; |
2725 | 367 | } | 211 | } |
2726 | 368 | 212 | ||
2727 | 369 | 213 | ||
2753 | 370 | std::vector<colorspace::Component> colorspace::getColorSpaceInfo( Inkscape::ColorProfile *prof ) | 214 | std::vector<colorspace::Component> colorspace::getColorSpaceInfo(Inkscape::ColorProfile *prof) |
2754 | 371 | { | 215 | { |
2755 | 372 | return getColorSpaceInfo( asICColorSpaceSig(prof->getColorSpace()) ); | 216 | return getColorSpaceInfo(asICColorSpaceSig(prof->getColorSpace())); |
2756 | 373 | } | 217 | } |
2757 | 374 | 218 | ||
2758 | 375 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 219 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2759 | 376 | 220 | ||
2760 | 377 | ColorICCSelectorImpl::ColorICCSelectorImpl(ColorICCSelector *owner) : | 221 | namespace Inkscape { |
2761 | 378 | _owner(owner), | 222 | namespace UI { |
2762 | 379 | _updating( FALSE ), | 223 | namespace Widget { |
2763 | 380 | _dragging( FALSE ), | 224 | |
2764 | 381 | _fixupNeeded(0), | 225 | /** |
2765 | 382 | _fixupBtn(0), | 226 | * Class containing the parts for a single color component's UI presence. |
2766 | 383 | _profileSel(0), | 227 | */ |
2767 | 384 | _compUI(), | 228 | class ComponentUI { |
2768 | 385 | _adj(0), | 229 | public: |
2769 | 386 | _slider(0), | 230 | ComponentUI() |
2770 | 387 | _sbtn(0), | 231 | : _component() |
2771 | 388 | _label(0) | 232 | , _adj(0) |
2772 | 389 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 233 | , _slider(0) |
2773 | 390 | , | 234 | , _btn(0) |
2774 | 391 | _profileName(), | 235 | , _label(0) |
2775 | 392 | _prof(0), | 236 | , _map(0) |
2776 | 393 | _profChannelCount(0), | 237 | { |
2777 | 394 | _profChangedID(0) | 238 | } |
2778 | 239 | |||
2779 | 240 | ComponentUI(colorspace::Component const &component) | ||
2780 | 241 | : _component(component) | ||
2781 | 242 | , _adj(0) | ||
2782 | 243 | , _slider(0) | ||
2783 | 244 | , _btn(0) | ||
2784 | 245 | , _label(0) | ||
2785 | 246 | , _map(0) | ||
2786 | 247 | { | ||
2787 | 248 | } | ||
2788 | 249 | |||
2789 | 250 | colorspace::Component _component; | ||
2790 | 251 | GtkAdjustment *_adj; // Component adjustment | ||
2791 | 252 | Inkscape::UI::Widget::ColorSlider *_slider; | ||
2792 | 253 | GtkWidget *_btn; // spinbutton | ||
2793 | 254 | GtkWidget *_label; // Label | ||
2794 | 255 | guchar *_map; | ||
2795 | 256 | }; | ||
2796 | 257 | |||
2797 | 258 | /** | ||
2798 | 259 | * Class that implements the internals of the selector. | ||
2799 | 260 | */ | ||
2800 | 261 | class ColorICCSelectorImpl { | ||
2801 | 262 | public: | ||
2802 | 263 | ColorICCSelectorImpl(ColorICCSelector *owner, SelectedColor &color); | ||
2803 | 264 | |||
2804 | 265 | ~ColorICCSelectorImpl(); | ||
2805 | 266 | |||
2806 | 267 | static void _adjustmentChanged(GtkAdjustment *adjustment, ColorICCSelectorImpl *cs); | ||
2807 | 268 | |||
2808 | 269 | void _sliderGrabbed(); | ||
2809 | 270 | void _sliderReleased(); | ||
2810 | 271 | void _sliderChanged(); | ||
2811 | 272 | |||
2812 | 273 | static void _profileSelected(GtkWidget *src, gpointer data); | ||
2813 | 274 | static void _fixupHit(GtkWidget *src, gpointer data); | ||
2814 | 275 | |||
2815 | 276 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
2816 | 277 | void _setProfile(SVGICCColor *profile); | ||
2817 | 278 | void _switchToProfile(gchar const *name); | ||
2818 | 279 | #endif | ||
2819 | 280 | void _updateSliders(gint ignore); | ||
2820 | 281 | void _profilesChanged(std::string const &name); | ||
2821 | 282 | |||
2822 | 283 | ColorICCSelector *_owner; | ||
2823 | 284 | SelectedColor &_color; | ||
2824 | 285 | |||
2825 | 286 | gboolean _updating : 1; | ||
2826 | 287 | gboolean _dragging : 1; | ||
2827 | 288 | |||
2828 | 289 | guint32 _fixupNeeded; | ||
2829 | 290 | GtkWidget *_fixupBtn; | ||
2830 | 291 | GtkWidget *_profileSel; | ||
2831 | 292 | |||
2832 | 293 | std::vector<ComponentUI> _compUI; | ||
2833 | 294 | |||
2834 | 295 | GtkAdjustment *_adj; // Channel adjustment | ||
2835 | 296 | Inkscape::UI::Widget::ColorSlider *_slider; | ||
2836 | 297 | GtkWidget *_sbtn; // Spinbutton | ||
2837 | 298 | GtkWidget *_label; // Label | ||
2838 | 299 | |||
2839 | 300 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
2840 | 301 | std::string _profileName; | ||
2841 | 302 | Inkscape::ColorProfile *_prof; | ||
2842 | 303 | guint _profChannelCount; | ||
2843 | 304 | gulong _profChangedID; | ||
2844 | 305 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
2845 | 306 | }; | ||
2846 | 307 | |||
2847 | 308 | |||
2848 | 309 | |||
2849 | 310 | const gchar *ColorICCSelector::MODE_NAME = N_("CMS"); | ||
2850 | 311 | |||
2851 | 312 | ColorICCSelector::ColorICCSelector(SelectedColor &color) | ||
2852 | 313 | : _impl(NULL) | ||
2853 | 314 | { | ||
2854 | 315 | _impl = new ColorICCSelectorImpl(this, color); | ||
2855 | 316 | init(); | ||
2856 | 317 | color.signal_changed.connect(sigc::mem_fun(this, &ColorICCSelector::_colorChanged)); | ||
2857 | 318 | // color.signal_dragged.connect(sigc::mem_fun(this, &ColorICCSelector::_colorChanged)); | ||
2858 | 319 | } | ||
2859 | 320 | |||
2860 | 321 | ColorICCSelector::~ColorICCSelector() | ||
2861 | 322 | { | ||
2862 | 323 | if (_impl) { | ||
2863 | 324 | delete _impl; | ||
2864 | 325 | _impl = 0; | ||
2865 | 326 | } | ||
2866 | 327 | } | ||
2867 | 328 | |||
2868 | 329 | |||
2869 | 330 | |||
2870 | 331 | ColorICCSelectorImpl::ColorICCSelectorImpl(ColorICCSelector *owner, SelectedColor &color) | ||
2871 | 332 | : _owner(owner) | ||
2872 | 333 | , _color(color) | ||
2873 | 334 | , _updating(FALSE) | ||
2874 | 335 | , _dragging(FALSE) | ||
2875 | 336 | , _fixupNeeded(0) | ||
2876 | 337 | , _fixupBtn(0) | ||
2877 | 338 | , _profileSel(0) | ||
2878 | 339 | , _compUI() | ||
2879 | 340 | , _adj(0) | ||
2880 | 341 | , _slider(0) | ||
2881 | 342 | , _sbtn(0) | ||
2882 | 343 | , _label(0) | ||
2883 | 344 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
2884 | 345 | , _profileName() | ||
2885 | 346 | , _prof(0) | ||
2886 | 347 | , _profChannelCount(0) | ||
2887 | 348 | , _profChangedID(0) | ||
2888 | 395 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 349 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2889 | 396 | { | 350 | { |
2890 | 397 | } | 351 | } |
2891 | @@ -405,21 +359,12 @@ | |||
2892 | 405 | 359 | ||
2893 | 406 | void ColorICCSelector::init() | 360 | void ColorICCSelector::init() |
2894 | 407 | { | 361 | { |
2895 | 408 | if (_impl) delete(_impl); | ||
2896 | 409 | _impl = new ColorICCSelectorImpl(this); | ||
2897 | 410 | gint row = 0; | 362 | gint row = 0; |
2898 | 411 | 363 | ||
2899 | 412 | _impl->_updating = FALSE; | 364 | _impl->_updating = FALSE; |
2900 | 413 | _impl->_dragging = FALSE; | 365 | _impl->_dragging = FALSE; |
2901 | 414 | 366 | ||
2910 | 415 | #if GTK_CHECK_VERSION(3,0,0) | 367 | GtkWidget *t = GTK_WIDGET(gobj()); |
2903 | 416 | GtkWidget *t = gtk_grid_new(); | ||
2904 | 417 | #else | ||
2905 | 418 | GtkWidget *t = gtk_table_new(5, 3, FALSE); | ||
2906 | 419 | #endif | ||
2907 | 420 | |||
2908 | 421 | gtk_widget_show (t); | ||
2909 | 422 | gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4); | ||
2911 | 423 | 368 | ||
2912 | 424 | _impl->_compUI.clear(); | 369 | _impl->_compUI.clear(); |
2913 | 425 | 370 | ||
2914 | @@ -428,50 +373,53 @@ | |||
2915 | 428 | 373 | ||
2916 | 429 | 374 | ||
2917 | 430 | _impl->_fixupBtn = gtk_button_new_with_label(_("Fix")); | 375 | _impl->_fixupBtn = gtk_button_new_with_label(_("Fix")); |
2923 | 431 | g_signal_connect( G_OBJECT(_impl->_fixupBtn), "clicked", G_CALLBACK(ColorICCSelectorImpl::_fixupHit), (gpointer)_impl ); | 376 | g_signal_connect(G_OBJECT(_impl->_fixupBtn), "clicked", G_CALLBACK(ColorICCSelectorImpl::_fixupHit), |
2924 | 432 | gtk_widget_set_sensitive( _impl->_fixupBtn, FALSE ); | 377 | (gpointer)_impl); |
2925 | 433 | gtk_widget_set_tooltip_text( _impl->_fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); | 378 | gtk_widget_set_sensitive(_impl->_fixupBtn, FALSE); |
2926 | 434 | //gtk_misc_set_alignment( GTK_MISC (_impl->_fixupBtn), 1.0, 0.5 ); | 379 | gtk_widget_set_tooltip_text(_impl->_fixupBtn, _("Fix RGB fallback to match icc-color() value.")); |
2927 | 435 | gtk_widget_show( _impl->_fixupBtn ); | 380 | // gtk_misc_set_alignment( GTK_MISC (_impl->_fixupBtn), 1.0, 0.5 ); |
2928 | 381 | gtk_widget_show(_impl->_fixupBtn); | ||
2929 | 436 | 382 | ||
2930 | 437 | attachToGridOrTable(t, _impl->_fixupBtn, 0, row, 1, 1); | 383 | attachToGridOrTable(t, _impl->_fixupBtn, 0, row, 1, 1); |
2931 | 438 | 384 | ||
2932 | 439 | // Combobox and store with 2 columns : label (0) and full name (1) | 385 | // Combobox and store with 2 columns : label (0) and full name (1) |
2935 | 440 | GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); | 386 | GtkListStore *store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); |
2936 | 441 | _impl->_profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); | 387 | _impl->_profileSel = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); |
2937 | 442 | 388 | ||
2939 | 443 | GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); | 389 | GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); |
2940 | 444 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, TRUE); | 390 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, TRUE); |
2941 | 445 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, "text", 0, NULL); | 391 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, "text", 0, NULL); |
2942 | 446 | 392 | ||
2943 | 447 | GtkTreeIter iter; | 393 | GtkTreeIter iter; |
2946 | 448 | gtk_list_store_append (store, &iter); | 394 | gtk_list_store_append(store, &iter); |
2947 | 449 | gtk_list_store_set (store, &iter, 0, _("<none>"), 1, _("<none>"), -1); | 395 | gtk_list_store_set(store, &iter, 0, _("<none>"), 1, _("<none>"), -1); |
2948 | 450 | 396 | ||
2951 | 451 | gtk_widget_show( _impl->_profileSel ); | 397 | gtk_widget_show(_impl->_profileSel); |
2952 | 452 | gtk_combo_box_set_active( GTK_COMBO_BOX(_impl->_profileSel), 0 ); | 398 | gtk_combo_box_set_active(GTK_COMBO_BOX(_impl->_profileSel), 0); |
2953 | 453 | 399 | ||
2954 | 454 | attachToGridOrTable(t, _impl->_profileSel, 1, row, 1, 1); | 400 | attachToGridOrTable(t, _impl->_profileSel, 1, row, 1, 1); |
2955 | 455 | 401 | ||
2956 | 456 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 402 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2958 | 457 | _impl->_profChangedID = g_signal_connect( G_OBJECT(_impl->_profileSel), "changed", G_CALLBACK(ColorICCSelectorImpl::_profileSelected), (gpointer)_impl ); | 403 | _impl->_profChangedID = g_signal_connect(G_OBJECT(_impl->_profileSel), "changed", |
2959 | 404 | G_CALLBACK(ColorICCSelectorImpl::_profileSelected), (gpointer)_impl); | ||
2960 | 458 | #else | 405 | #else |
2962 | 459 | gtk_widget_set_sensitive( _impl->_profileSel, false ); | 406 | gtk_widget_set_sensitive(_impl->_profileSel, false); |
2963 | 460 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 407 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2964 | 461 | 408 | ||
2965 | 462 | 409 | ||
2966 | 463 | row++; | 410 | row++; |
2967 | 464 | 411 | ||
2969 | 465 | // populate the data for colorspaces and channels: | 412 | // populate the data for colorspaces and channels: |
2970 | 466 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 413 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2972 | 467 | std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo( cmsSigRgbData ); | 414 | std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo(cmsSigRgbData); |
2973 | 468 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 415 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2974 | 469 | 416 | ||
2976 | 470 | for ( size_t i = 0; i < maxColorspaceComponentCount; i++ ) { | 417 | for (size_t i = 0; i < maxColorspaceComponentCount; i++) { |
2977 | 471 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 418 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2978 | 472 | if (i < things.size()) { | 419 | if (i < things.size()) { |
2979 | 473 | _impl->_compUI.push_back(ComponentUI(things[i])); | 420 | _impl->_compUI.push_back(ComponentUI(things[i])); |
2981 | 474 | } else { | 421 | } |
2982 | 422 | else { | ||
2983 | 475 | _impl->_compUI.push_back(ComponentUI()); | 423 | _impl->_compUI.push_back(ComponentUI()); |
2984 | 476 | } | 424 | } |
2985 | 477 | 425 | ||
2986 | @@ -482,9 +430,10 @@ | |||
2987 | 482 | std::string labelStr = "."; | 430 | std::string labelStr = "."; |
2988 | 483 | #endif | 431 | #endif |
2989 | 484 | 432 | ||
2993 | 485 | _impl->_compUI[i]._label = gtk_label_new_with_mnemonic( labelStr.c_str() ); | 433 | _impl->_compUI[i]._label = gtk_label_new_with_mnemonic(labelStr.c_str()); |
2994 | 486 | gtk_misc_set_alignment( GTK_MISC (_impl->_compUI[i]._label), 1.0, 0.5 ); | 434 | gtk_misc_set_alignment(GTK_MISC(_impl->_compUI[i]._label), 1.0, 0.5); |
2995 | 487 | gtk_widget_show( _impl->_compUI[i]._label ); | 435 | gtk_widget_show(_impl->_compUI[i]._label); |
2996 | 436 | gtk_widget_set_no_show_all(_impl->_compUI[i]._label, TRUE); | ||
2997 | 488 | 437 | ||
2998 | 489 | attachToGridOrTable(t, _impl->_compUI[i]._label, 0, row, 1, 1); | 438 | attachToGridOrTable(t, _impl->_compUI[i]._label, 0, row, 1, 1); |
2999 | 490 | 439 | ||
3000 | @@ -493,41 +442,47 @@ | |||
3001 | 493 | gdouble step = static_cast<gdouble>(scaleValue) / 100.0; | 442 | gdouble step = static_cast<gdouble>(scaleValue) / 100.0; |
3002 | 494 | gdouble page = static_cast<gdouble>(scaleValue) / 10.0; | 443 | gdouble page = static_cast<gdouble>(scaleValue) / 10.0; |
3003 | 495 | gint digits = (step > 0.9) ? 0 : 2; | 444 | gint digits = (step > 0.9) ? 0 : 2; |
3005 | 496 | _impl->_compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, scaleValue, step, page, page ) ); | 445 | _impl->_compUI[i]._adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, scaleValue, step, page, page)); |
3006 | 497 | 446 | ||
3007 | 498 | // Slider | 447 | // Slider |
3027 | 499 | _impl->_compUI[i]._slider = sp_color_slider_new( _impl->_compUI[i]._adj ); | 448 | _impl->_compUI[i]._slider = |
3028 | 500 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 449 | Gtk::manage(new Inkscape::UI::Widget::ColorSlider(Glib::wrap(_impl->_compUI[i]._adj, true))); |
3029 | 501 | gtk_widget_set_tooltip_text( _impl->_compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" ); | 450 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3030 | 502 | #else | 451 | _impl->_compUI[i]._slider->set_tooltip_text((i < things.size()) ? things[i].tip.c_str() : ""); |
3031 | 503 | gtk_widget_set_tooltip_text( _impl->_compUI[i]._slider, "." ); | 452 | #else |
3032 | 504 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 453 | _impl->_compUI[i]._slider->set_tooltip_text("."); |
3033 | 505 | gtk_widget_show( _impl->_compUI[i]._slider ); | 454 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3034 | 506 | 455 | _impl->_compUI[i]._slider->show(); | |
3035 | 507 | attachToGridOrTable(t, _impl->_compUI[i]._slider, 1, row, 1, 1, true); | 456 | _impl->_compUI[i]._slider->set_no_show_all(); |
3036 | 508 | 457 | ||
3037 | 509 | _impl->_compUI[i]._btn = gtk_spin_button_new( _impl->_compUI[i]._adj, step, digits ); | 458 | attachToGridOrTable(t, _impl->_compUI[i]._slider->gobj(), 1, row, 1, 1, true); |
3038 | 510 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 459 | |
3039 | 511 | gtk_widget_set_tooltip_text( _impl->_compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : "" ); | 460 | _impl->_compUI[i]._btn = gtk_spin_button_new(_impl->_compUI[i]._adj, step, digits); |
3040 | 512 | #else | 461 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3041 | 513 | gtk_widget_set_tooltip_text( _impl->_compUI[i]._btn, "." ); | 462 | gtk_widget_set_tooltip_text(_impl->_compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : ""); |
3042 | 514 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 463 | #else |
3043 | 515 | sp_dialog_defocus_on_enter( _impl->_compUI[i]._btn ); | 464 | gtk_widget_set_tooltip_text(_impl->_compUI[i]._btn, "."); |
3044 | 516 | gtk_label_set_mnemonic_widget( GTK_LABEL(_impl->_compUI[i]._label), _impl->_compUI[i]._btn ); | 465 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3045 | 517 | gtk_widget_show( _impl->_compUI[i]._btn ); | 466 | sp_dialog_defocus_on_enter(_impl->_compUI[i]._btn); |
3046 | 467 | gtk_label_set_mnemonic_widget(GTK_LABEL(_impl->_compUI[i]._label), _impl->_compUI[i]._btn); | ||
3047 | 468 | gtk_widget_show(_impl->_compUI[i]._btn); | ||
3048 | 469 | gtk_widget_set_no_show_all(_impl->_compUI[i]._btn, TRUE); | ||
3049 | 518 | 470 | ||
3050 | 519 | attachToGridOrTable(t, _impl->_compUI[i]._btn, 2, row, 1, 1, false, true); | 471 | attachToGridOrTable(t, _impl->_compUI[i]._btn, 2, row, 1, 1, false, true); |
3051 | 520 | 472 | ||
3054 | 521 | _impl->_compUI[i]._map = g_new( guchar, 4 * 1024 ); | 473 | _impl->_compUI[i]._map = g_new(guchar, 4 * 1024); |
3055 | 522 | memset( _impl->_compUI[i]._map, 0x0ff, 1024 * 4 ); | 474 | memset(_impl->_compUI[i]._map, 0x0ff, 1024 * 4); |
3056 | 523 | 475 | ||
3057 | 524 | 476 | ||
3058 | 525 | // Signals | 477 | // Signals |
3060 | 526 | g_signal_connect( G_OBJECT( _impl->_compUI[i]._adj ), "value_changed", G_CALLBACK( ColorICCSelectorImpl::_adjustmentChanged ), _csel ); | 478 | g_signal_connect(G_OBJECT(_impl->_compUI[i]._adj), "value_changed", |
3061 | 479 | G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged), _impl); | ||
3062 | 527 | 480 | ||
3066 | 528 | g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "grabbed", G_CALLBACK( ColorICCSelectorImpl::_sliderGrabbed ), _csel ); | 481 | _impl->_compUI[i]._slider->signal_grabbed.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderGrabbed)); |
3067 | 529 | g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "released", G_CALLBACK( ColorICCSelectorImpl::_sliderReleased ), _csel ); | 482 | _impl->_compUI[i]._slider->signal_released.connect( |
3068 | 530 | g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "changed", G_CALLBACK( ColorICCSelectorImpl::_sliderChanged ), _csel ); | 483 | sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderReleased)); |
3069 | 484 | _impl->_compUI[i]._slider->signal_value_changed.connect( | ||
3070 | 485 | sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderChanged)); | ||
3071 | 531 | 486 | ||
3072 | 532 | row++; | 487 | row++; |
3073 | 533 | } | 488 | } |
3074 | @@ -543,16 +498,14 @@ | |||
3075 | 543 | _impl->_adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 255.0, 1.0, 10.0, 10.0)); | 498 | _impl->_adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 255.0, 1.0, 10.0, 10.0)); |
3076 | 544 | 499 | ||
3077 | 545 | // Slider | 500 | // Slider |
3088 | 546 | _impl->_slider = sp_color_slider_new(_impl->_adj); | 501 | _impl->_slider = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(Glib::wrap(_impl->_adj, true))); |
3089 | 547 | gtk_widget_set_tooltip_text(_impl->_slider, _("Alpha (opacity)")); | 502 | _impl->_slider->set_tooltip_text(_("Alpha (opacity)")); |
3090 | 548 | gtk_widget_show(_impl->_slider); | 503 | _impl->_slider->show(); |
3091 | 549 | 504 | ||
3092 | 550 | attachToGridOrTable(t, _impl->_slider, 1, row, 1, 1, true); | 505 | attachToGridOrTable(t, _impl->_slider->gobj(), 1, row, 1, 1, true); |
3093 | 551 | 506 | ||
3094 | 552 | sp_color_slider_set_colors( SP_COLOR_SLIDER( _impl->_slider ), | 507 | _impl->_slider->setColors(SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.0), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.5), |
3095 | 553 | SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ), | 508 | SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 1.0)); |
3086 | 554 | SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.5 ), | ||
3087 | 555 | SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 1.0 ) ); | ||
3096 | 556 | 509 | ||
3097 | 557 | 510 | ||
3098 | 558 | // Spinbutton | 511 | // Spinbutton |
3099 | @@ -565,96 +518,72 @@ | |||
3100 | 565 | attachToGridOrTable(t, _impl->_sbtn, 2, row, 1, 1, false, true); | 518 | attachToGridOrTable(t, _impl->_sbtn, 2, row, 1, 1, false, true); |
3101 | 566 | 519 | ||
3102 | 567 | // Signals | 520 | // Signals |
3144 | 568 | g_signal_connect(G_OBJECT(_impl->_adj), "value_changed", G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged), _csel); | 521 | g_signal_connect(G_OBJECT(_impl->_adj), "value_changed", G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged), |
3145 | 569 | 522 | _impl); | |
3146 | 570 | g_signal_connect(G_OBJECT(_impl->_slider), "grabbed", G_CALLBACK(ColorICCSelectorImpl::_sliderGrabbed), _csel); | 523 | |
3147 | 571 | g_signal_connect(G_OBJECT(_impl->_slider), "released", G_CALLBACK(ColorICCSelectorImpl::_sliderReleased), _csel); | 524 | _impl->_slider->signal_grabbed.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderGrabbed)); |
3148 | 572 | g_signal_connect(G_OBJECT(_impl->_slider), "changed", G_CALLBACK(ColorICCSelectorImpl::_sliderChanged), _csel); | 525 | _impl->_slider->signal_released.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderReleased)); |
3149 | 573 | } | 526 | _impl->_slider->signal_value_changed.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderChanged)); |
3150 | 574 | 527 | ||
3151 | 575 | static void sp_color_icc_selector_dispose(GObject *object) | 528 | gtk_widget_show(t); |
3152 | 576 | { | 529 | } |
3153 | 577 | if (G_OBJECT_CLASS(sp_color_icc_selector_parent_class)->dispose) { | 530 | |
3154 | 578 | G_OBJECT_CLASS(sp_color_icc_selector_parent_class)->dispose(object); | 531 | void ColorICCSelectorImpl::_fixupHit(GtkWidget * /*src*/, gpointer data) |
3155 | 579 | } | 532 | { |
3156 | 580 | } | 533 | ColorICCSelectorImpl *self = reinterpret_cast<ColorICCSelectorImpl *>(data); |
3157 | 581 | 534 | gtk_widget_set_sensitive(self->_fixupBtn, FALSE); | |
3158 | 582 | static void | 535 | self->_adjustmentChanged(self->_compUI[0]._adj, self); |
3118 | 583 | sp_color_icc_selector_show_all (GtkWidget *widget) | ||
3119 | 584 | { | ||
3120 | 585 | gtk_widget_show (widget); | ||
3121 | 586 | } | ||
3122 | 587 | |||
3123 | 588 | static void sp_color_icc_selector_hide(GtkWidget *widget) | ||
3124 | 589 | { | ||
3125 | 590 | gtk_widget_hide(widget); | ||
3126 | 591 | } | ||
3127 | 592 | |||
3128 | 593 | GtkWidget * | ||
3129 | 594 | sp_color_icc_selector_new (void) | ||
3130 | 595 | { | ||
3131 | 596 | SPColorICCSelector *csel; | ||
3132 | 597 | |||
3133 | 598 | csel = static_cast<SPColorICCSelector*>(g_object_new (SP_TYPE_COLOR_ICC_SELECTOR, NULL)); | ||
3134 | 599 | |||
3135 | 600 | return GTK_WIDGET (csel); | ||
3136 | 601 | } | ||
3137 | 602 | |||
3138 | 603 | |||
3139 | 604 | void ColorICCSelectorImpl::_fixupHit( GtkWidget* /*src*/, gpointer data ) | ||
3140 | 605 | { | ||
3141 | 606 | ColorICCSelectorImpl* self = reinterpret_cast<ColorICCSelectorImpl*>(data); | ||
3142 | 607 | gtk_widget_set_sensitive( self->_fixupBtn, FALSE ); | ||
3143 | 608 | self->_adjustmentChanged( self->_compUI[0]._adj, SP_COLOR_ICC_SELECTOR(self->_owner->_csel) ); | ||
3159 | 609 | } | 536 | } |
3160 | 610 | 537 | ||
3161 | 611 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 538 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3163 | 612 | void ColorICCSelectorImpl::_profileSelected( GtkWidget* /*src*/, gpointer data ) | 539 | void ColorICCSelectorImpl::_profileSelected(GtkWidget * /*src*/, gpointer data) |
3164 | 613 | { | 540 | { |
3166 | 614 | ColorICCSelectorImpl* self = reinterpret_cast<ColorICCSelectorImpl*>(data); | 541 | ColorICCSelectorImpl *self = reinterpret_cast<ColorICCSelectorImpl *>(data); |
3167 | 615 | 542 | ||
3169 | 616 | GtkTreeIter iter; | 543 | GtkTreeIter iter; |
3170 | 617 | if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->_profileSel), &iter)) { | 544 | if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->_profileSel), &iter)) { |
3171 | 618 | GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(self->_profileSel)); | 545 | GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(self->_profileSel)); |
3173 | 619 | gchar* name = 0; | 546 | gchar *name = 0; |
3174 | 620 | 547 | ||
3175 | 621 | gtk_tree_model_get(store, &iter, 1, &name, -1); | 548 | gtk_tree_model_get(store, &iter, 1, &name, -1); |
3178 | 622 | self->_switchToProfile( name ); | 549 | self->_switchToProfile(name); |
3179 | 623 | gtk_widget_set_tooltip_text(self->_profileSel, name ); | 550 | gtk_widget_set_tooltip_text(self->_profileSel, name); |
3180 | 624 | 551 | ||
3183 | 625 | if ( name ) { | 552 | if (name) { |
3184 | 626 | g_free( name ); | 553 | g_free(name); |
3185 | 627 | } | 554 | } |
3186 | 628 | } | 555 | } |
3187 | 629 | } | 556 | } |
3188 | 630 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 557 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3189 | 631 | 558 | ||
3190 | 632 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 559 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3192 | 633 | void ColorICCSelectorImpl::_switchToProfile( gchar const* name ) | 560 | void ColorICCSelectorImpl::_switchToProfile(gchar const *name) |
3193 | 634 | { | 561 | { |
3194 | 635 | bool dirty = false; | 562 | bool dirty = false; |
3196 | 636 | SPColor tmp( _owner->_color ); | 563 | SPColor tmp(_color.color()); |
3197 | 637 | 564 | ||
3208 | 638 | if ( name ) { | 565 | if (name) { |
3209 | 639 | if ( tmp.icc && tmp.icc->colorProfile == name ) { | 566 | if (tmp.icc && tmp.icc->colorProfile == name) { |
3210 | 640 | #ifdef DEBUG_LCMS | 567 | #ifdef DEBUG_LCMS |
3211 | 641 | g_message("Already at name [%s]", name ); | 568 | g_message("Already at name [%s]", name); |
3212 | 642 | #endif // DEBUG_LCMS | 569 | #endif // DEBUG_LCMS |
3213 | 643 | } else { | 570 | } |
3214 | 644 | #ifdef DEBUG_LCMS | 571 | else { |
3215 | 645 | g_message("Need to switch to profile [%s]", name ); | 572 | #ifdef DEBUG_LCMS |
3216 | 646 | #endif // DEBUG_LCMS | 573 | g_message("Need to switch to profile [%s]", name); |
3217 | 647 | if ( tmp.icc ) { | 574 | #endif // DEBUG_LCMS |
3218 | 575 | if (tmp.icc) { | ||
3219 | 648 | tmp.icc->colors.clear(); | 576 | tmp.icc->colors.clear(); |
3221 | 649 | } else { | 577 | } |
3222 | 578 | else { | ||
3223 | 650 | tmp.icc = new SVGICCColor(); | 579 | tmp.icc = new SVGICCColor(); |
3224 | 651 | } | 580 | } |
3225 | 652 | tmp.icc->colorProfile = name; | 581 | tmp.icc->colorProfile = name; |
3228 | 653 | Inkscape::ColorProfile* newProf = SP_ACTIVE_DOCUMENT->profileManager->find(name); | 582 | Inkscape::ColorProfile *newProf = SP_ACTIVE_DOCUMENT->profileManager->find(name); |
3229 | 654 | if ( newProf ) { | 583 | if (newProf) { |
3230 | 655 | cmsHTRANSFORM trans = newProf->getTransfFromSRGB8(); | 584 | cmsHTRANSFORM trans = newProf->getTransfFromSRGB8(); |
3233 | 656 | if ( trans ) { | 585 | if (trans) { |
3234 | 657 | guint32 val = _owner->_color.toRGBA32(0); | 586 | guint32 val = _color.color().toRGBA32(0); |
3235 | 658 | guchar pre[4] = { | 587 | guchar pre[4] = { |
3236 | 659 | static_cast<guchar>(SP_RGBA32_R_U(val)), | 588 | static_cast<guchar>(SP_RGBA32_R_U(val)), |
3237 | 660 | static_cast<guchar>(SP_RGBA32_G_U(val)), | 589 | static_cast<guchar>(SP_RGBA32_G_U(val)), |
3238 | @@ -663,29 +592,31 @@ | |||
3239 | 663 | #ifdef DEBUG_LCMS | 592 | #ifdef DEBUG_LCMS |
3240 | 664 | g_message("Shoving in [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]); | 593 | g_message("Shoving in [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]); |
3241 | 665 | #endif // DEBUG_LCMS | 594 | #endif // DEBUG_LCMS |
3244 | 666 | cmsUInt16Number post[4] = {0,0,0,0}; | 595 | cmsUInt16Number post[4] = { 0, 0, 0, 0 }; |
3245 | 667 | cmsDoTransform( trans, pre, post, 1 ); | 596 | cmsDoTransform(trans, pre, post, 1); |
3246 | 668 | #ifdef DEBUG_LCMS | 597 | #ifdef DEBUG_LCMS |
3247 | 669 | g_message("got on out [%04x] [%04x] [%04x] [%04x]", post[0], post[1], post[2], post[3]); | 598 | g_message("got on out [%04x] [%04x] [%04x] [%04x]", post[0], post[1], post[2], post[3]); |
3248 | 670 | #endif // DEBUG_LCMS | 599 | #endif // DEBUG_LCMS |
3249 | 671 | #if HAVE_LIBLCMS1 | 600 | #if HAVE_LIBLCMS1 |
3251 | 672 | guint count = _cmsChannelsOf( asICColorSpaceSig(newProf->getColorSpace()) ); | 601 | guint count = _cmsChannelsOf(asICColorSpaceSig(newProf->getColorSpace())); |
3252 | 673 | #elif HAVE_LIBLCMS2 | 602 | #elif HAVE_LIBLCMS2 |
3254 | 674 | guint count = cmsChannelsOf( asICColorSpaceSig(newProf->getColorSpace()) ); | 603 | guint count = cmsChannelsOf(asICColorSpaceSig(newProf->getColorSpace())); |
3255 | 675 | #endif | 604 | #endif |
3256 | 676 | 605 | ||
3258 | 677 | std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo(asICColorSpaceSig(newProf->getColorSpace())); | 606 | std::vector<colorspace::Component> things = |
3259 | 607 | colorspace::getColorSpaceInfo(asICColorSpaceSig(newProf->getColorSpace())); | ||
3260 | 678 | 608 | ||
3263 | 679 | for ( guint i = 0; i < count; i++ ) { | 609 | for (guint i = 0; i < count; i++) { |
3264 | 680 | gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)((i < things.size()) ? things[i].scale : 1); | 610 | gdouble val = |
3265 | 611 | (((gdouble)post[i]) / 65535.0) * (gdouble)((i < things.size()) ? things[i].scale : 1); | ||
3266 | 681 | #ifdef DEBUG_LCMS | 612 | #ifdef DEBUG_LCMS |
3267 | 682 | g_message(" scaled %d by %d to be %f", i, ((i < things.size()) ? things[i].scale : 1), val); | 613 | g_message(" scaled %d by %d to be %f", i, ((i < things.size()) ? things[i].scale : 1), val); |
3268 | 683 | #endif // DEBUG_LCMS | 614 | #endif // DEBUG_LCMS |
3269 | 684 | tmp.icc->colors.push_back(val); | 615 | tmp.icc->colors.push_back(val); |
3270 | 685 | } | 616 | } |
3271 | 686 | cmsHTRANSFORM retrans = newProf->getTransfToSRGB8(); | 617 | cmsHTRANSFORM retrans = newProf->getTransfToSRGB8(); |
3274 | 687 | if ( retrans ) { | 618 | if (retrans) { |
3275 | 688 | cmsDoTransform( retrans, post, pre, 1 ); | 619 | cmsDoTransform(retrans, post, pre, 1); |
3276 | 689 | #ifdef DEBUG_LCMS | 620 | #ifdef DEBUG_LCMS |
3277 | 690 | g_message(" back out [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]); | 621 | g_message(" back out [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]); |
3278 | 691 | #endif // DEBUG_LCMS | 622 | #endif // DEBUG_LCMS |
3279 | @@ -695,30 +626,32 @@ | |||
3280 | 695 | } | 626 | } |
3281 | 696 | dirty = true; | 627 | dirty = true; |
3282 | 697 | } | 628 | } |
3284 | 698 | } else { | 629 | } |
3285 | 630 | else { | ||
3286 | 699 | #ifdef DEBUG_LCMS | 631 | #ifdef DEBUG_LCMS |
3288 | 700 | g_message("NUKE THE ICC"); | 632 | g_message("NUKE THE ICC"); |
3289 | 701 | #endif // DEBUG_LCMS | 633 | #endif // DEBUG_LCMS |
3291 | 702 | if ( tmp.icc ) { | 634 | if (tmp.icc) { |
3292 | 703 | delete tmp.icc; | 635 | delete tmp.icc; |
3293 | 704 | tmp.icc = 0; | 636 | tmp.icc = 0; |
3294 | 705 | dirty = true; | 637 | dirty = true; |
3297 | 706 | _fixupHit( 0, this ); | 638 | _fixupHit(0, this); |
3298 | 707 | } else { | 639 | } |
3299 | 640 | else { | ||
3300 | 708 | #ifdef DEBUG_LCMS | 641 | #ifdef DEBUG_LCMS |
3302 | 709 | g_message("No icc to nuke"); | 642 | g_message("No icc to nuke"); |
3303 | 710 | #endif // DEBUG_LCMS | 643 | #endif // DEBUG_LCMS |
3304 | 711 | } | 644 | } |
3305 | 712 | } | 645 | } |
3306 | 713 | 646 | ||
3308 | 714 | if ( dirty ) { | 647 | if (dirty) { |
3309 | 715 | #ifdef DEBUG_LCMS | 648 | #ifdef DEBUG_LCMS |
3310 | 716 | g_message("+----------------"); | 649 | g_message("+----------------"); |
3311 | 717 | g_message("+ new color is [%s]", tmp.toString().c_str()); | 650 | g_message("+ new color is [%s]", tmp.toString().c_str()); |
3312 | 718 | #endif // DEBUG_LCMS | 651 | #endif // DEBUG_LCMS |
3314 | 719 | _setProfile( tmp.icc ); | 652 | _setProfile(tmp.icc); |
3315 | 720 | //_adjustmentChanged( _compUI[0]._adj, SP_COLOR_ICC_SELECTOR(_csel) ); | 653 | //_adjustmentChanged( _compUI[0]._adj, SP_COLOR_ICC_SELECTOR(_csel) ); |
3317 | 721 | _owner->setColorAlpha( tmp, _owner->_alpha, true ); | 654 | _color.setColor(tmp); |
3318 | 722 | #ifdef DEBUG_LCMS | 655 | #ifdef DEBUG_LCMS |
3319 | 723 | g_message("+_________________"); | 656 | g_message("+_________________"); |
3320 | 724 | #endif // DEBUG_LCMS | 657 | #endif // DEBUG_LCMS |
3321 | @@ -727,238 +660,257 @@ | |||
3322 | 727 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 660 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3323 | 728 | 661 | ||
3324 | 729 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 662 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3326 | 730 | void ColorICCSelectorImpl::_profilesChanged( std::string const & name ) | 663 | void ColorICCSelectorImpl::_profilesChanged(std::string const &name) |
3327 | 731 | { | 664 | { |
3329 | 732 | GtkComboBox* combo = GTK_COMBO_BOX(_profileSel); | 665 | GtkComboBox *combo = GTK_COMBO_BOX(_profileSel); |
3330 | 733 | 666 | ||
3332 | 734 | g_signal_handler_block( G_OBJECT(_profileSel), _profChangedID ); | 667 | g_signal_handler_block(G_OBJECT(_profileSel), _profChangedID); |
3333 | 735 | 668 | ||
3334 | 736 | GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(combo)); | 669 | GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(combo)); |
3335 | 737 | gtk_list_store_clear(store); | 670 | gtk_list_store_clear(store); |
3336 | 738 | 671 | ||
3337 | 739 | GtkTreeIter iter; | 672 | GtkTreeIter iter; |
3339 | 740 | gtk_list_store_append (store, &iter); | 673 | gtk_list_store_append(store, &iter); |
3340 | 741 | gtk_list_store_set(store, &iter, 0, _("<none>"), 1, _("<none>"), -1); | 674 | gtk_list_store_set(store, &iter, 0, _("<none>"), 1, _("<none>"), -1); |
3341 | 742 | 675 | ||
3343 | 743 | gtk_combo_box_set_active( combo, 0 ); | 676 | gtk_combo_box_set_active(combo, 0); |
3344 | 744 | 677 | ||
3345 | 745 | int index = 1; | 678 | int index = 1; |
3350 | 746 | const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); | 679 | const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); |
3351 | 747 | while ( current ) { | 680 | while (current) { |
3352 | 748 | SPObject* obj = SP_OBJECT(current->data); | 681 | SPObject *obj = SP_OBJECT(current->data); |
3353 | 749 | Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); | 682 | Inkscape::ColorProfile *prof = reinterpret_cast<Inkscape::ColorProfile *>(obj); |
3354 | 750 | 683 | ||
3356 | 751 | gtk_list_store_append (store, &iter); | 684 | gtk_list_store_append(store, &iter); |
3357 | 752 | gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); | 685 | gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); |
3358 | 753 | 686 | ||
3362 | 754 | if ( name == prof->name ) { | 687 | if (name == prof->name) { |
3363 | 755 | gtk_combo_box_set_active( combo, index ); | 688 | gtk_combo_box_set_active(combo, index); |
3364 | 756 | gtk_widget_set_tooltip_text(_profileSel, prof->name ); | 689 | gtk_widget_set_tooltip_text(_profileSel, prof->name); |
3365 | 757 | } | 690 | } |
3366 | 758 | 691 | ||
3367 | 759 | index++; | 692 | index++; |
3368 | 760 | current = g_slist_next(current); | 693 | current = g_slist_next(current); |
3369 | 761 | } | 694 | } |
3370 | 762 | 695 | ||
3372 | 763 | g_signal_handler_unblock( G_OBJECT(_profileSel), _profChangedID ); | 696 | g_signal_handler_unblock(G_OBJECT(_profileSel), _profChangedID); |
3373 | 764 | } | 697 | } |
3374 | 765 | #else | 698 | #else |
3376 | 766 | void ColorICCSelectorImpl::_profilesChanged( std::string const & /*name*/ ) | 699 | void ColorICCSelectorImpl::_profilesChanged(std::string const & /*name*/) {} |
3377 | 700 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
3378 | 701 | |||
3379 | 702 | void ColorICCSelector::on_show() | ||
3380 | 767 | { | 703 | { |
3381 | 704 | #if GTK_CHECK_VERSION(3, 0, 0) | ||
3382 | 705 | Gtk::Grid::on_show(); | ||
3383 | 706 | #else | ||
3384 | 707 | Gtk::Table::on_show(); | ||
3385 | 708 | #endif | ||
3386 | 709 | _colorChanged(); | ||
3387 | 768 | } | 710 | } |
3388 | 769 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
3389 | 770 | 711 | ||
3390 | 771 | // Helpers for setting color value | 712 | // Helpers for setting color value |
3391 | 772 | 713 | ||
3392 | 773 | void ColorICCSelector::_colorChanged() | 714 | void ColorICCSelector::_colorChanged() |
3393 | 774 | { | 715 | { |
3394 | 775 | _impl->_updating = TRUE; | 716 | _impl->_updating = TRUE; |
3409 | 776 | //sp_color_icc_set_color( SP_COLOR_ICC( _icc ), &color ); | 717 | // sp_color_icc_set_color( SP_COLOR_ICC( _icc ), &color ); |
3410 | 777 | 718 | ||
3411 | 778 | #ifdef DEBUG_LCMS | 719 | #ifdef DEBUG_LCMS |
3412 | 779 | g_message( "/^^^^^^^^^ %p::_colorChanged(%08x:%s)", this, | 720 | g_message("/^^^^^^^^^ %p::_colorChanged(%08x:%s)", this, _impl->_color.color().toRGBA32(_impl->_color.alpha()), |
3413 | 780 | _color.toRGBA32(_alpha), ( (_color.icc) ? _color.icc->colorProfile.c_str(): "<null>" ) | 721 | ((_impl->_color.color().icc) ? _impl->_color.color().icc->colorProfile.c_str() : "<null>")); |
3414 | 781 | ); | 722 | #endif // DEBUG_LCMS |
3415 | 782 | #endif // DEBUG_LCMS | 723 | |
3416 | 783 | 724 | #ifdef DEBUG_LCMS | |
3417 | 784 | #ifdef DEBUG_LCMS | 725 | g_message("FLIPPIES!!!! %p '%s'", _impl->_color.color().icc, |
3418 | 785 | g_message("FLIPPIES!!!! %p '%s'", _color.icc, (_color.icc ? _color.icc->colorProfile.c_str():"<null>")); | 726 | (_impl->_color.color().icc ? _impl->_color.color().icc->colorProfile.c_str() : "<null>")); |
3419 | 786 | #endif // DEBUG_LCMS | 727 | #endif // DEBUG_LCMS |
3420 | 787 | 728 | ||
3421 | 788 | _impl->_profilesChanged( (_color.icc) ? _color.icc->colorProfile : std::string("") ); | 729 | _impl->_profilesChanged((_impl->_color.color().icc) ? _impl->_color.color().icc->colorProfile : std::string("")); |
3422 | 789 | ColorScales::setScaled( _impl->_adj, _alpha ); | 730 | ColorScales::setScaled(_impl->_adj, _impl->_color.alpha()); |
3423 | 790 | 731 | ||
3424 | 791 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 732 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3426 | 792 | _impl->_setProfile( _color.icc ); | 733 | _impl->_setProfile(_impl->_color.color().icc); |
3427 | 793 | _impl->_fixupNeeded = 0; | 734 | _impl->_fixupNeeded = 0; |
3429 | 794 | gtk_widget_set_sensitive( _impl->_fixupBtn, FALSE ); | 735 | gtk_widget_set_sensitive(_impl->_fixupBtn, FALSE); |
3430 | 795 | 736 | ||
3431 | 796 | if (_impl->_prof) { | 737 | if (_impl->_prof) { |
3433 | 797 | if (_impl->_prof->getTransfToSRGB8() ) { | 738 | if (_impl->_prof->getTransfToSRGB8()) { |
3434 | 798 | cmsUInt16Number tmp[4]; | 739 | cmsUInt16Number tmp[4]; |
3436 | 799 | for ( guint i = 0; i < _impl->_profChannelCount; i++ ) { | 740 | for (guint i = 0; i < _impl->_profChannelCount; i++) { |
3437 | 800 | gdouble val = 0.0; | 741 | gdouble val = 0.0; |
3443 | 801 | if ( _color.icc->colors.size() > i ) { | 742 | if (_impl->_color.color().icc->colors.size() > i) { |
3444 | 802 | if ( _impl->_compUI[i]._component.scale == 256 ) { | 743 | if (_impl->_compUI[i]._component.scale == 256) { |
3445 | 803 | val = (_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_impl->_compUI[i]._component.scale); | 744 | val = (_impl->_color.color().icc->colors[i] + 128.0) / |
3446 | 804 | } else { | 745 | static_cast<gdouble>(_impl->_compUI[i]._component.scale); |
3447 | 805 | val = _color.icc->colors[i] / static_cast<gdouble>(_impl->_compUI[i]._component.scale); | 746 | } |
3448 | 747 | else { | ||
3449 | 748 | val = _impl->_color.color().icc->colors[i] / | ||
3450 | 749 | static_cast<gdouble>(_impl->_compUI[i]._component.scale); | ||
3451 | 806 | } | 750 | } |
3452 | 807 | } | 751 | } |
3453 | 808 | tmp[i] = val * 0x0ffff; | 752 | tmp[i] = val * 0x0ffff; |
3454 | 809 | } | 753 | } |
3456 | 810 | guchar post[4] = {0,0,0,0}; | 754 | guchar post[4] = { 0, 0, 0, 0 }; |
3457 | 811 | cmsHTRANSFORM trans = _impl->_prof->getTransfToSRGB8(); | 755 | cmsHTRANSFORM trans = _impl->_prof->getTransfToSRGB8(); |
3462 | 812 | if ( trans ) { | 756 | if (trans) { |
3463 | 813 | cmsDoTransform( trans, tmp, post, 1 ); | 757 | cmsDoTransform(trans, tmp, post, 1); |
3464 | 814 | guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255 ); | 758 | guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255); |
3465 | 815 | if ( other != _color.toRGBA32(255) ) { | 759 | if (other != _impl->_color.color().toRGBA32(255)) { |
3466 | 816 | _impl->_fixupNeeded = other; | 760 | _impl->_fixupNeeded = other; |
3468 | 817 | gtk_widget_set_sensitive( _impl->_fixupBtn, TRUE ); | 761 | gtk_widget_set_sensitive(_impl->_fixupBtn, TRUE); |
3469 | 818 | #ifdef DEBUG_LCMS | 762 | #ifdef DEBUG_LCMS |
3471 | 819 | g_message("Color needs to change 0x%06x to 0x%06x", _color.toRGBA32(255) >> 8, other >> 8 ); | 763 | g_message("Color needs to change 0x%06x to 0x%06x", _color.toRGBA32(255) >> 8, other >> 8); |
3472 | 820 | #endif // DEBUG_LCMS | 764 | #endif // DEBUG_LCMS |
3473 | 821 | } | 765 | } |
3474 | 822 | } | 766 | } |
3475 | 823 | } | 767 | } |
3476 | 824 | } | 768 | } |
3477 | 825 | #else | 769 | #else |
3479 | 826 | //(void)color; | 770 | //(void)color; |
3480 | 827 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 771 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3482 | 828 | _impl->_updateSliders( -1 ); | 772 | _impl->_updateSliders(-1); |
3483 | 829 | 773 | ||
3484 | 830 | 774 | ||
3485 | 831 | _impl->_updating = FALSE; | 775 | _impl->_updating = FALSE; |
3486 | 832 | #ifdef DEBUG_LCMS | 776 | #ifdef DEBUG_LCMS |
3488 | 833 | g_message( "\\_________ %p::_colorChanged()", this ); | 777 | g_message("\\_________ %p::_colorChanged()", this); |
3489 | 834 | #endif // DEBUG_LCMS | 778 | #endif // DEBUG_LCMS |
3490 | 835 | } | 779 | } |
3491 | 836 | 780 | ||
3492 | 837 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 781 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3494 | 838 | void ColorICCSelectorImpl::_setProfile( SVGICCColor* profile ) | 782 | void ColorICCSelectorImpl::_setProfile(SVGICCColor *profile) |
3495 | 839 | { | 783 | { |
3496 | 840 | #ifdef DEBUG_LCMS | 784 | #ifdef DEBUG_LCMS |
3500 | 841 | g_message( "/^^^^^^^^^ %p::_setProfile(%s)", this, | 785 | g_message("/^^^^^^^^^ %p::_setProfile(%s)", this, ((profile) ? profile->colorProfile.c_str() : "<null>")); |
3498 | 842 | ( (profile) ? profile->colorProfile.c_str() : "<null>") | ||
3499 | 843 | ); | ||
3501 | 844 | #endif // DEBUG_LCMS | 786 | #endif // DEBUG_LCMS |
3502 | 845 | bool profChanged = false; | 787 | bool profChanged = false; |
3504 | 846 | if ( _prof && (!profile || (_profileName != profile->colorProfile) ) ) { | 788 | if (_prof && (!profile || (_profileName != profile->colorProfile))) { |
3505 | 847 | // Need to clear out the prior one | 789 | // Need to clear out the prior one |
3506 | 848 | profChanged = true; | 790 | profChanged = true; |
3507 | 849 | _profileName.clear(); | 791 | _profileName.clear(); |
3508 | 850 | _prof = 0; | 792 | _prof = 0; |
3509 | 851 | _profChannelCount = 0; | 793 | _profChannelCount = 0; |
3511 | 852 | } else if ( profile && !_prof ) { | 794 | } |
3512 | 795 | else if (profile && !_prof) { | ||
3513 | 853 | profChanged = true; | 796 | profChanged = true; |
3514 | 854 | } | 797 | } |
3515 | 855 | 798 | ||
3520 | 856 | for ( size_t i = 0; i < _compUI.size(); i++ ) { | 799 | for (size_t i = 0; i < _compUI.size(); i++) { |
3521 | 857 | gtk_widget_hide( _compUI[i]._label ); | 800 | gtk_widget_hide(_compUI[i]._label); |
3522 | 858 | gtk_widget_hide( _compUI[i]._slider ); | 801 | _compUI[i]._slider->hide(); |
3523 | 859 | gtk_widget_hide( _compUI[i]._btn ); | 802 | gtk_widget_hide(_compUI[i]._btn); |
3524 | 860 | } | 803 | } |
3525 | 861 | 804 | ||
3527 | 862 | if ( profile ) { | 805 | if (profile) { |
3528 | 863 | _prof = SP_ACTIVE_DOCUMENT->profileManager->find(profile->colorProfile.c_str()); | 806 | _prof = SP_ACTIVE_DOCUMENT->profileManager->find(profile->colorProfile.c_str()); |
3530 | 864 | if ( _prof && (asICColorProfileClassSig(_prof->getProfileClass()) != cmsSigNamedColorClass) ) { | 807 | if (_prof && (asICColorProfileClassSig(_prof->getProfileClass()) != cmsSigNamedColorClass)) { |
3531 | 865 | #if HAVE_LIBLCMS1 | 808 | #if HAVE_LIBLCMS1 |
3533 | 866 | _profChannelCount = _cmsChannelsOf( asICColorSpaceSig(_prof->getColorSpace()) ); | 809 | _profChannelCount = _cmsChannelsOf(asICColorSpaceSig(_prof->getColorSpace())); |
3534 | 867 | #elif HAVE_LIBLCMS2 | 810 | #elif HAVE_LIBLCMS2 |
3536 | 868 | _profChannelCount = cmsChannelsOf( asICColorSpaceSig(_prof->getColorSpace()) ); | 811 | _profChannelCount = cmsChannelsOf(asICColorSpaceSig(_prof->getColorSpace())); |
3537 | 869 | #endif | 812 | #endif |
3538 | 870 | 813 | ||
3543 | 871 | if ( profChanged ) { | 814 | if (profChanged) { |
3544 | 872 | std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo(asICColorSpaceSig(_prof->getColorSpace())); | 815 | std::vector<colorspace::Component> things = |
3545 | 873 | for (size_t i = 0; (i < things.size()) && (i < _profChannelCount); ++i) | 816 | colorspace::getColorSpaceInfo(asICColorSpaceSig(_prof->getColorSpace())); |
3546 | 874 | { | 817 | for (size_t i = 0; (i < things.size()) && (i < _profChannelCount); ++i) { |
3547 | 875 | _compUI[i]._component = things[i]; | 818 | _compUI[i]._component = things[i]; |
3548 | 876 | } | 819 | } |
3549 | 877 | 820 | ||
3573 | 878 | for ( guint i = 0; i < _profChannelCount; i++ ) { | 821 | for (guint i = 0; i < _profChannelCount; i++) { |
3574 | 879 | gtk_label_set_text_with_mnemonic( GTK_LABEL(_compUI[i]._label), (i < things.size()) ? things[i].name.c_str() : ""); | 822 | gtk_label_set_text_with_mnemonic(GTK_LABEL(_compUI[i]._label), |
3575 | 880 | 823 | (i < things.size()) ? things[i].name.c_str() : ""); | |
3576 | 881 | gtk_widget_set_tooltip_text( _compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" ); | 824 | |
3577 | 882 | gtk_widget_set_tooltip_text( _compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : "" ); | 825 | _compUI[i]._slider->set_tooltip_text((i < things.size()) ? things[i].tip.c_str() : ""); |
3578 | 883 | 826 | gtk_widget_set_tooltip_text(_compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : ""); | |
3579 | 884 | sp_color_slider_set_colors( SP_COLOR_SLIDER(_compUI[i]._slider), | 827 | |
3580 | 885 | SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), | 828 | _compUI[i]._slider->setColors(SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), |
3581 | 886 | SPColor(0.5, 0.5, 0.5).toRGBA32(0xff), | 829 | SPColor(0.5, 0.5, 0.5).toRGBA32(0xff), |
3582 | 887 | SPColor(1.0, 1.0, 1.0).toRGBA32(0xff) ); | 830 | SPColor(1.0, 1.0, 1.0).toRGBA32(0xff)); |
3583 | 888 | /* | 831 | /* |
3584 | 889 | _compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); | 832 | _compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], |
3585 | 890 | g_signal_connect( G_OBJECT( _compUI[i]._adj ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); | 833 | step, page, page ) ); |
3586 | 891 | 834 | g_signal_connect( G_OBJECT( _compUI[i]._adj ), "value_changed", G_CALLBACK( | |
3587 | 892 | sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_compUI[i]._slider), _compUI[i]._adj ); | 835 | _adjustmentChanged ), _csel ); |
3588 | 893 | gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_compUI[i]._btn), _compUI[i]._adj ); | 836 | |
3589 | 894 | gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_compUI[i]._btn), digits ); | 837 | sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_compUI[i]._slider), |
3590 | 895 | */ | 838 | _compUI[i]._adj ); |
3591 | 896 | gtk_widget_show( _compUI[i]._label ); | 839 | gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_compUI[i]._btn), |
3592 | 897 | gtk_widget_show( _compUI[i]._slider ); | 840 | _compUI[i]._adj ); |
3593 | 898 | gtk_widget_show( _compUI[i]._btn ); | 841 | gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_compUI[i]._btn), digits ); |
3594 | 899 | //gtk_adjustment_set_value( _compUI[i]._adj, 0.0 ); | 842 | */ |
3595 | 900 | //gtk_adjustment_set_value( _compUI[i]._adj, val ); | 843 | gtk_widget_show(_compUI[i]._label); |
3596 | 844 | _compUI[i]._slider->show(); | ||
3597 | 845 | gtk_widget_show(_compUI[i]._btn); | ||
3598 | 846 | // gtk_adjustment_set_value( _compUI[i]._adj, 0.0 ); | ||
3599 | 847 | // gtk_adjustment_set_value( _compUI[i]._adj, val ); | ||
3600 | 901 | } | 848 | } |
3605 | 902 | for ( size_t i = _profChannelCount; i < _compUI.size(); i++ ) { | 849 | for (size_t i = _profChannelCount; i < _compUI.size(); i++) { |
3606 | 903 | gtk_widget_hide( _compUI[i]._label ); | 850 | gtk_widget_hide(_compUI[i]._label); |
3607 | 904 | gtk_widget_hide( _compUI[i]._slider ); | 851 | _compUI[i]._slider->hide(); |
3608 | 905 | gtk_widget_hide( _compUI[i]._btn ); | 852 | gtk_widget_hide(_compUI[i]._btn); |
3609 | 906 | } | 853 | } |
3610 | 907 | } | 854 | } |
3612 | 908 | } else { | 855 | } |
3613 | 856 | else { | ||
3614 | 909 | // Give up for now on named colors | 857 | // Give up for now on named colors |
3615 | 910 | _prof = 0; | 858 | _prof = 0; |
3616 | 911 | } | 859 | } |
3617 | 912 | } | 860 | } |
3618 | 913 | 861 | ||
3619 | 914 | #ifdef DEBUG_LCMS | 862 | #ifdef DEBUG_LCMS |
3621 | 915 | g_message( "\\_________ %p::_setProfile()", this ); | 863 | g_message("\\_________ %p::_setProfile()", this); |
3622 | 916 | #endif // DEBUG_LCMS | 864 | #endif // DEBUG_LCMS |
3623 | 917 | } | 865 | } |
3624 | 918 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 866 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3625 | 919 | 867 | ||
3627 | 920 | void ColorICCSelectorImpl::_updateSliders( gint ignore ) | 868 | void ColorICCSelectorImpl::_updateSliders(gint ignore) |
3628 | 921 | { | 869 | { |
3629 | 922 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 870 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3633 | 923 | if ( _owner->_color.icc ) | 871 | if (_color.color().icc) { |
3634 | 924 | { | 872 | for (guint i = 0; i < _profChannelCount; i++) { |
3632 | 925 | for ( guint i = 0; i < _profChannelCount; i++ ) { | ||
3635 | 926 | gdouble val = 0.0; | 873 | gdouble val = 0.0; |
3641 | 927 | if ( _owner->_color.icc->colors.size() > i ) { | 874 | if (_color.color().icc->colors.size() > i) { |
3642 | 928 | if ( _compUI[i]._component.scale == 256 ) { | 875 | if (_compUI[i]._component.scale == 256) { |
3643 | 929 | val = (_owner->_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_compUI[i]._component.scale); | 876 | val = (_color.color().icc->colors[i] + 128.0) / static_cast<gdouble>(_compUI[i]._component.scale); |
3644 | 930 | } else { | 877 | } |
3645 | 931 | val = _owner->_color.icc->colors[i] / static_cast<gdouble>(_compUI[i]._component.scale); | 878 | else { |
3646 | 879 | val = _color.color().icc->colors[i] / static_cast<gdouble>(_compUI[i]._component.scale); | ||
3647 | 932 | } | 880 | } |
3648 | 933 | } | 881 | } |
3650 | 934 | gtk_adjustment_set_value( _compUI[i]._adj, val ); | 882 | gtk_adjustment_set_value(_compUI[i]._adj, val); |
3651 | 935 | } | 883 | } |
3652 | 936 | 884 | ||
3661 | 937 | if ( _prof ) { | 885 | if (_prof) { |
3662 | 938 | if ( _prof->getTransfToSRGB8() ) { | 886 | if (_prof->getTransfToSRGB8()) { |
3663 | 939 | for ( guint i = 0; i < _profChannelCount; i++ ) { | 887 | for (guint i = 0; i < _profChannelCount; i++) { |
3664 | 940 | if ( static_cast<gint>(i) != ignore ) { | 888 | if (static_cast<gint>(i) != ignore) { |
3665 | 941 | cmsUInt16Number* scratch = getScratch(); | 889 | cmsUInt16Number *scratch = getScratch(); |
3666 | 942 | cmsUInt16Number filler[4] = {0, 0, 0, 0}; | 890 | cmsUInt16Number filler[4] = { 0, 0, 0, 0 }; |
3667 | 943 | for ( guint j = 0; j < _profChannelCount; j++ ) { | 891 | for (guint j = 0; j < _profChannelCount; j++) { |
3668 | 944 | filler[j] = 0x0ffff * ColorScales::getScaled( _compUI[j]._adj ); | 892 | filler[j] = 0x0ffff * ColorScales::getScaled(_compUI[j]._adj); |
3669 | 945 | } | 893 | } |
3675 | 946 | 894 | ||
3676 | 947 | cmsUInt16Number* p = scratch; | 895 | cmsUInt16Number *p = scratch; |
3677 | 948 | for ( guint x = 0; x < 1024; x++ ) { | 896 | for (guint x = 0; x < 1024; x++) { |
3678 | 949 | for ( guint j = 0; j < _profChannelCount; j++ ) { | 897 | for (guint j = 0; j < _profChannelCount; j++) { |
3679 | 950 | if ( j == i ) { | 898 | if (j == i) { |
3680 | 951 | *p++ = x * 0x0ffff / 1024; | 899 | *p++ = x * 0x0ffff / 1024; |
3682 | 952 | } else { | 900 | } |
3683 | 901 | else { | ||
3684 | 953 | *p++ = filler[j]; | 902 | *p++ = filler[j]; |
3685 | 954 | } | 903 | } |
3686 | 955 | } | 904 | } |
3687 | 956 | } | 905 | } |
3689 | 957 | 906 | ||
3690 | 958 | cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); | 907 | cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); |
3694 | 959 | if ( trans ) { | 908 | if (trans) { |
3695 | 960 | cmsDoTransform( trans, scratch, _compUI[i]._map, 1024 ); | 909 | cmsDoTransform(trans, scratch, _compUI[i]._map, 1024); |
3696 | 961 | sp_color_slider_set_map( SP_COLOR_SLIDER(_compUI[i]._slider), _compUI[i]._map ); | 910 | if (_compUI[i]._slider) |
3697 | 911 | { | ||
3698 | 912 | _compUI[i]._slider->setMap(_compUI[i]._map); | ||
3699 | 913 | } | ||
3700 | 962 | } | 914 | } |
3701 | 963 | } | 915 | } |
3702 | 964 | } | 916 | } |
3703 | @@ -969,15 +921,15 @@ | |||
3704 | 969 | (void)ignore; | 921 | (void)ignore; |
3705 | 970 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 922 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3706 | 971 | 923 | ||
3710 | 972 | guint32 start = _owner->_color.toRGBA32( 0x00 ); | 924 | guint32 start = _color.color().toRGBA32(0x00); |
3711 | 973 | guint32 mid = _owner->_color.toRGBA32( 0x7f ); | 925 | guint32 mid = _color.color().toRGBA32(0x7f); |
3712 | 974 | guint32 end = _owner->_color.toRGBA32( 0xff ); | 926 | guint32 end = _color.color().toRGBA32(0xff); |
3713 | 975 | 927 | ||
3715 | 976 | sp_color_slider_set_colors( SP_COLOR_SLIDER(_slider), start, mid, end ); | 928 | _slider->setColors(start, mid, end); |
3716 | 977 | } | 929 | } |
3717 | 978 | 930 | ||
3718 | 979 | 931 | ||
3720 | 980 | void ColorICCSelectorImpl::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICCSelector *cs ) | 932 | void ColorICCSelectorImpl::_adjustmentChanged(GtkAdjustment *adjustment, ColorICCSelectorImpl *cs) |
3721 | 981 | { | 933 | { |
3722 | 982 | // // TODO check this. It looks questionable: | 934 | // // TODO check this. It looks questionable: |
3723 | 983 | // // if a value is entered between 0 and 1 exclusive, normalize it to (int) 0..255 or 0..100 | 935 | // // if a value is entered between 0 and 1 exclusive, normalize it to (int) 0..255 or 0..100 |
3724 | @@ -986,121 +938,135 @@ | |||
3725 | 986 | // } | 938 | // } |
3726 | 987 | 939 | ||
3727 | 988 | #ifdef DEBUG_LCMS | 940 | #ifdef DEBUG_LCMS |
3729 | 989 | g_message( "/^^^^^^^^^ %p::_adjustmentChanged()", cs ); | 941 | g_message("/^^^^^^^^^ %p::_adjustmentChanged()", cs); |
3730 | 990 | #endif // DEBUG_LCMS | 942 | #endif // DEBUG_LCMS |
3731 | 991 | 943 | ||
3744 | 992 | ColorICCSelector* iccSelector = static_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); | 944 | ColorICCSelector *iccSelector = cs->_owner; |
3745 | 993 | if (iccSelector->_impl->_updating) { | 945 | if (iccSelector->_impl->_updating) { |
3746 | 994 | return; | 946 | return; |
3747 | 995 | } | 947 | } |
3748 | 996 | 948 | ||
3749 | 997 | iccSelector->_impl->_updating = TRUE; | 949 | iccSelector->_impl->_updating = TRUE; |
3750 | 998 | 950 | ||
3751 | 999 | gint match = -1; | 951 | gint match = -1; |
3752 | 1000 | 952 | ||
3753 | 1001 | SPColor newColor( iccSelector->_color ); | 953 | SPColor newColor(iccSelector->_impl->_color.color()); |
3754 | 1002 | gfloat scaled = ColorScales::getScaled( iccSelector->_impl->_adj ); | 954 | gfloat scaled = ColorScales::getScaled(iccSelector->_impl->_adj); |
3755 | 1003 | if ( iccSelector->_impl->_adj == adjustment ) { | 955 | if (iccSelector->_impl->_adj == adjustment) { |
3756 | 1004 | #ifdef DEBUG_LCMS | 956 | #ifdef DEBUG_LCMS |
3758 | 1005 | g_message("ALPHA"); | 957 | g_message("ALPHA"); |
3759 | 1006 | #endif // DEBUG_LCMS | 958 | #endif // DEBUG_LCMS |
3761 | 1007 | } else { | 959 | } |
3762 | 960 | else { | ||
3763 | 1008 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 961 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3813 | 1009 | for ( size_t i = 0; i < iccSelector->_impl->_compUI.size(); i++ ) { | 962 | for (size_t i = 0; i < iccSelector->_impl->_compUI.size(); i++) { |
3814 | 1010 | if ( iccSelector->_impl->_compUI[i]._adj == adjustment ) { | 963 | if (iccSelector->_impl->_compUI[i]._adj == adjustment) { |
3815 | 1011 | match = i; | 964 | match = i; |
3816 | 1012 | break; | 965 | break; |
3817 | 1013 | } | 966 | } |
3818 | 1014 | } | 967 | } |
3819 | 1015 | if ( match >= 0 ) { | 968 | if (match >= 0) { |
3820 | 1016 | #ifdef DEBUG_LCMS | 969 | #ifdef DEBUG_LCMS |
3821 | 1017 | g_message(" channel %d", match ); | 970 | g_message(" channel %d", match); |
3822 | 1018 | #endif // DEBUG_LCMS | 971 | #endif // DEBUG_LCMS |
3823 | 1019 | } | 972 | } |
3824 | 1020 | 973 | ||
3825 | 1021 | 974 | ||
3826 | 1022 | cmsUInt16Number tmp[4]; | 975 | cmsUInt16Number tmp[4]; |
3827 | 1023 | for ( guint i = 0; i < 4; i++ ) { | 976 | for (guint i = 0; i < 4; i++) { |
3828 | 1024 | tmp[i] = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ) * 0x0ffff; | 977 | tmp[i] = ColorScales::getScaled(iccSelector->_impl->_compUI[i]._adj) * 0x0ffff; |
3829 | 1025 | } | 978 | } |
3830 | 1026 | guchar post[4] = {0,0,0,0}; | 979 | guchar post[4] = { 0, 0, 0, 0 }; |
3831 | 1027 | 980 | ||
3832 | 1028 | cmsHTRANSFORM trans = iccSelector->_impl->_prof->getTransfToSRGB8(); | 981 | cmsHTRANSFORM trans = iccSelector->_impl->_prof->getTransfToSRGB8(); |
3833 | 1029 | if ( trans ) { | 982 | if (trans) { |
3834 | 1030 | cmsDoTransform( trans, tmp, post, 1 ); | 983 | cmsDoTransform(trans, tmp, post, 1); |
3835 | 1031 | } | 984 | } |
3836 | 1032 | 985 | ||
3837 | 1033 | SPColor other( SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255) ); | 986 | SPColor other(SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255)); |
3838 | 1034 | other.icc = new SVGICCColor(); | 987 | other.icc = new SVGICCColor(); |
3839 | 1035 | if ( iccSelector->_color.icc ) { | 988 | if (iccSelector->_impl->_color.color().icc) { |
3840 | 1036 | other.icc->colorProfile = iccSelector->_color.icc->colorProfile; | 989 | other.icc->colorProfile = iccSelector->_impl->_color.color().icc->colorProfile; |
3841 | 1037 | } | 990 | } |
3842 | 1038 | 991 | ||
3843 | 1039 | guint32 prior = iccSelector->_color.toRGBA32(255); | 992 | guint32 prior = iccSelector->_impl->_color.color().toRGBA32(255); |
3844 | 1040 | guint32 newer = other.toRGBA32(255); | 993 | guint32 newer = other.toRGBA32(255); |
3845 | 1041 | 994 | ||
3846 | 1042 | if ( prior != newer ) { | 995 | if (prior != newer) { |
3847 | 1043 | #ifdef DEBUG_LCMS | 996 | #ifdef DEBUG_LCMS |
3848 | 1044 | g_message("Transformed color from 0x%08x to 0x%08x", prior, newer ); | 997 | g_message("Transformed color from 0x%08x to 0x%08x", prior, newer); |
3849 | 1045 | g_message(" ~~~~ FLIP"); | 998 | g_message(" ~~~~ FLIP"); |
3850 | 1046 | #endif // DEBUG_LCMS | 999 | #endif // DEBUG_LCMS |
3851 | 1047 | newColor = other; | 1000 | newColor = other; |
3852 | 1048 | newColor.icc->colors.clear(); | 1001 | newColor.icc->colors.clear(); |
3853 | 1049 | for ( guint i = 0; i < iccSelector->_impl->_profChannelCount; i++ ) { | 1002 | for (guint i = 0; i < iccSelector->_impl->_profChannelCount; i++) { |
3854 | 1050 | gdouble val = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ); | 1003 | gdouble val = ColorScales::getScaled(iccSelector->_impl->_compUI[i]._adj); |
3855 | 1051 | val *= iccSelector->_impl->_compUI[i]._component.scale; | 1004 | val *= iccSelector->_impl->_compUI[i]._component.scale; |
3856 | 1052 | if ( iccSelector->_impl->_compUI[i]._component.scale == 256 ) { | 1005 | if (iccSelector->_impl->_compUI[i]._component.scale == 256) { |
3857 | 1053 | val -= 128; | 1006 | val -= 128; |
3858 | 1054 | } | 1007 | } |
3859 | 1055 | newColor.icc->colors.push_back( val ); | 1008 | newColor.icc->colors.push_back(val); |
3860 | 1056 | } | 1009 | } |
3861 | 1057 | } | 1010 | } |
3862 | 1058 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 1011 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
3866 | 1059 | } | 1012 | } |
3867 | 1060 | iccSelector->_updateInternals( newColor, scaled, iccSelector->_impl->_dragging ); | 1013 | iccSelector->_impl->_color.setColorAlpha(newColor, scaled); |
3868 | 1061 | iccSelector->_impl->_updateSliders( match ); | 1014 | // iccSelector->_updateInternals( newColor, scaled, iccSelector->_impl->_dragging ); |
3869 | 1015 | iccSelector->_impl->_updateSliders(match); | ||
3870 | 1062 | 1016 | ||
3872 | 1063 | iccSelector->_impl->_updating = FALSE; | 1017 | iccSelector->_impl->_updating = FALSE; |
3873 | 1064 | #ifdef DEBUG_LCMS | 1018 | #ifdef DEBUG_LCMS |
3875 | 1065 | g_message( "\\_________ %p::_adjustmentChanged()", cs ); | 1019 | g_message("\\_________ %p::_adjustmentChanged()", cs); |
3876 | 1066 | #endif // DEBUG_LCMS | 1020 | #endif // DEBUG_LCMS |
3877 | 1067 | } | 1021 | } |
3878 | 1068 | 1022 | ||
3880 | 1069 | void ColorICCSelectorImpl::_sliderGrabbed( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) | 1023 | void ColorICCSelectorImpl::_sliderGrabbed() |
3881 | 1070 | { | 1024 | { |
3888 | 1071 | // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); | 1025 | // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); |
3889 | 1072 | // if (!iccSelector->_dragging) { | 1026 | // if (!iccSelector->_dragging) { |
3890 | 1073 | // iccSelector->_dragging = TRUE; | 1027 | // iccSelector->_dragging = TRUE; |
3891 | 1074 | // iccSelector->_grabbed(); | 1028 | // iccSelector->_grabbed(); |
3892 | 1075 | // iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_impl->_adj ), iccSelector->_dragging ); | 1029 | // iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_impl->_adj ), |
3893 | 1076 | // } | 1030 | // iccSelector->_dragging ); |
3894 | 1031 | // } | ||
3895 | 1077 | } | 1032 | } |
3896 | 1078 | 1033 | ||
3898 | 1079 | void ColorICCSelectorImpl::_sliderReleased( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) | 1034 | void ColorICCSelectorImpl::_sliderReleased() |
3899 | 1080 | { | 1035 | { |
3906 | 1081 | // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); | 1036 | // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); |
3907 | 1082 | // if (iccSelector->_dragging) { | 1037 | // if (iccSelector->_dragging) { |
3908 | 1083 | // iccSelector->_dragging = FALSE; | 1038 | // iccSelector->_dragging = FALSE; |
3909 | 1084 | // iccSelector->_released(); | 1039 | // iccSelector->_released(); |
3910 | 1085 | // iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), iccSelector->_dragging ); | 1040 | // iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), |
3911 | 1086 | // } | 1041 | // iccSelector->_dragging ); |
3912 | 1042 | // } | ||
3913 | 1087 | } | 1043 | } |
3914 | 1088 | 1044 | ||
3915 | 1089 | #ifdef DEBUG_LCMS | 1045 | #ifdef DEBUG_LCMS |
3917 | 1090 | void ColorICCSelectorImpl::_sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ) | 1046 | void ColorICCSelectorImpl::_sliderChanged(SPColorSlider *slider, SPColorICCSelector *cs) |
3918 | 1091 | #else | 1047 | #else |
3920 | 1092 | void ColorICCSelectorImpl::_sliderChanged( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) | 1048 | void ColorICCSelectorImpl::_sliderChanged() |
3921 | 1093 | #endif // DEBUG_LCMS | 1049 | #endif // DEBUG_LCMS |
3922 | 1094 | { | 1050 | { |
3923 | 1095 | #ifdef DEBUG_LCMS | 1051 | #ifdef DEBUG_LCMS |
3925 | 1096 | g_message("Changed %p and %p", slider, cs ); | 1052 | g_message("Changed %p and %p", slider, cs); |
3926 | 1097 | #endif // DEBUG_LCMS | 1053 | #endif // DEBUG_LCMS |
3933 | 1098 | // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); | 1054 | // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); |
3934 | 1099 | 1055 | ||
3935 | 1100 | // iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), iccSelector->_dragging ); | 1056 | // iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), |
3936 | 1101 | } | 1057 | // iccSelector->_dragging ); |
3937 | 1102 | 1058 | } | |
3938 | 1103 | 1059 | ||
3939 | 1060 | Gtk::Widget *ColorICCSelectorFactory::createWidget(Inkscape::UI::SelectedColor &color) const | ||
3940 | 1061 | { | ||
3941 | 1062 | Gtk::Widget *w = Gtk::manage(new ColorICCSelector(color)); | ||
3942 | 1063 | return w; | ||
3943 | 1064 | } | ||
3944 | 1065 | |||
3945 | 1066 | Glib::ustring ColorICCSelectorFactory::modeName() const { return gettext(ColorICCSelector::MODE_NAME); } | ||
3946 | 1067 | } | ||
3947 | 1068 | } | ||
3948 | 1069 | } | ||
3949 | 1104 | /* | 1070 | /* |
3950 | 1105 | Local Variables: | 1071 | Local Variables: |
3951 | 1106 | mode:c++ | 1072 | mode:c++ |
3952 | 1107 | 1073 | ||
3953 | === renamed file 'src/widgets/sp-color-icc-selector.h' => 'src/ui/widget/color-icc-selector.h' | |||
3954 | --- src/widgets/sp-color-icc-selector.h 2014-10-08 02:22:03 +0000 | |||
3955 | +++ src/ui/widget/color-icc-selector.h 2015-05-17 11:43:43 +0000 | |||
3956 | @@ -1,63 +1,69 @@ | |||
3957 | 1 | #ifndef SEEN_SP_COLOR_ICC_SELECTOR_H | 1 | #ifndef SEEN_SP_COLOR_ICC_SELECTOR_H |
3958 | 2 | #define SEEN_SP_COLOR_ICC_SELECTOR_H | 2 | #define SEEN_SP_COLOR_ICC_SELECTOR_H |
3959 | 3 | 3 | ||
3962 | 4 | #include <glib.h> | 4 | #ifdef HAVE_CONFIG_H |
3963 | 5 | #include "sp-color-selector.h" | 5 | #include <config.h> |
3964 | 6 | #endif | ||
3965 | 7 | |||
3966 | 8 | #include <gtkmm/widget.h> | ||
3967 | 9 | #if WITH_GTKMM_3_0 | ||
3968 | 10 | #include <gtkmm/grid.h> | ||
3969 | 11 | #else | ||
3970 | 12 | #include <gtkmm/table.h> | ||
3971 | 13 | #endif | ||
3972 | 14 | |||
3973 | 15 | #include "ui/selected-color.h" | ||
3974 | 6 | 16 | ||
3975 | 7 | namespace Inkscape { | 17 | namespace Inkscape { |
3976 | 18 | |||
3977 | 8 | class ColorProfile; | 19 | class ColorProfile; |
3978 | 9 | } | ||
3979 | 10 | 20 | ||
3982 | 11 | struct SPColorICCSelector; | 21 | namespace UI { |
3983 | 12 | struct SPColorICCSelectorClass; | 22 | namespace Widget { |
3984 | 13 | 23 | ||
3985 | 14 | class ColorICCSelectorImpl; | 24 | class ColorICCSelectorImpl; |
3986 | 15 | 25 | ||
3991 | 16 | class ColorICCSelector: public ColorSelector | 26 | class ColorICCSelector |
3992 | 17 | { | 27 | #if GTK_CHECK_VERSION(3, 0, 0) |
3993 | 18 | public: | 28 | : public Gtk::Grid |
3994 | 19 | ColorICCSelector( SPColorSelector* csel ); | 29 | #else |
3995 | 30 | : public Gtk::Table | ||
3996 | 31 | #endif | ||
3997 | 32 | { | ||
3998 | 33 | public: | ||
3999 | 34 | static const gchar *MODE_NAME; | ||
4000 | 35 | |||
4001 | 36 | ColorICCSelector(SelectedColor &color); | ||
4002 | 20 | virtual ~ColorICCSelector(); | 37 | virtual ~ColorICCSelector(); |
4003 | 21 | 38 | ||
4004 | 22 | virtual void init(); | 39 | virtual void init(); |
4005 | 23 | 40 | ||
4007 | 24 | protected: | 41 | protected: |
4008 | 42 | void on_show(); | ||
4009 | 43 | |||
4010 | 25 | virtual void _colorChanged(); | 44 | virtual void _colorChanged(); |
4011 | 26 | 45 | ||
4013 | 27 | void _recalcColor( gboolean changing ); | 46 | void _recalcColor(gboolean changing); |
4014 | 28 | 47 | ||
4016 | 29 | private: | 48 | private: |
4017 | 30 | friend class ColorICCSelectorImpl; | 49 | friend class ColorICCSelectorImpl; |
4018 | 31 | 50 | ||
4019 | 32 | // By default, disallow copy constructor and assignment operator | 51 | // By default, disallow copy constructor and assignment operator |
4022 | 33 | ColorICCSelector( const ColorICCSelector& obj ); | 52 | ColorICCSelector(const ColorICCSelector &obj); |
4023 | 34 | ColorICCSelector& operator=( const ColorICCSelector& obj ); | 53 | ColorICCSelector &operator=(const ColorICCSelector &obj); |
4024 | 35 | 54 | ||
4025 | 36 | ColorICCSelectorImpl *_impl; | 55 | ColorICCSelectorImpl *_impl; |
4026 | 37 | }; | 56 | }; |
4027 | 38 | 57 | ||
4028 | 39 | 58 | ||
4050 | 40 | 59 | class ColorICCSelectorFactory : public ColorSelectorFactory { | |
4051 | 41 | #define SP_TYPE_COLOR_ICC_SELECTOR (sp_color_icc_selector_get_type()) | 60 | public: |
4052 | 42 | #define SP_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelector)) | 61 | Gtk::Widget *createWidget(SelectedColor &color) const; |
4053 | 43 | #define SP_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelectorClass)) | 62 | Glib::ustring modeName() const; |
4054 | 44 | #define SP_IS_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_COLOR_ICC_SELECTOR)) | 63 | }; |
4055 | 45 | #define SP_IS_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_COLOR_ICC_SELECTOR)) | 64 | } |
4056 | 46 | 65 | } | |
4057 | 47 | struct SPColorICCSelector { | 66 | } |
4037 | 48 | SPColorSelector parent; | ||
4038 | 49 | }; | ||
4039 | 50 | |||
4040 | 51 | struct SPColorICCSelectorClass { | ||
4041 | 52 | SPColorSelectorClass parent_class; | ||
4042 | 53 | }; | ||
4043 | 54 | |||
4044 | 55 | GType sp_color_icc_selector_get_type(void); | ||
4045 | 56 | |||
4046 | 57 | GtkWidget *sp_color_icc_selector_new(void); | ||
4047 | 58 | |||
4048 | 59 | |||
4049 | 60 | |||
4058 | 61 | #endif // SEEN_SP_COLOR_ICC_SELECTOR_H | 67 | #endif // SEEN_SP_COLOR_ICC_SELECTOR_H |
4059 | 62 | 68 | ||
4060 | 63 | /* | 69 | /* |
4061 | 64 | 70 | ||
4062 | === renamed file 'src/widgets/sp-color-notebook.cpp' => 'src/ui/widget/color-notebook.cpp' | |||
4063 | --- src/widgets/sp-color-notebook.cpp 2014-10-08 02:22:03 +0000 | |||
4064 | +++ src/ui/widget/color-notebook.cpp 2015-05-17 11:43:43 +0000 | |||
4065 | @@ -1,11 +1,13 @@ | |||
4070 | 1 | /* | 1 | /** |
4071 | 2 | * A notebook with RGB, CMYK, CMS, HSL, and Wheel pages | 2 | * @file |
4072 | 3 | * | 3 | * A notebook with RGB, CMYK, CMS, HSL, and Wheel pages - implementation |
4073 | 4 | * Author: | 4 | */ |
4074 | 5 | /* Authors: | ||
4075 | 5 | * Lauris Kaplinski <lauris@kaplinski.com> | 6 | * Lauris Kaplinski <lauris@kaplinski.com> |
4076 | 6 | * bulia byak <buliabyak@users.sf.net> | 7 | * bulia byak <buliabyak@users.sf.net> |
4077 | 8 | * Tomasz Boczkowski <penginsbacon@gmail.com> (c++-sification) | ||
4078 | 7 | * | 9 | * |
4080 | 8 | * Copyright (C) 2001-2002 Lauris Kaplinski | 10 | * Copyright (C) 2001-2014 Authors |
4081 | 9 | * | 11 | * |
4082 | 10 | * This code is in public domain | 12 | * This code is in public domain |
4083 | 11 | */ | 13 | */ |
4084 | @@ -14,7 +16,7 @@ | |||
4085 | 14 | #define noDUMP_CHANGE_INFO | 16 | #define noDUMP_CHANGE_INFO |
4086 | 15 | 17 | ||
4087 | 16 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
4089 | 17 | # include "config.h" | 19 | #include "config.h" |
4090 | 18 | #endif | 20 | #endif |
4091 | 19 | 21 | ||
4092 | 20 | #include "widgets/icon.h" | 22 | #include "widgets/icon.h" |
4093 | @@ -22,512 +24,233 @@ | |||
4094 | 22 | #include <string> | 24 | #include <string> |
4095 | 23 | #include <cstdlib> | 25 | #include <cstdlib> |
4096 | 24 | #include <cstddef> | 26 | #include <cstddef> |
4097 | 25 | #include <gtk/gtk.h> | ||
4098 | 26 | #include <glibmm/i18n.h> | 27 | #include <glibmm/i18n.h> |
4099 | 28 | #include <gtkmm/label.h> | ||
4100 | 29 | #include <gtkmm/notebook.h> | ||
4101 | 27 | 30 | ||
4109 | 28 | #include "ui/dialog-events.h" | 31 | #include "preferences.h" |
4110 | 29 | #include "../preferences.h" | 32 | #include "widgets/spw-utilities.h" |
4104 | 30 | #include "sp-color-notebook.h" | ||
4105 | 31 | #include "spw-utilities.h" | ||
4106 | 32 | #include "sp-color-scales.h" | ||
4107 | 33 | #include "sp-color-icc-selector.h" | ||
4108 | 34 | #include "sp-color-wheel-selector.h" | ||
4111 | 35 | #include "svg/svg-icc-color.h" | 33 | #include "svg/svg-icc-color.h" |
4115 | 36 | #include "../inkscape.h" | 34 | #include "inkscape.h" |
4116 | 37 | #include "../document.h" | 35 | #include "document.h" |
4117 | 38 | #include "../profile-manager.h" | 36 | #include "profile-manager.h" |
4118 | 39 | #include "color-profile.h" | 37 | #include "color-profile.h" |
4119 | 40 | #include "cms-system.h" | 38 | #include "cms-system.h" |
4120 | 39 | #include "ui/dialog-events.h" | ||
4121 | 41 | #include "ui/tools-switch.h" | 40 | #include "ui/tools-switch.h" |
4122 | 42 | #include "ui/tools/tool-base.h" | 41 | #include "ui/tools/tool-base.h" |
4123 | 42 | #include "ui/widget/color-entry.h" | ||
4124 | 43 | #include "ui/widget/color-icc-selector.h" | ||
4125 | 44 | #include "ui/widget/color-notebook.h" | ||
4126 | 45 | #include "ui/widget/color-scales.h" | ||
4127 | 46 | #include "ui/widget/color-wheel-selector.h" | ||
4128 | 43 | 47 | ||
4129 | 44 | using Inkscape::CMSSystem; | 48 | using Inkscape::CMSSystem; |
4130 | 45 | 49 | ||
4131 | 46 | struct SPColorNotebookTracker { | ||
4132 | 47 | const gchar* name; | ||
4133 | 48 | const gchar* className; | ||
4134 | 49 | GType type; | ||
4135 | 50 | guint submode; | ||
4136 | 51 | gboolean enabledFull; | ||
4137 | 52 | gboolean enabledBrief; | ||
4138 | 53 | SPColorNotebook *backPointer; | ||
4139 | 54 | }; | ||
4140 | 55 | |||
4141 | 56 | static void sp_color_notebook_dispose(GObject *object); | ||
4142 | 57 | |||
4143 | 58 | static void sp_color_notebook_show_all (GtkWidget *widget); | ||
4144 | 59 | static void sp_color_notebook_hide(GtkWidget *widget); | ||
4145 | 60 | |||
4146 | 61 | #define XPAD 4 | 50 | #define XPAD 4 |
4147 | 62 | #define YPAD 1 | 51 | #define YPAD 1 |
4148 | 63 | 52 | ||
4255 | 64 | G_DEFINE_TYPE(SPColorNotebook, sp_color_notebook, SP_TYPE_COLOR_SELECTOR); | 53 | namespace Inkscape { |
4256 | 65 | 54 | namespace UI { | |
4257 | 66 | static void sp_color_notebook_class_init(SPColorNotebookClass *klass) | 55 | namespace Widget { |
4258 | 67 | { | 56 | |
4259 | 68 | GObjectClass *object_class = reinterpret_cast<GObjectClass *>(klass); | 57 | |
4260 | 69 | GtkWidgetClass *widget_class = reinterpret_cast<GtkWidgetClass *>(klass); | 58 | ColorNotebook::ColorNotebook(SelectedColor &color) |
4261 | 70 | 59 | #if GTK_CHECK_VERSION(3, 0, 0) | |
4262 | 71 | object_class->dispose = sp_color_notebook_dispose; | 60 | : Gtk::Grid() |
4263 | 72 | 61 | #else | |
4264 | 73 | widget_class->show_all = sp_color_notebook_show_all; | 62 | : Gtk::Table(2, 3, false) |
4265 | 74 | widget_class->hide = sp_color_notebook_hide; | 63 | #endif |
4266 | 75 | } | 64 | , _selected_color(color) |
4267 | 76 | 65 | ||
4268 | 77 | static void | 66 | { |
4269 | 78 | sp_color_notebook_switch_page(GtkNotebook *notebook, | 67 | Page *page; |
4270 | 79 | GtkWidget *page, | 68 | |
4271 | 80 | guint page_num, | 69 | page = new Page(new ColorScalesFactory(SP_COLOR_SCALES_MODE_RGB), true); |
4272 | 81 | SPColorNotebook *colorbook) | 70 | _available_pages.push_back(page); |
4273 | 82 | { | 71 | page = new Page(new ColorScalesFactory(SP_COLOR_SCALES_MODE_HSV), true); |
4274 | 83 | if ( colorbook ) | 72 | _available_pages.push_back(page); |
4275 | 84 | { | 73 | page = new Page(new ColorScalesFactory(SP_COLOR_SCALES_MODE_CMYK), true); |
4276 | 85 | ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base); | 74 | _available_pages.push_back(page); |
4277 | 86 | nb->switchPage( notebook, page, page_num ); | 75 | page = new Page(new ColorWheelSelectorFactory, true); |
4278 | 87 | 76 | _available_pages.push_back(page); | |
4279 | 88 | // remember the page we switched to | 77 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
4280 | 89 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 78 | page = new Page(new ColorICCSelectorFactory, true); |
4281 | 90 | prefs->setInt("/colorselector/page", page_num); | 79 | _available_pages.push_back(page); |
4282 | 91 | } | 80 | #endif |
4283 | 92 | } | 81 | |
4284 | 93 | 82 | _initUI(); | |
4285 | 94 | void ColorNotebook::switchPage(GtkNotebook*, | 83 | |
4286 | 95 | GtkWidget*, | 84 | _selected_color.signal_changed.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorChanged)); |
4287 | 96 | guint page_num) | 85 | _selected_color.signal_dragged.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorChanged)); |
4288 | 97 | { | 86 | } |
4289 | 98 | SPColorSelector* csel; | 87 | |
4290 | 99 | GtkWidget* widget; | 88 | ColorNotebook::~ColorNotebook() |
4291 | 100 | 89 | { | |
4292 | 101 | if ( gtk_notebook_get_current_page (GTK_NOTEBOOK (_book)) >= 0 ) | 90 | if (_buttons) { |
4293 | 102 | { | 91 | delete[] _buttons; |
4294 | 103 | csel = getCurrentSelector(); | 92 | _buttons = 0; |
4295 | 104 | csel->base->getColorAlpha(_color, _alpha); | 93 | } |
4296 | 105 | } | 94 | } |
4297 | 106 | widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (_book), page_num); | 95 | |
4298 | 107 | if ( widget && SP_IS_COLOR_SELECTOR(widget) ) | 96 | ColorNotebook::Page::Page(Inkscape::UI::ColorSelectorFactory *selector_factory, bool enabled_full) |
4299 | 108 | { | 97 | : selector_factory(selector_factory) |
4300 | 109 | csel = SP_COLOR_SELECTOR (widget); | 98 | , enabled_full(enabled_full) |
4301 | 110 | csel->base->setColorAlpha( _color, _alpha ); | 99 | { |
4302 | 111 | 100 | } | |
4303 | 112 | // Temporary workaround to undo a spurious GRABBED | 101 | |
4304 | 113 | _released(); | 102 | |
4305 | 114 | } | 103 | void ColorNotebook::_initUI() |
4200 | 115 | } | ||
4201 | 116 | |||
4202 | 117 | static gint sp_color_notebook_menu_handler( GtkWidget *widget, GdkEvent *event ) | ||
4203 | 118 | { | ||
4204 | 119 | if (event->type == GDK_BUTTON_PRESS) | ||
4205 | 120 | { | ||
4206 | 121 | SPColorSelector* csel = SP_COLOR_SELECTOR(widget); | ||
4207 | 122 | (dynamic_cast<ColorNotebook*>(csel->base))->menuHandler( event ); | ||
4208 | 123 | |||
4209 | 124 | /* Tell calling code that we have handled this event; the buck | ||
4210 | 125 | * stops here. */ | ||
4211 | 126 | return TRUE; | ||
4212 | 127 | } | ||
4213 | 128 | |||
4214 | 129 | /* Tell calling code that we have not handled this event; pass it on. */ | ||
4215 | 130 | return FALSE; | ||
4216 | 131 | } | ||
4217 | 132 | |||
4218 | 133 | gint ColorNotebook::menuHandler( GdkEvent* event ) | ||
4219 | 134 | { | ||
4220 | 135 | GdkEventButton *bevent = (GdkEventButton *) event; | ||
4221 | 136 | gtk_menu_popup (GTK_MENU( _popup ), NULL, NULL, NULL, NULL, | ||
4222 | 137 | bevent->button, bevent->time); | ||
4223 | 138 | return TRUE; | ||
4224 | 139 | } | ||
4225 | 140 | |||
4226 | 141 | static void sp_color_notebook_menuitem_response (GtkMenuItem *menuitem, gpointer user_data) | ||
4227 | 142 | { | ||
4228 | 143 | gboolean active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)); | ||
4229 | 144 | SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (user_data); | ||
4230 | 145 | if ( entry ) | ||
4231 | 146 | { | ||
4232 | 147 | if ( active ) | ||
4233 | 148 | { | ||
4234 | 149 | (dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(entry->backPointer)->base))->addPage(entry->type, entry->submode); | ||
4235 | 150 | } | ||
4236 | 151 | else | ||
4237 | 152 | { | ||
4238 | 153 | (dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(entry->backPointer)->base))->removePage(entry->type, entry->submode); | ||
4239 | 154 | } | ||
4240 | 155 | } | ||
4241 | 156 | } | ||
4242 | 157 | |||
4243 | 158 | static void | ||
4244 | 159 | sp_color_notebook_init (SPColorNotebook *colorbook) | ||
4245 | 160 | { | ||
4246 | 161 | SP_COLOR_SELECTOR(colorbook)->base = new ColorNotebook( SP_COLOR_SELECTOR(colorbook) ); | ||
4247 | 162 | |||
4248 | 163 | if ( SP_COLOR_SELECTOR(colorbook)->base ) | ||
4249 | 164 | { | ||
4250 | 165 | SP_COLOR_SELECTOR(colorbook)->base->init(); | ||
4251 | 166 | } | ||
4252 | 167 | } | ||
4253 | 168 | |||
4254 | 169 | void ColorNotebook::init() | ||
4306 | 170 | { | 104 | { |
4307 | 171 | guint row = 0; | 105 | guint row = 0; |
4371 | 172 | guint i = 0; | 106 | |
4372 | 173 | guint j = 0; | 107 | Gtk::Notebook *notebook = Gtk::manage(new Gtk::Notebook); |
4373 | 174 | GType *selector_types = 0; | 108 | notebook->show(); |
4374 | 175 | guint selector_type_count = 0; | 109 | notebook->set_show_border(false); |
4375 | 176 | 110 | notebook->set_show_tabs(false); | |
4376 | 177 | /* tempory hardcoding to get types loaded */ | 111 | _book = GTK_WIDGET(notebook->gobj()); |
4377 | 178 | SP_TYPE_COLOR_SCALES; | 112 | |
4378 | 179 | SP_TYPE_COLOR_WHEEL_SELECTOR; | 113 | #if GTK_CHECK_VERSION(3, 0, 0) |
4316 | 180 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
4317 | 181 | SP_TYPE_COLOR_ICC_SELECTOR; | ||
4318 | 182 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | ||
4319 | 183 | |||
4320 | 184 | /* REJON: Comment out the next line to not use the normal GTK Color | ||
4321 | 185 | wheel. */ | ||
4322 | 186 | |||
4323 | 187 | // SP_TYPE_COLOR_GTKSELECTOR; | ||
4324 | 188 | |||
4325 | 189 | _updating = FALSE; | ||
4326 | 190 | _updatingrgba = FALSE; | ||
4327 | 191 | _btn = 0; | ||
4328 | 192 | _popup = 0; | ||
4329 | 193 | _trackerList = g_ptr_array_new (); | ||
4330 | 194 | |||
4331 | 195 | _book = gtk_notebook_new (); | ||
4332 | 196 | gtk_widget_show (_book); | ||
4333 | 197 | |||
4334 | 198 | // Dont show the notebook tabs, use radiobuttons instead | ||
4335 | 199 | gtk_notebook_set_show_border (GTK_NOTEBOOK (_book), false); | ||
4336 | 200 | gtk_notebook_set_show_tabs (GTK_NOTEBOOK (_book), false); | ||
4337 | 201 | |||
4338 | 202 | selector_types = g_type_children (SP_TYPE_COLOR_SELECTOR, &selector_type_count); | ||
4339 | 203 | |||
4340 | 204 | for ( i = 0; i < selector_type_count; i++ ) | ||
4341 | 205 | { | ||
4342 | 206 | if (!g_type_is_a (selector_types[i], SP_TYPE_COLOR_NOTEBOOK)) | ||
4343 | 207 | { | ||
4344 | 208 | guint howmany = 1; | ||
4345 | 209 | gpointer klass = g_type_class_ref (selector_types[i]); | ||
4346 | 210 | if ( klass && SP_IS_COLOR_SELECTOR_CLASS(klass) ) | ||
4347 | 211 | { | ||
4348 | 212 | SPColorSelectorClass *ck = SP_COLOR_SELECTOR_CLASS (klass); | ||
4349 | 213 | howmany = MAX (1, ck->submode_count); | ||
4350 | 214 | for ( j = 0; j < howmany; j++ ) | ||
4351 | 215 | { | ||
4352 | 216 | SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (malloc(sizeof(SPColorNotebookTracker))); | ||
4353 | 217 | if ( entry ) | ||
4354 | 218 | { | ||
4355 | 219 | memset( entry, 0, sizeof(SPColorNotebookTracker) ); | ||
4356 | 220 | entry->name = ck->name[j]; | ||
4357 | 221 | entry->type = selector_types[i]; | ||
4358 | 222 | entry->submode = j; | ||
4359 | 223 | entry->enabledFull = TRUE; | ||
4360 | 224 | entry->enabledBrief = TRUE; | ||
4361 | 225 | entry->backPointer = SP_COLOR_NOTEBOOK(_csel); | ||
4362 | 226 | |||
4363 | 227 | g_ptr_array_add (_trackerList, entry); | ||
4364 | 228 | } | ||
4365 | 229 | } | ||
4366 | 230 | } | ||
4367 | 231 | } | ||
4368 | 232 | } | ||
4369 | 233 | |||
4370 | 234 | #if GTK_CHECK_VERSION(3,0,0) | ||
4379 | 235 | _buttonbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); | 114 | _buttonbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); |
4380 | 236 | gtk_box_set_homogeneous(GTK_BOX(_buttonbox), TRUE); | 115 | gtk_box_set_homogeneous(GTK_BOX(_buttonbox), TRUE); |
4381 | 237 | #else | 116 | #else |
4383 | 238 | _buttonbox = gtk_hbox_new (TRUE, 2); | 117 | _buttonbox = gtk_hbox_new(TRUE, 2); |
4384 | 239 | #endif | 118 | #endif |
4385 | 240 | 119 | ||
4388 | 241 | gtk_widget_show (_buttonbox); | 120 | gtk_widget_show(_buttonbox); |
4389 | 242 | _buttons = new GtkWidget *[_trackerList->len]; | 121 | _buttons = new GtkWidget *[_available_pages.size()]; |
4390 | 243 | 122 | ||
4399 | 244 | for ( i = 0; i < _trackerList->len; i++ ) | 123 | for (int i = 0; static_cast<size_t>(i) < _available_pages.size(); i++) { |
4400 | 245 | { | 124 | _addPage(_available_pages[i]); |
4393 | 246 | SPColorNotebookTracker *entry = | ||
4394 | 247 | reinterpret_cast< SPColorNotebookTracker* > (g_ptr_array_index (_trackerList, i)); | ||
4395 | 248 | if ( entry ) | ||
4396 | 249 | { | ||
4397 | 250 | addPage(entry->type, entry->submode); | ||
4398 | 251 | } | ||
4401 | 252 | } | 125 | } |
4402 | 253 | 126 | ||
4417 | 254 | #if GTK_CHECK_VERSION(3,0,0) | 127 | sp_set_font_size_smaller(_buttonbox); |
4418 | 255 | GtkWidget* table = gtk_grid_new(); | 128 | |
4419 | 256 | #else | 129 | #if GTK_CHECK_VERSION(3, 0, 0) |
4420 | 257 | GtkWidget* table = gtk_table_new(2, 3, FALSE); | 130 | #if GTK_CHECK_VERSION(3, 12, 0) |
4407 | 258 | #endif | ||
4408 | 259 | |||
4409 | 260 | gtk_widget_show (table); | ||
4410 | 261 | |||
4411 | 262 | gtk_box_pack_start (GTK_BOX (_csel), table, TRUE, TRUE, 0); | ||
4412 | 263 | |||
4413 | 264 | sp_set_font_size_smaller (_buttonbox); | ||
4414 | 265 | |||
4415 | 266 | #if GTK_CHECK_VERSION(3,0,0) | ||
4416 | 267 | #if GTK_CHECK_VERSION(3,12,0) | ||
4421 | 268 | gtk_widget_set_margin_start(_buttonbox, XPAD); | 131 | gtk_widget_set_margin_start(_buttonbox, XPAD); |
4422 | 269 | gtk_widget_set_margin_end(_buttonbox, XPAD); | 132 | gtk_widget_set_margin_end(_buttonbox, XPAD); |
4424 | 270 | #else | 133 | #else |
4425 | 271 | gtk_widget_set_margin_left(_buttonbox, XPAD); | 134 | gtk_widget_set_margin_left(_buttonbox, XPAD); |
4426 | 272 | gtk_widget_set_margin_right(_buttonbox, XPAD); | 135 | gtk_widget_set_margin_right(_buttonbox, XPAD); |
4428 | 273 | #endif | 136 | #endif |
4429 | 274 | gtk_widget_set_margin_top(_buttonbox, YPAD); | 137 | gtk_widget_set_margin_top(_buttonbox, YPAD); |
4430 | 275 | gtk_widget_set_margin_bottom(_buttonbox, YPAD); | 138 | gtk_widget_set_margin_bottom(_buttonbox, YPAD); |
4431 | 276 | gtk_widget_set_hexpand(_buttonbox, TRUE); | 139 | gtk_widget_set_hexpand(_buttonbox, TRUE); |
4432 | 277 | gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER); | 140 | gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER); |
4434 | 278 | gtk_grid_attach(GTK_GRID(table), _buttonbox, 0, row, 2, 1); | 141 | attach(*Glib::wrap(_buttonbox), 0, row, 2, 1); |
4435 | 279 | #else | 142 | #else |
4440 | 280 | gtk_table_attach (GTK_TABLE (table), _buttonbox, 0, 2, row, row + 1, | 143 | attach(*Glib::wrap(_buttonbox), 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, static_cast<Gtk::AttachOptions>(0), |
4441 | 281 | static_cast<GtkAttachOptions>(GTK_EXPAND|GTK_FILL), | 144 | XPAD, YPAD); |
4438 | 282 | static_cast<GtkAttachOptions>(0), | ||
4439 | 283 | XPAD, YPAD); | ||
4442 | 284 | #endif | 145 | #endif |
4443 | 285 | 146 | ||
4444 | 286 | row++; | 147 | row++; |
4445 | 287 | 148 | ||
4454 | 288 | #if GTK_CHECK_VERSION(3,0,0) | 149 | #if GTK_CHECK_VERSION(3, 0, 0) |
4455 | 289 | #if GTK_CHECK_VERSION(3,12,0) | 150 | #if GTK_CHECK_VERSION(3, 12, 0) |
4456 | 290 | gtk_widget_set_margin_start(_book, XPAD*2); | 151 | gtk_widget_set_margin_start(_book, XPAD * 2); |
4457 | 291 | gtk_widget_set_margin_end(_book, XPAD*2); | 152 | gtk_widget_set_margin_end(_book, XPAD * 2); |
4458 | 292 | #else | 153 | #else |
4459 | 293 | gtk_widget_set_margin_left(_book, XPAD*2); | 154 | gtk_widget_set_margin_left(_book, XPAD * 2); |
4460 | 294 | gtk_widget_set_margin_right(_book, XPAD*2); | 155 | gtk_widget_set_margin_right(_book, XPAD * 2); |
4461 | 295 | #endif | 156 | #endif |
4462 | 296 | gtk_widget_set_margin_top(_book, YPAD); | 157 | gtk_widget_set_margin_top(_book, YPAD); |
4463 | 297 | gtk_widget_set_margin_bottom(_book, YPAD); | 158 | gtk_widget_set_margin_bottom(_book, YPAD); |
4464 | 298 | gtk_widget_set_hexpand(_book, TRUE); | 159 | gtk_widget_set_hexpand(_book, TRUE); |
4465 | 299 | gtk_widget_set_vexpand(_book, TRUE); | 160 | gtk_widget_set_vexpand(_book, TRUE); |
4467 | 300 | gtk_grid_attach(GTK_GRID(table), _book, 0, row, 2, 1); | 161 | attach(*notebook, 0, row, 2, 1); |
4468 | 301 | #else | 162 | #else |
4473 | 302 | gtk_table_attach (GTK_TABLE (table), _book, 0, 2, row, row + 1, | 163 | attach(*notebook, 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, XPAD * 2, YPAD); |
4470 | 303 | static_cast<GtkAttachOptions>(GTK_EXPAND|GTK_FILL), | ||
4471 | 304 | static_cast<GtkAttachOptions>(GTK_EXPAND|GTK_FILL), | ||
4472 | 305 | XPAD*2, YPAD); | ||
4474 | 306 | #endif | 164 | #endif |
4475 | 307 | 165 | ||
4476 | 308 | // restore the last active page | 166 | // restore the last active page |
4477 | 309 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 167 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
4478 | 310 | _setCurrentPage(prefs->getInt("/colorselector/page", 0)); | 168 | _setCurrentPage(prefs->getInt("/colorselector/page", 0)); |
4479 | 311 | |||
4480 | 312 | { | ||
4481 | 313 | gboolean found = FALSE; | ||
4482 | 314 | |||
4483 | 315 | _popup = gtk_menu_new(); | ||
4484 | 316 | GtkMenu *menu = GTK_MENU (_popup); | ||
4485 | 317 | |||
4486 | 318 | for ( i = 0; i < _trackerList->len; i++ ) | ||
4487 | 319 | { | ||
4488 | 320 | SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (g_ptr_array_index (_trackerList, i)); | ||
4489 | 321 | if ( entry ) | ||
4490 | 322 | { | ||
4491 | 323 | GtkWidget *item = gtk_check_menu_item_new_with_label (_(entry->name)); | ||
4492 | 324 | gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), entry->enabledFull); | ||
4493 | 325 | gtk_widget_show (item); | ||
4494 | 326 | gtk_menu_shell_append (GTK_MENU_SHELL(menu), item); | ||
4495 | 327 | |||
4496 | 328 | g_signal_connect (G_OBJECT (item), "activate", | ||
4497 | 329 | G_CALLBACK (sp_color_notebook_menuitem_response), | ||
4498 | 330 | reinterpret_cast< gpointer > (entry) ); | ||
4499 | 331 | found = TRUE; | ||
4500 | 332 | } | ||
4501 | 333 | } | ||
4502 | 334 | |||
4503 | 335 | GtkWidget *arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); | ||
4504 | 336 | gtk_widget_show (arrow); | ||
4505 | 337 | |||
4506 | 338 | _btn = gtk_button_new (); | ||
4507 | 339 | gtk_widget_show (_btn); | ||
4508 | 340 | gtk_container_add (GTK_CONTAINER (_btn), arrow); | ||
4509 | 341 | |||
4510 | 342 | GtkWidget *align = gtk_alignment_new (1.0, 0.0, 0.0, 0.0); | ||
4511 | 343 | gtk_widget_show (align); | ||
4512 | 344 | gtk_container_add (GTK_CONTAINER (align), _btn); | ||
4513 | 345 | |||
4514 | 346 | // uncomment to reenable the "show/hide modes" menu, | ||
4515 | 347 | // but first fix it so it remembers its settings in prefs and does not take that much space (entire vertical column!) | ||
4516 | 348 | //gtk_table_attach (GTK_TABLE (table), align, 2, 3, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); | ||
4517 | 349 | |||
4518 | 350 | g_signal_connect_swapped(G_OBJECT(_btn), "event", G_CALLBACK (sp_color_notebook_menu_handler), G_OBJECT(_csel)); | ||
4519 | 351 | if ( !found ) | ||
4520 | 352 | { | ||
4521 | 353 | gtk_widget_set_sensitive (_btn, FALSE); | ||
4522 | 354 | } | ||
4523 | 355 | } | ||
4524 | 356 | |||
4525 | 357 | row++; | 169 | row++; |
4526 | 358 | 170 | ||
4528 | 359 | #if GTK_CHECK_VERSION(3,0,0) | 171 | #if GTK_CHECK_VERSION(3, 0, 0) |
4529 | 360 | GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | 172 | GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); |
4530 | 361 | #else | 173 | #else |
4532 | 362 | GtkWidget *rgbabox = gtk_hbox_new (FALSE, 0); | 174 | GtkWidget *rgbabox = gtk_hbox_new(FALSE, 0); |
4533 | 363 | #endif | 175 | #endif |
4534 | 364 | 176 | ||
4535 | 365 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 177 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
4536 | 366 | /* Create color management icons */ | 178 | /* Create color management icons */ |
4542 | 367 | _box_colormanaged = gtk_event_box_new (); | 179 | _box_colormanaged = gtk_event_box_new(); |
4543 | 368 | GtkWidget *colormanaged = gtk_image_new_from_icon_name ("color-management-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); | 180 | GtkWidget *colormanaged = gtk_image_new_from_icon_name("color-management-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); |
4544 | 369 | gtk_container_add (GTK_CONTAINER (_box_colormanaged), colormanaged); | 181 | gtk_container_add(GTK_CONTAINER(_box_colormanaged), colormanaged); |
4545 | 370 | gtk_widget_set_tooltip_text (_box_colormanaged, _("Color Managed")); | 182 | gtk_widget_set_tooltip_text(_box_colormanaged, _("Color Managed")); |
4546 | 371 | gtk_widget_set_sensitive (_box_colormanaged, false); | 183 | gtk_widget_set_sensitive(_box_colormanaged, false); |
4547 | 372 | gtk_box_pack_start(GTK_BOX(rgbabox), _box_colormanaged, FALSE, FALSE, 2); | 184 | gtk_box_pack_start(GTK_BOX(rgbabox), _box_colormanaged, FALSE, FALSE, 2); |
4548 | 373 | 185 | ||
4554 | 374 | _box_outofgamut = gtk_event_box_new (); | 186 | _box_outofgamut = gtk_event_box_new(); |
4555 | 375 | GtkWidget *outofgamut = gtk_image_new_from_icon_name ("out-of-gamut-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); | 187 | GtkWidget *outofgamut = gtk_image_new_from_icon_name("out-of-gamut-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); |
4556 | 376 | gtk_container_add (GTK_CONTAINER (_box_outofgamut), outofgamut); | 188 | gtk_container_add(GTK_CONTAINER(_box_outofgamut), outofgamut); |
4557 | 377 | gtk_widget_set_tooltip_text (_box_outofgamut, _("Out of gamut!")); | 189 | gtk_widget_set_tooltip_text(_box_outofgamut, _("Out of gamut!")); |
4558 | 378 | gtk_widget_set_sensitive (_box_outofgamut, false); | 190 | gtk_widget_set_sensitive(_box_outofgamut, false); |
4559 | 379 | gtk_box_pack_start(GTK_BOX(rgbabox), _box_outofgamut, FALSE, FALSE, 2); | 191 | gtk_box_pack_start(GTK_BOX(rgbabox), _box_outofgamut, FALSE, FALSE, 2); |
4560 | 380 | 192 | ||
4566 | 381 | _box_toomuchink = gtk_event_box_new (); | 193 | _box_toomuchink = gtk_event_box_new(); |
4567 | 382 | GtkWidget *toomuchink = gtk_image_new_from_icon_name ("too-much-ink-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); | 194 | GtkWidget *toomuchink = gtk_image_new_from_icon_name("too-much-ink-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); |
4568 | 383 | gtk_container_add (GTK_CONTAINER (_box_toomuchink), toomuchink); | 195 | gtk_container_add(GTK_CONTAINER(_box_toomuchink), toomuchink); |
4569 | 384 | gtk_widget_set_tooltip_text (_box_toomuchink, _("Too much ink!")); | 196 | gtk_widget_set_tooltip_text(_box_toomuchink, _("Too much ink!")); |
4570 | 385 | gtk_widget_set_sensitive (_box_toomuchink, false); | 197 | gtk_widget_set_sensitive(_box_toomuchink, false); |
4571 | 386 | gtk_box_pack_start(GTK_BOX(rgbabox), _box_toomuchink, FALSE, FALSE, 2); | 198 | gtk_box_pack_start(GTK_BOX(rgbabox), _box_toomuchink, FALSE, FALSE, 2); |
4573 | 387 | #endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 199 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
4574 | 388 | 200 | ||
4575 | 389 | 201 | ||
4576 | 390 | /* Color picker */ | 202 | /* Color picker */ |
4579 | 391 | GtkWidget *picker = gtk_image_new_from_icon_name ("color-picker", GTK_ICON_SIZE_SMALL_TOOLBAR); | 203 | GtkWidget *picker = gtk_image_new_from_icon_name("color-picker", GTK_ICON_SIZE_SMALL_TOOLBAR); |
4580 | 392 | _btn_picker = gtk_button_new (); | 204 | _btn_picker = gtk_button_new(); |
4581 | 393 | gtk_button_set_relief(GTK_BUTTON(_btn_picker), GTK_RELIEF_NONE); | 205 | gtk_button_set_relief(GTK_BUTTON(_btn_picker), GTK_RELIEF_NONE); |
4585 | 394 | gtk_widget_show (_btn); | 206 | gtk_container_add(GTK_CONTAINER(_btn_picker), picker); |
4586 | 395 | gtk_container_add (GTK_CONTAINER (_btn_picker), picker); | 207 | gtk_widget_set_tooltip_text(_btn_picker, _("Pick colors from image")); |
4584 | 396 | gtk_widget_set_tooltip_text (_btn_picker, _("Pick colors from image")); | ||
4587 | 397 | gtk_box_pack_start(GTK_BOX(rgbabox), _btn_picker, FALSE, FALSE, 2); | 208 | gtk_box_pack_start(GTK_BOX(rgbabox), _btn_picker, FALSE, FALSE, 2); |
4589 | 398 | g_signal_connect(G_OBJECT(_btn_picker), "clicked", G_CALLBACK(ColorNotebook::_picker_clicked), _csel); | 209 | g_signal_connect(G_OBJECT(_btn_picker), "clicked", G_CALLBACK(ColorNotebook::_onPickerClicked), this); |
4590 | 399 | 210 | ||
4591 | 400 | /* Create RGBA entry and color preview */ | 211 | /* Create RGBA entry and color preview */ |
4594 | 401 | _rgbal = gtk_label_new_with_mnemonic (_("RGBA_:")); | 212 | _rgbal = gtk_label_new_with_mnemonic(_("RGBA_:")); |
4595 | 402 | gtk_misc_set_alignment (GTK_MISC (_rgbal), 1.0, 0.5); | 213 | gtk_misc_set_alignment(GTK_MISC(_rgbal), 1.0, 0.5); |
4596 | 403 | gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2); | 214 | gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2); |
4597 | 404 | 215 | ||
4605 | 405 | _rgbae = gtk_entry_new (); | 216 | ColorEntry *rgba_entry = Gtk::manage(new ColorEntry(_selected_color)); |
4606 | 406 | sp_dialog_defocus_on_enter (_rgbae); | 217 | sp_dialog_defocus_on_enter(GTK_WIDGET(rgba_entry->gobj())); |
4607 | 407 | gtk_entry_set_max_length (GTK_ENTRY (_rgbae), 8); | 218 | gtk_box_pack_start(GTK_BOX(rgbabox), GTK_WIDGET(rgba_entry->gobj()), FALSE, FALSE, 0); |
4608 | 408 | gtk_entry_set_width_chars (GTK_ENTRY (_rgbae), 8); | 219 | gtk_label_set_mnemonic_widget(GTK_LABEL(_rgbal), GTK_WIDGET(rgba_entry->gobj())); |
4602 | 409 | gtk_widget_set_tooltip_text (_rgbae, _("Hexadecimal RGBA value of the color")); | ||
4603 | 410 | gtk_box_pack_start(GTK_BOX(rgbabox), _rgbae, FALSE, FALSE, 0); | ||
4604 | 411 | gtk_label_set_mnemonic_widget (GTK_LABEL(_rgbal), _rgbae); | ||
4609 | 412 | 220 | ||
4612 | 413 | sp_set_font_size_smaller (rgbabox); | 221 | sp_set_font_size_smaller(rgbabox); |
4613 | 414 | gtk_widget_show_all (rgbabox); | 222 | gtk_widget_show_all(rgbabox); |
4614 | 415 | 223 | ||
4615 | 416 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 224 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
4617 | 417 | //the "too much ink" icon is initially hidden | 225 | // the "too much ink" icon is initially hidden |
4618 | 418 | gtk_widget_hide(GTK_WIDGET(_box_toomuchink)); | 226 | gtk_widget_hide(GTK_WIDGET(_box_toomuchink)); |
4620 | 419 | #endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 227 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
4621 | 420 | 228 | ||
4624 | 421 | #if GTK_CHECK_VERSION(3,0,0) | 229 | #if GTK_CHECK_VERSION(3, 0, 0) |
4625 | 422 | #if GTK_CHECK_VERSION(3,12,0) | 230 | #if GTK_CHECK_VERSION(3, 12, 0) |
4626 | 423 | gtk_widget_set_margin_start(rgbabox, XPAD); | 231 | gtk_widget_set_margin_start(rgbabox, XPAD); |
4627 | 424 | gtk_widget_set_margin_end(rgbabox, XPAD); | 232 | gtk_widget_set_margin_end(rgbabox, XPAD); |
4629 | 425 | #else | 233 | #else |
4630 | 426 | gtk_widget_set_margin_left(rgbabox, XPAD); | 234 | gtk_widget_set_margin_left(rgbabox, XPAD); |
4631 | 427 | gtk_widget_set_margin_right(rgbabox, XPAD); | 235 | gtk_widget_set_margin_right(rgbabox, XPAD); |
4633 | 428 | #endif | 236 | #endif |
4634 | 429 | gtk_widget_set_margin_top(rgbabox, YPAD); | 237 | gtk_widget_set_margin_top(rgbabox, YPAD); |
4635 | 430 | gtk_widget_set_margin_bottom(rgbabox, YPAD); | 238 | gtk_widget_set_margin_bottom(rgbabox, YPAD); |
4637 | 431 | gtk_grid_attach(GTK_GRID(table), rgbabox, 0, row, 2, 1); | 239 | attach(*Glib::wrap(rgbabox), 0, row, 2, 1); |
4638 | 432 | #else | 240 | #else |
4640 | 433 | gtk_table_attach (GTK_TABLE (table), rgbabox, 0, 2, row, row + 1, GTK_FILL, GTK_SHRINK, XPAD, YPAD); | 241 | attach(*Glib::wrap(rgbabox), 0, 2, row, row + 1, Gtk::FILL, Gtk::SHRINK, XPAD, YPAD); |
4641 | 434 | #endif | 242 | #endif |
4642 | 435 | 243 | ||
4643 | 436 | #ifdef SPCS_PREVIEW | 244 | #ifdef SPCS_PREVIEW |
4647 | 437 | _p = sp_color_preview_new (0xffffffff); | 245 | _p = sp_color_preview_new(0xffffffff); |
4648 | 438 | gtk_widget_show (_p); | 246 | gtk_widget_show(_p); |
4649 | 439 | gtk_table_attach (GTK_TABLE (table), _p, 2, 3, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); | 247 | attach(*Glib::wrap(_p), 2, 3, row, row + 1, Gtk::FILL, Gtk::FILL, XPAD, YPAD); |
4650 | 440 | #endif | 248 | #endif |
4651 | 441 | 249 | ||
4741 | 442 | _switchId = g_signal_connect(G_OBJECT (_book), "switch-page", | 250 | g_signal_connect(G_OBJECT(_book), "switch-page", G_CALLBACK(ColorNotebook::_onPageSwitched), this); |
4742 | 443 | G_CALLBACK (sp_color_notebook_switch_page), SP_COLOR_NOTEBOOK(_csel)); | 251 | } |
4743 | 444 | 252 | ||
4744 | 445 | _entryId = g_signal_connect (G_OBJECT (_rgbae), "changed", G_CALLBACK (ColorNotebook::_rgbaEntryChangedHook), _csel); | 253 | void ColorNotebook::_onPickerClicked(GtkWidget * /*widget*/, ColorNotebook * /*colorbook*/) |
4656 | 446 | } | ||
4657 | 447 | |||
4658 | 448 | static void sp_color_notebook_dispose(GObject *object) | ||
4659 | 449 | { | ||
4660 | 450 | if (G_OBJECT_CLASS(sp_color_notebook_parent_class)->dispose) | ||
4661 | 451 | G_OBJECT_CLASS(sp_color_notebook_parent_class)->dispose(object); | ||
4662 | 452 | } | ||
4663 | 453 | |||
4664 | 454 | ColorNotebook::~ColorNotebook() | ||
4665 | 455 | { | ||
4666 | 456 | if ( _trackerList ) | ||
4667 | 457 | { | ||
4668 | 458 | g_ptr_array_free (_trackerList, TRUE); | ||
4669 | 459 | _trackerList = 0; | ||
4670 | 460 | } | ||
4671 | 461 | |||
4672 | 462 | if ( _switchId ) | ||
4673 | 463 | { | ||
4674 | 464 | if ( _book ) | ||
4675 | 465 | { | ||
4676 | 466 | g_signal_handler_disconnect (_book, _switchId); | ||
4677 | 467 | _switchId = 0; | ||
4678 | 468 | } | ||
4679 | 469 | } | ||
4680 | 470 | |||
4681 | 471 | if ( _buttons ) | ||
4682 | 472 | { | ||
4683 | 473 | delete [] _buttons; | ||
4684 | 474 | _buttons = 0; | ||
4685 | 475 | } | ||
4686 | 476 | |||
4687 | 477 | } | ||
4688 | 478 | |||
4689 | 479 | static void | ||
4690 | 480 | sp_color_notebook_show_all (GtkWidget *widget) | ||
4691 | 481 | { | ||
4692 | 482 | gtk_widget_show (widget); | ||
4693 | 483 | } | ||
4694 | 484 | |||
4695 | 485 | static void sp_color_notebook_hide(GtkWidget *widget) | ||
4696 | 486 | { | ||
4697 | 487 | gtk_widget_hide(widget); | ||
4698 | 488 | } | ||
4699 | 489 | |||
4700 | 490 | GtkWidget *sp_color_notebook_new() | ||
4701 | 491 | { | ||
4702 | 492 | SPColorNotebook *colorbook = SP_COLOR_NOTEBOOK(g_object_new (SP_TYPE_COLOR_NOTEBOOK, NULL)); | ||
4703 | 493 | |||
4704 | 494 | return GTK_WIDGET(colorbook); | ||
4705 | 495 | } | ||
4706 | 496 | |||
4707 | 497 | ColorNotebook::ColorNotebook( SPColorSelector* csel ) | ||
4708 | 498 | : ColorSelector( csel ) | ||
4709 | 499 | { | ||
4710 | 500 | } | ||
4711 | 501 | |||
4712 | 502 | SPColorSelector* ColorNotebook::getCurrentSelector() | ||
4713 | 503 | { | ||
4714 | 504 | SPColorSelector* csel = NULL; | ||
4715 | 505 | gint current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (_book)); | ||
4716 | 506 | |||
4717 | 507 | if ( current_page >= 0 ) | ||
4718 | 508 | { | ||
4719 | 509 | GtkWidget* widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (_book), current_page); | ||
4720 | 510 | if ( SP_IS_COLOR_SELECTOR (widget) ) | ||
4721 | 511 | { | ||
4722 | 512 | csel = SP_COLOR_SELECTOR (widget); | ||
4723 | 513 | } | ||
4724 | 514 | } | ||
4725 | 515 | |||
4726 | 516 | return csel; | ||
4727 | 517 | } | ||
4728 | 518 | |||
4729 | 519 | void ColorNotebook::_colorChanged() | ||
4730 | 520 | { | ||
4731 | 521 | SPColorSelector* cselPage = getCurrentSelector(); | ||
4732 | 522 | if ( cselPage ) | ||
4733 | 523 | { | ||
4734 | 524 | cselPage->base->setColorAlpha( _color, _alpha ); | ||
4735 | 525 | } | ||
4736 | 526 | |||
4737 | 527 | _updateRgbaEntry( _color, _alpha ); | ||
4738 | 528 | } | ||
4739 | 529 | |||
4740 | 530 | void ColorNotebook::_picker_clicked(GtkWidget * /*widget*/, SPColorNotebook * /*colorbook*/) | ||
4745 | 531 | { | 254 | { |
4746 | 532 | // Set the dropper into a "one click" mode, so it reverts to the previous tool after a click | 255 | // Set the dropper into a "one click" mode, so it reverts to the previous tool after a click |
4747 | 533 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 256 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
4748 | @@ -535,283 +258,113 @@ | |||
4749 | 535 | Inkscape::UI::Tools::sp_toggle_dropper(SP_ACTIVE_DESKTOP); | 258 | Inkscape::UI::Tools::sp_toggle_dropper(SP_ACTIVE_DESKTOP); |
4750 | 536 | } | 259 | } |
4751 | 537 | 260 | ||
4797 | 538 | void ColorNotebook::_rgbaEntryChangedHook(GtkEntry *entry, SPColorNotebook *colorbook) | 261 | void ColorNotebook::_onButtonClicked(GtkWidget *widget, ColorNotebook *nb) |
4798 | 539 | { | 262 | { |
4799 | 540 | (dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base))->_rgbaEntryChanged( entry ); | 263 | if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { |
4800 | 541 | } | 264 | return; |
4801 | 542 | 265 | } | |
4802 | 543 | void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry) | 266 | |
4803 | 544 | { | 267 | for (gint i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(nb->_book)); i++) { |
4804 | 545 | if (_updating) return; | 268 | if (nb->_buttons[i] == widget) { |
4805 | 546 | if (_updatingrgba) return; | 269 | gtk_notebook_set_current_page(GTK_NOTEBOOK(nb->_book), i); |
4806 | 547 | 270 | } | |
4807 | 548 | const gchar *t = gtk_entry_get_text( entry ); | 271 | } |
4808 | 549 | 272 | } | |
4809 | 550 | if (t) { | 273 | |
4810 | 551 | Glib::ustring text = t; | 274 | void ColorNotebook::_onSelectedColorChanged() { _updateICCButtons(); } |
4811 | 552 | bool changed = false; | 275 | |
4812 | 553 | if (!text.empty() && text[0] == '#') { | 276 | void ColorNotebook::_onPageSwitched(GtkNotebook *notebook, GtkWidget *page, guint page_num, ColorNotebook *colorbook) |
4813 | 554 | changed = true; | 277 | { |
4814 | 555 | text.erase(0,1); | 278 | if (colorbook->get_visible()) { |
4815 | 556 | if (text.size() == 6) { | 279 | // remember the page we switched to |
4816 | 557 | // it was a standard RGB hex | 280 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
4817 | 558 | unsigned int alph = SP_COLOR_F_TO_U(_alpha); | 281 | prefs->setInt("/colorselector/page", page_num); |
4818 | 559 | gchar* tmp = g_strdup_printf("%02x", alph); | 282 | } |
4819 | 560 | text += tmp; | 283 | } |
4820 | 561 | g_free(tmp); | 284 | |
4776 | 562 | } | ||
4777 | 563 | } | ||
4778 | 564 | gchar* str = g_strdup(text.c_str()); | ||
4779 | 565 | gchar* end = 0; | ||
4780 | 566 | guint64 rgba = g_ascii_strtoull( str, &end, 16 ); | ||
4781 | 567 | if ( end != str ) { | ||
4782 | 568 | ptrdiff_t len = end - str; | ||
4783 | 569 | if ( len < 8 ) { | ||
4784 | 570 | rgba = rgba << ( 4 * ( 8 - len ) ); | ||
4785 | 571 | } | ||
4786 | 572 | _updatingrgba = TRUE; | ||
4787 | 573 | if ( changed ) { | ||
4788 | 574 | gtk_entry_set_text( entry, str ); | ||
4789 | 575 | } | ||
4790 | 576 | SPColor color( rgba ); | ||
4791 | 577 | setColorAlpha( color, SP_RGBA32_A_F(rgba), true ); | ||
4792 | 578 | _updatingrgba = FALSE; | ||
4793 | 579 | } | ||
4794 | 580 | g_free(str); | ||
4795 | 581 | } | ||
4796 | 582 | } | ||
4821 | 583 | 285 | ||
4822 | 584 | // TODO pass in param so as to avoid the need for SP_ACTIVE_DOCUMENT | 286 | // TODO pass in param so as to avoid the need for SP_ACTIVE_DOCUMENT |
4824 | 585 | void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) | 287 | void ColorNotebook::_updateICCButtons() |
4825 | 586 | { | 288 | { |
4827 | 587 | g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); | 289 | SPColor color = _selected_color.color(); |
4828 | 290 | gfloat alpha = _selected_color.alpha(); | ||
4829 | 291 | |||
4830 | 292 | g_return_if_fail((0.0 <= alpha) && (alpha <= 1.0)); | ||
4831 | 588 | 293 | ||
4832 | 589 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 294 | #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
4833 | 590 | /* update color management icon*/ | 295 | /* update color management icon*/ |
4835 | 591 | gtk_widget_set_sensitive (_box_colormanaged, color.icc != NULL); | 296 | gtk_widget_set_sensitive(_box_colormanaged, color.icc != NULL); |
4836 | 592 | 297 | ||
4837 | 593 | /* update out-of-gamut icon */ | 298 | /* update out-of-gamut icon */ |
4842 | 594 | gtk_widget_set_sensitive (_box_outofgamut, false); | 299 | gtk_widget_set_sensitive(_box_outofgamut, false); |
4843 | 595 | if (color.icc){ | 300 | if (color.icc) { |
4844 | 596 | Inkscape::ColorProfile* target_profile = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str()); | 301 | Inkscape::ColorProfile *target_profile = |
4845 | 597 | if ( target_profile ) | 302 | SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str()); |
4846 | 303 | if (target_profile) | ||
4847 | 598 | gtk_widget_set_sensitive(_box_outofgamut, target_profile->GamutCheck(color)); | 304 | gtk_widget_set_sensitive(_box_outofgamut, target_profile->GamutCheck(color)); |
4848 | 599 | } | 305 | } |
4849 | 600 | 306 | ||
4850 | 601 | /* update too-much-ink icon */ | 307 | /* update too-much-ink icon */ |
4855 | 602 | gtk_widget_set_sensitive (_box_toomuchink, false); | 308 | gtk_widget_set_sensitive(_box_toomuchink, false); |
4856 | 603 | if (color.icc){ | 309 | if (color.icc) { |
4857 | 604 | Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str()); | 310 | Inkscape::ColorProfile *prof = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str()); |
4858 | 605 | if ( prof && CMSSystem::isPrintColorSpace(prof) ) { | 311 | if (prof && CMSSystem::isPrintColorSpace(prof)) { |
4859 | 606 | gtk_widget_show(GTK_WIDGET(_box_toomuchink)); | 312 | gtk_widget_show(GTK_WIDGET(_box_toomuchink)); |
4860 | 607 | double ink_sum = 0; | 313 | double ink_sum = 0; |
4862 | 608 | for (unsigned int i=0; i<color.icc->colors.size(); i++){ | 314 | for (unsigned int i = 0; i < color.icc->colors.size(); i++) { |
4863 | 609 | ink_sum += color.icc->colors[i]; | 315 | ink_sum += color.icc->colors[i]; |
4864 | 610 | } | 316 | } |
4865 | 611 | 317 | ||
4868 | 612 | /* Some literature states that when the sum of paint values exceed 320%, it is considered to be a satured color, | 318 | /* Some literature states that when the sum of paint values exceed 320%, it is considered to be a satured |
4869 | 613 | which means the paper can get too wet due to an excessive ammount of ink. This may lead to several issues | 319 | color, |
4870 | 320 | which means the paper can get too wet due to an excessive ammount of ink. This may lead to several | ||
4871 | 321 | issues | ||
4872 | 614 | such as misalignment and poor quality of printing in general.*/ | 322 | such as misalignment and poor quality of printing in general.*/ |
4876 | 615 | if ( ink_sum > 3.2 ) | 323 | if (ink_sum > 3.2) |
4877 | 616 | gtk_widget_set_sensitive (_box_toomuchink, true); | 324 | gtk_widget_set_sensitive(_box_toomuchink, true); |
4878 | 617 | } else { | 325 | } |
4879 | 326 | else { | ||
4880 | 618 | gtk_widget_hide(GTK_WIDGET(_box_toomuchink)); | 327 | gtk_widget_hide(GTK_WIDGET(_box_toomuchink)); |
4881 | 619 | } | 328 | } |
4882 | 620 | } | 329 | } |
4902 | 621 | #endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 330 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
4884 | 622 | |||
4885 | 623 | if ( !_updatingrgba ) | ||
4886 | 624 | { | ||
4887 | 625 | gchar s[32]; | ||
4888 | 626 | guint32 rgba; | ||
4889 | 627 | |||
4890 | 628 | /* Update RGBA entry */ | ||
4891 | 629 | rgba = color.toRGBA32( alpha ); | ||
4892 | 630 | |||
4893 | 631 | g_snprintf (s, 32, "%08x", rgba); | ||
4894 | 632 | const gchar* oldText = gtk_entry_get_text( GTK_ENTRY( _rgbae ) ); | ||
4895 | 633 | if ( strcmp( oldText, s ) != 0 ) | ||
4896 | 634 | { | ||
4897 | 635 | g_signal_handler_block( _rgbae, _entryId ); | ||
4898 | 636 | gtk_entry_set_text( GTK_ENTRY(_rgbae), s ); | ||
4899 | 637 | g_signal_handler_unblock( _rgbae, _entryId ); | ||
4900 | 638 | } | ||
4901 | 639 | } | ||
4903 | 640 | } | 331 | } |
4904 | 641 | 332 | ||
4905 | 642 | void ColorNotebook::_setCurrentPage(int i) | 333 | void ColorNotebook::_setCurrentPage(int i) |
4906 | 643 | { | 334 | { |
4907 | 644 | gtk_notebook_set_current_page(GTK_NOTEBOOK(_book), i); | 335 | gtk_notebook_set_current_page(GTK_NOTEBOOK(_book), i); |
4908 | 645 | 336 | ||
4910 | 646 | if (_buttons && _trackerList && (static_cast<size_t>(i) < _trackerList->len) ) { | 337 | if (_buttons && (static_cast<size_t>(i) < _available_pages.size())) { |
4911 | 647 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_buttons[i]), TRUE); | 338 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_buttons[i]), TRUE); |
4912 | 648 | } | 339 | } |
4913 | 649 | } | 340 | } |
4914 | 650 | 341 | ||
4915 | 651 | void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorbook) | ||
4916 | 652 | { | ||
4917 | 653 | ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base); | ||
4918 | 654 | |||
4919 | 655 | if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) { | ||
4920 | 656 | return; | ||
4921 | 657 | } | ||
4922 | 658 | |||
4923 | 659 | for(gint i = 0; i < gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb->_book)); i++) { | ||
4924 | 660 | if (nb->_buttons[i] == widget) { | ||
4925 | 661 | gtk_notebook_set_current_page (GTK_NOTEBOOK (nb->_book), i); | ||
4926 | 662 | } | ||
4927 | 663 | } | ||
4928 | 664 | } | ||
4929 | 665 | |||
4930 | 666 | void ColorNotebook::_entryGrabbed (SPColorSelector *, SPColorNotebook *colorbook) | ||
4931 | 667 | { | ||
4932 | 668 | ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base); | ||
4933 | 669 | nb->_grabbed(); | ||
4934 | 670 | } | ||
4935 | 671 | |||
4936 | 672 | void ColorNotebook::_entryDragged (SPColorSelector *csel, SPColorNotebook *colorbook) | ||
4937 | 673 | { | ||
4938 | 674 | gboolean oldState; | ||
4939 | 675 | ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base); | ||
4940 | 676 | |||
4941 | 677 | oldState = nb->_dragging; | ||
4942 | 678 | |||
4943 | 679 | nb->_dragging = TRUE; | ||
4944 | 680 | nb->_entryModified( csel, colorbook ); | ||
4945 | 681 | |||
4946 | 682 | nb->_dragging = oldState; | ||
4947 | 683 | } | ||
4948 | 684 | |||
4949 | 685 | void ColorNotebook::_entryReleased (SPColorSelector *, SPColorNotebook *colorbook) | ||
4950 | 686 | { | ||
4951 | 687 | ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base); | ||
4952 | 688 | nb->_released(); | ||
4953 | 689 | } | ||
4954 | 690 | |||
4955 | 691 | void ColorNotebook::_entryChanged (SPColorSelector *csel, SPColorNotebook *colorbook) | ||
4956 | 692 | { | ||
4957 | 693 | gboolean oldState; | ||
4958 | 694 | ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base); | ||
4959 | 695 | |||
4960 | 696 | oldState = nb->_dragging; | ||
4961 | 697 | |||
4962 | 698 | nb->_dragging = FALSE; | ||
4963 | 699 | nb->_entryModified( csel, colorbook ); | ||
4964 | 700 | |||
4965 | 701 | nb->_dragging = oldState; | ||
4966 | 702 | } | ||
4967 | 703 | |||
4968 | 704 | void ColorNotebook::_entryModified (SPColorSelector *csel, SPColorNotebook *colorbook) | ||
4969 | 705 | { | ||
4970 | 706 | g_return_if_fail (colorbook != NULL); | ||
4971 | 707 | g_return_if_fail (SP_IS_COLOR_NOTEBOOK (colorbook)); | ||
4972 | 708 | g_return_if_fail (csel != NULL); | ||
4973 | 709 | g_return_if_fail (SP_IS_COLOR_SELECTOR (csel)); | ||
4974 | 710 | |||
4975 | 711 | ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base); | ||
4976 | 712 | SPColor color; | ||
4977 | 713 | gfloat alpha = 1.0; | ||
4978 | 714 | |||
4979 | 715 | csel->base->getColorAlpha( color, alpha ); | ||
4980 | 716 | nb->_updateRgbaEntry( color, alpha ); | ||
4981 | 717 | nb->_updateInternals( color, alpha, nb->_dragging ); | ||
4982 | 718 | } | ||
4983 | 719 | |||
4984 | 720 | GtkWidget* ColorNotebook::addPage(GType page_type, guint submode) | ||
4985 | 721 | { | ||
4986 | 722 | GtkWidget *page; | ||
4987 | 723 | |||
4988 | 724 | page = sp_color_selector_new( page_type ); | ||
4989 | 725 | if ( page ) | ||
4990 | 726 | { | ||
4991 | 727 | GtkWidget* tab_label = 0; | ||
4992 | 728 | SPColorSelector* csel; | ||
4993 | 729 | |||
4994 | 730 | csel = SP_COLOR_SELECTOR (page); | ||
4995 | 731 | if ( submode > 0 ) | ||
4996 | 732 | { | ||
4997 | 733 | csel->base->setSubmode( submode ); | ||
4998 | 734 | } | ||
4999 | 735 | gtk_widget_show (page); | ||
5000 | 736 | int index = csel->base ? csel->base->getSubmode() : 0; |
Mostly looks good. We reviewed the first 5000 lines (the view was truncated there). Saw a bunch of minor white space issues. Reviewed at hackfest.
We are really looking forward to getting this in for 0.92!