Skip to content

Commit

Permalink
Refactor footer picker buttons
Browse files Browse the repository at this point in the history
* Add context picker button in footer bottom right.
* Factor out picker grab behaviour.
* Factor out picker button click behaviour to a separate class.
  • Loading branch information
achadwick committed May 20, 2015
1 parent bd24b01 commit 9f319e3
Show file tree
Hide file tree
Showing 6 changed files with 669 additions and 22 deletions.
16 changes: 0 additions & 16 deletions glade/mypaint_widgets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,6 @@
</properties>
</glade-widget-class>

<!-- gui/colorpicker.py -->
<glade-widget-class name="MyPaintBrushColorPickerButton"
title="Brush Color Picker Button" parent="GtkSpinner"
generic-name="brushcolorpickerbutton">
<properties>
<!-- Hide GtkSpinner properties -->
<property id="active" visible="False" save="False" />
<!-- Representative size for preview -->
<property id="width-request" default="24" optional="True"
optional-default="True" save="False"/>
<property id="height-request" default="24" optional="True"
optional-default="True" save="False"/>
</properties>
</glade-widget-class>

<!-- gui/colorpreview.py -->
<glade-widget-class name="MyPaintBrushColorIndicator"
title="Brush Color Indicator" parent="GtkDrawingArea"
Expand Down Expand Up @@ -331,7 +316,6 @@
<glade-widget-class-ref name="ButtonMappingEditor"/>
<glade-widget-class-ref name="AccelMapEditor"/>
<glade-widget-class-ref name="MyPaintDeviceSettingsEditor"/>
<glade-widget-class-ref name="MyPaintBrushColorPickerButton"/>
<glade-widget-class-ref name="MyPaintBrushColorIndicator"/>
</glade-widget-group>

Expand Down
7 changes: 7 additions & 0 deletions gui/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
from buttonmap import ButtonMapping
import gui.cursor
import lib.fileutils
import gui.picker


## Utility methods
Expand Down Expand Up @@ -219,6 +220,12 @@ def __init__(self, filenames, app_datapath, app_extradatapath,
# File I/O
self.filehandler = filehandling.FileHandler(self)

# Picking grabs
self.context_grab = gui.picker.ContextPickingGrabPresenter()
self.context_grab.app = self
self.color_grab = gui.picker.ColorPickingGrabPresenter()
self.color_grab.app = self

# Load the main interface
mypaint_main_xml = join(self.datapath, "gui", "mypaint.glade")
self.builder.add_from_file(mypaint_main_xml)
Expand Down
13 changes: 13 additions & 0 deletions gui/drawwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import gui.layermanip # registration
from lib.color import RGBColor, HSVColor
import uicolor
import gui.picker

import brushselectionwindow

Expand Down Expand Up @@ -880,3 +881,15 @@ def _mode_icon_query_tooltip_cb(self, widget, x, y, kbmode, tooltip):
markup = self._MODE_ICON_TEMPLATE.format(**params)
tooltip.set_markup(markup)
return True

def _footer_context_picker_button_realize_cb(self, button):
presenter = gui.picker.ButtonPresenter()
presenter.set_button(button)
presenter.set_picking_grab(self.app.context_grab)
self._footer_context_picker_button_presenter = presenter

def _footer_color_picker_button_realize_cb(self, button):
presenter = gui.picker.ButtonPresenter()
presenter.set_button(button)
presenter.set_picking_grab(self.app.color_grab)
self._footer_color_picker_button_presenter = presenter
50 changes: 44 additions & 6 deletions gui/mypaint.glade
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-requires mypaint_widgets 3.0 -->
<requires lib="gtk+" version="3.10"/>
<requires lib="mypaint_widgets" version="3.0"/>
<object class="MyPaintDrawWindow" id="drawwindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">MyPaint</property>
Expand Down Expand Up @@ -56,9 +57,22 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="MyPaintBrushColorPickerButton" id="footer_color_picker_button">
<object class="GtkButton" id="footer_color_picker_button">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes" context="footer: color picker button: tooltip">Pick color</property>
<property name="relief">none</property>
<signal name="realize" handler="_footer_color_picker_button_realize_cb" swapped="no"/>
<child>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="pixel_size">16</property>
<property name="icon_name">mypaint-pick-color-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -69,6 +83,7 @@
<child>
<object class="MyPaintBrushColorIndicator" id="colorindicator1">
<property name="width_request">96</property>
<property name="height_request">-1</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
Expand All @@ -85,7 +100,6 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes" context="Footerbar|">Add the current color to the palette</property>
<property name="use_action_appearance">False</property>
<property name="relief">none</property>
<signal name="clicked" handler="palette_add_current_color_cb" swapped="no"/>
<child>
Expand Down Expand Up @@ -158,7 +172,7 @@ R: {rotation:+.1f}°</property>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">6</property>
</packing>
</child>
<child>
Expand All @@ -170,7 +184,31 @@ R: {rotation:+.1f}°</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">10</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkButton" id="footer_context_picker_button">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes" context="footer: context picker button: tooltip">Pick brushstroke settings, stroke color, and layer</property>
<property name="relief">none</property>
<signal name="realize" handler="_footer_context_picker_button_realize_cb" swapped="no"/>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="pixel_size">16</property>
<property name="icon_name">mypaint-target-brush-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
</object>
Expand Down
Loading

0 comments on commit 9f319e3

Please sign in to comment.