Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Dudev <emildudev@gmail.com>2013-12-17 05:59:35 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-12-19 22:05:57 (GMT)
commit71f9e51998155398abf94f0499bde6840a8e2d36 (patch)
tree713501638552c545f0748aadb7458e3806ce89a0
parentf6754ca59c4b6fbcf6f7b253ac845901452421f6 (diff)
Paint tools enhancement
When a tool is selected, show in the color palette, only the controls needed. Fixes #3603 Signed-off-by: Emil Dudev <emildudev@gmail.com> Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--toolbox.py41
-rw-r--r--widgets.py90
2 files changed, 92 insertions, 39 deletions
diff --git a/toolbox.py b/toolbox.py
index ce6f8c6..26b5418 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -150,6 +150,10 @@ class DrawToolbarBox(ToolbarBox):
self.tools_builder = ToolsToolbarBuilder(self.toolbar, self._activity,
self._fill_color_button)
+ separator = Gtk.SeparatorToolItem()
+ separator.set_draw(True)
+ self.toolbar.insert(separator, -1)
+
self.shapes_button = DrawToolButton('shapes',
self._activity.tool_group,
_('Shapes'))
@@ -161,6 +165,10 @@ class DrawToolbarBox(ToolbarBox):
self.toolbar.insert(item_fill_color, -1)
+ separator = Gtk.SeparatorToolItem()
+ separator.set_draw(True)
+ self.toolbar.insert(separator, -1)
+
fonts_button = ToolbarButton()
fonts_button.props.page = TextToolbar(self._activity)
fonts_button.props.icon_name = 'format-text-size'
@@ -347,15 +355,6 @@ class ToolsToolbarBuilder():
self.properties = self._activity.area.tool
self._fill_color_button = fill_color_button
- self._stroke_color = ButtonStrokeColor(activity)
- self._stroke_color.set_title(_('Brush properties'))
- self._stroke_color.connect('notify::color', self._color_button_cb)
- toolbar.insert(self._stroke_color, -1)
-
- separator = Gtk.SeparatorToolItem()
- separator.set_draw(True)
- toolbar.insert(separator, -1)
-
self._tool_brush = DrawToolButton('tool-brush',
activity.tool_group, _('Brush'))
activity.tool_group = self._tool_brush
@@ -394,6 +393,11 @@ class ToolsToolbarBuilder():
self._tool_brush.connect('clicked', self.set_tool,
self._TOOL_BRUSH_NAME)
+ self._stroke_color = ButtonStrokeColor(activity)
+ self.set_tool(self._tool_brush, 'brush')
+ self._stroke_color.connect('notify::color', self._color_button_cb)
+ toolbar.insert(self._stroke_color, -1)
+
def set_tool(self, widget, tool_name):
"""
Set tool to the Area object. Configures tool's color and size.
@@ -405,6 +409,7 @@ class ToolsToolbarBuilder():
"""
if widget != self._tool_brush:
self._tool_brush.set_icon_name(widget.icon_name)
+ self._stroke_color.set_selected_tool(tool_name)
if tool_name == 'stamp':
resized_stamp = self._activity.area.setup_stamp()
@@ -449,15 +454,27 @@ class ButtonFillColor(ColorToolButton):
ColorToolButton.__init__(self)
self._activity = activity
self.properties = self._activity.area.tool
- self.connect('notify::color', self._color_button_cb)
+ self._button_cb = self.connect('notify::color', self._color_button_cb)
+ self._inactive_color = style.COLOR_INACTIVE_FILL.get_gdk_color()
+ # self._old_color = self.get_color()
def _color_button_cb(self, widget, pspec):
- color = self.get_color()
- self.set_fill_color(color)
+ self._old_color = self.get_color()
+ self.set_fill_color(self._old_color)
def set_fill_color(self, color):
self._activity.area.set_fill_color(color)
+ def set_sensitive(self, value):
+ self.handler_block(self._button_cb)
+ if value:
+ self.set_color(self._old_color)
+ else:
+ self.set_color(self._inactive_color)
+ self.handler_unblock(self._button_cb)
+
+ ColorToolButton.set_sensitive(self, value)
+
def create_palette(self):
self._palette = self.get_child().create_palette()
color_palette_hbox = self._palette._picker_hbox
diff --git a/widgets.py b/widgets.py
index 74add83..002ddf2 100644
--- a/widgets.py
+++ b/widgets.py
@@ -181,6 +181,7 @@ class ButtonStrokeColor(Gtk.ToolItem):
self._tooltip = None
self._palette_invoker = ToolInvoker()
self._palette = None
+ self._selected_tool = None
GObject.GObject.__init__(self, **kwargs)
@@ -259,7 +260,7 @@ class ButtonStrokeColor(Gtk.ToolItem):
self.alpha_scale.connect('value-changed', self._on_alpha_changed)
# User is able to choose Shapes for 'Brush' and 'Eraser'
- shape_box = Gtk.HBox()
+ self.shape_box = Gtk.HBox()
self.custom_box.pack_start(self.vbox_brush_options, True, True, 0)
item1 = RadioToolButton()
item1.set_icon_name('tool-shape-ellipse')
@@ -276,21 +277,22 @@ class ButtonStrokeColor(Gtk.ToolItem):
item1.connect('toggled', self._on_toggled, self.properties, 'circle')
item2.connect('toggled', self._on_toggled, self.properties, 'square')
- shape_box.pack_start(Gtk.Label(_('Shape')), True, True, 0)
- shape_box.pack_start(item1, True, True, 0)
- shape_box.pack_start(item2, True, True, 0)
+ self.shape_box.pack_start(Gtk.Label(_('Shape')), True, True, 0)
+ self.shape_box.pack_start(item1, True, True, 0)
+ self.shape_box.pack_start(item2, True, True, 0)
- self.vbox_brush_options.pack_start(shape_box, True, True, 0)
+ self.vbox_brush_options.pack_start(self.shape_box, True, True, 0)
- keep_aspect_checkbutton = Gtk.CheckButton(_('Keep aspect'))
+ self.keep_aspect_checkbutton = Gtk.CheckButton(_('Keep aspect'))
ratio = self._activity.area.keep_aspect_ratio
- keep_aspect_checkbutton.set_active(ratio)
- keep_aspect_checkbutton.connect('toggled',
- self._keep_aspect_checkbutton_toggled)
- self.vbox_brush_options.pack_start(keep_aspect_checkbutton, True, True,
- 0)
-
- color_palette_hbox.pack_start(Gtk.VSeparator(), True, True,
+ self.keep_aspect_checkbutton.set_active(ratio)
+ self.keep_aspect_checkbutton.connect(
+ 'toggled', self._keep_aspect_checkbutton_toggled)
+ self.vbox_brush_options.pack_start(self.keep_aspect_checkbutton, True,
+ True, 0)
+
+ self.custom_separator = Gtk.VSeparator()
+ color_palette_hbox.pack_start(self.custom_separator, True, True,
padding=style.DEFAULT_SPACING)
color_palette_hbox.pack_start(self.custom_box, True, True,
padding=style.DEFAULT_SPACING)
@@ -302,23 +304,51 @@ class ButtonStrokeColor(Gtk.ToolItem):
self._activity.area.keep_aspect_ratio = checkbutton.get_active()
def _update_palette(self):
- palette_children = self._palette._picker_hbox.get_children()
- if self.color_button.is_stamping():
- # Hide palette color widgets except size:
+ tool_name = self._selected_tool
+ show_controls = ()
+ show_colors = False
+ logging.error('TOOL NAME %s', tool_name)
+ if tool_name == 'brush' or tool_name is None:
+ title = _('Brush properties')
+ show_colors = True
+ show_controls = (self.size_label, self.size_scale, self.shape_box,
+ self.alpha_label, self.alpha_scale)
+ elif tool_name == 'stamp':
+ show_controls = (self.size_label, self.size_scale)
+ title = _('Stamp properties')
+ elif tool_name == 'eraser':
+ show_controls = (self.size_label, self.size_scale,
+ self.shape_box)
+ title = _('Eraser properties')
+ elif tool_name == 'bucket':
+ show_colors = True
+ title = _('Bucket properties')
+ elif tool_name == 'picker':
+ title = _('Picker properties')
+ elif tool_name == 'marquee-rectangular':
+ title = _('Select Area')
+ show_controls = (self.keep_aspect_checkbutton,)
+ else:
+ title = ''
+
+ self._palette._picker_hbox.show_all()
+ # Hide palette color widgets except size:
+ if not show_colors:
+ palette_children = self._palette._picker_hbox.get_children()
for ch in palette_children:
if ch != self.custom_box:
ch.hide()
- controls = self.vbox_brush_options.get_children()
- for control in controls:
- if control not in (self.size_label, self.size_scale):
- control.hide()
- # Change title:
- self.set_title(_('Stamp properties'))
- else:
- # Show palette color widgets:
- self._palette._picker_hbox.show_all()
- # Change title:
- self.set_title(_('Brush properties'))
+ elif not show_controls:
+ self.custom_separator.hide()
+
+ self.vbox_brush_options.show_all()
+ controls = self.vbox_brush_options.get_children()
+ for control in controls:
+ if control not in show_controls:
+ control.hide()
+
+ # Change title:
+ self.set_title(title)
self._palette._picker_hbox.resize_children()
self._palette._picker_hbox.queue_draw()
@@ -404,6 +434,12 @@ class ButtonStrokeColor(Gtk.ToolItem):
title = GObject.property(type=str, getter=get_title, setter=set_title)
+ def get_selected_tool(self):
+ return self._selected_tool
+
+ def set_selected_tool(self, tool_name):
+ self._selected_tool = tool_name
+
def do_draw(self, cr):
if self._palette and self._palette.is_up():
allocation = self.get_allocation()