Skip to content

Commit

Permalink
Statusbar: add extra required widgets (NFC)
Browse files Browse the repository at this point in the history
Added (to Glade, and with supporting code for the MyPaint runtime):

* Color picker button (icon taken from the Inkscape distro; GPL2+)
* Previous/next preview indicator (which might evolve a bit)
* Add missing Glade icon for the drawing window.
  • Loading branch information
Andrew Chadwick committed Jul 10, 2013
1 parent 0ffb42b commit a19c5e0
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 0 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions glade/mypaint_widgets.xml
Expand Up @@ -257,8 +257,38 @@
optional-default="True"/>
</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"
generic-name="brushcolorindicator">
<properties>
<!-- Representative size for preview -->
<property id="width-request" default="64" optional="True"
optional-default="True" />
<property id="height-request" default="24" optional="True"
optional-default="True" />
</properties>
</glade-widget-class>

</glade-widget-classes>


<glade-widget-group name="MyPaint" title="MyPaint Widgets">
<glade-widget-class-ref name="MyPaintDrawWindow"/>
<glade-widget-class-ref name="MyPaintWorkspace"/>
Expand All @@ -269,6 +299,8 @@
<glade-widget-class-ref name="ItemSpinBox"/>
<glade-widget-class-ref name="DropdownPanelButton"/>
<glade-widget-class-ref name="ButtonMappingEditor"/>
<glade-widget-class-ref name="MyPaintBrushColorPickerButton"/>
<glade-widget-class-ref name="MyPaintBrushColorIndicator"/>
</glade-widget-group>

</glade-catalog>
21 changes: 21 additions & 0 deletions gui/colorpicker.py
Expand Up @@ -232,3 +232,24 @@ def paint(self, cr):

self._previous_area = area


## More conventional color-picking button, with grab


class BrushColorPickerButton (colors.ColorPickerButton):
"""Color picker button that sets the app's working brush color."""

__gtype_name__ = "MyPaintBrushColorPickerButton"

def __init__(self):
colors.ColorPickerButton.__init__(self)
self.connect("realize", self._init_color_manager)

def _init_color_manager(self, widget):
from application import get_app
app = get_app()
mgr = app.brush_color_manager
assert mgr is not None
self.set_color_manager(mgr)


34 changes: 34 additions & 0 deletions gui/colorpreview.py
@@ -0,0 +1,34 @@
# This file is part of MyPaint.
# Copyright (C) 2013 by Andrew Chadwick <a.t.chadwick@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or


"""Color preview widget / current color indicator, for the status bar."""

# TODO: This *might* evolve to a color preview + alpha selector, possibly
# TODO: with a history row taking up the bottom. For now let's draw it at
# TODO: an aspect ratio of about 1:5 and see how users like it.


from colors import PreviousCurrentColorAdjuster


class BrushColorIndicator (PreviousCurrentColorAdjuster):
"""Previous/Current color adjuster bound to app.brush_color_manager"""

__gtype_name__ = "MyPaintBrushColorIndicator"

def __init__(self):
PreviousCurrentColorAdjuster.__init__(self)
self.connect("realize", self._init_color_manager)

def _init_color_manager(self, widget):
from application import get_app
app = get_app()
mgr = app.brush_color_manager
assert mgr is not None
self.set_color_manager(mgr)

0 comments on commit a19c5e0

Please sign in to comment.