Skip to content

Commit

Permalink
restructure the menus to get operators, to get a more usable popover
Browse files Browse the repository at this point in the history
in the context of #329, "blur" is gone so the color popover felt empty

now it has 3 submenus, and it'll change again to make better use of its hidden radiobuttons
  • Loading branch information
maoschanz committed Feb 10, 2021
1 parent fdce24e commit 803c017
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 93 deletions.
226 changes: 157 additions & 69 deletions src/optionsbars/classic/optionsbar-color-popover.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<child>
<object class="GtkBox" id="operator-box-start">
<property name="visible">True</property>
<property name="spacing">10</property>
<property name="orientation">horizontal</property>
<property name="tooltip-text" translatable="yes">How the color will be applied to the existing pixels</property>
<style><class name="linked"/></style>
<child>
<object class="GtkRadioButton" id="op-group">
<property name="visible">True</property>
Expand All @@ -33,82 +33,154 @@
<property name="action-target">'over'</property>
</object>
</child>

<!-- -->

<child>
<object class="GtkMenuButton" id="op-menubtn">
<object class="GtkBox">
<property name="visible">True</property>
<property name="menu-model">other-operators-menu</property>
<property name="orientation">horizontal</property>
<style><class name="linked"/></style>

<child>
<object class="GtkImage">
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'multiply'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'screen'</property>
</object>
</child>

<child>
<object class="GtkMenuButton" id="op-menubtn1">
<property name="visible">True</property>
<property name="icon-name">pan-down-symbolic</property>
<property name="menu-model">highlight-operators-menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">tool-highlight-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'source'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'multiply'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'difference'</property>
</object>
</child>
</object>
</child>

<child>
<object class="GtkBox">
<!-- <property name="visible">True</property> -->
<property name="orientation">horizontal</property>
<style><class name="linked"/></style>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-hue'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-saturation'</property>
</object>
</child>

<!-- -->

<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-color'</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<style><class name="linked"/></style>

<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-hue'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-saturation'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-color'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-luminosity'</property>
</object>
</child>

<child>
<object class="GtkMenuButton" id="op-menubtn2">
<property name="visible">True</property>
<property name="menu-model">hsl-operators-menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">display-brightness-symbolic</property>
</object>
</child>
</object>
</child>

</object>
</child>

<!-- -->

<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'hsl-luminosity'</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<style><class name="linked"/></style>

<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'source'</property>
</object>
</child>
<child>
<object class="GtkRadioButton">
<property name="group">op-group</property>
<!-- <property name="visible">True</property> -->
<property name="draw-indicator">False</property>
<property name="action-name">win.cairo_op_mirror</property>
<property name="action-target">'difference'</property>
</object>
</child>

<child>
<object class="GtkMenuButton" id="op-menubtn">
<property name="visible">True</property>
<property name="menu-model">other-operators-menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">view-more-symbolic</property>
</object>
</child>
</object>
</child>

</object>
</child>

</object>
</child>

Expand Down Expand Up @@ -202,19 +274,35 @@
</item>
<item>
<!-- Context: a possible way to apply the color to the canvas -->
<attribute name="label" translatable="yes">Highlight</attribute>
<attribute name="label" translatable="yes">Difference</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">difference</attribute>
</item>
<!-- and more...? -->
</section>
</menu>

<menu id="highlight-operators-menu">
<section>
<!-- Context: possible ways to apply the color to the canvas -->
<attribute name="label" translatable="yes">Highlight</attribute>
<item>
<!-- Context: a possible way to highlight text -->
<attribute name="label" translatable="yes">Dark text on light background</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">multiply</attribute>
</item>
<item>
<!-- Context: a possible way to apply the color to the canvas -->
<attribute name="label" translatable="yes">Difference</attribute>
<!-- Context: a possible way to highlight text -->
<attribute name="label" translatable="yes">Light text on dark background</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">difference</attribute>
<attribute name="target">screen</attribute>
</item>
<!-- and more...? -->
</section>
<submenu>
</menu>

<menu id="hsl-operators-menu">
<section>
<!-- Context: possible ways to apply the color to the canvas -->
<attribute name="label" translatable="yes">Photo-oriented modes</attribute>
<item>
Expand All @@ -241,7 +329,7 @@
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">hsl-luminosity</attribute>
</item>
</submenu>
</section>
</menu>

</interface>
Expand Down
11 changes: 7 additions & 4 deletions src/optionsbars/classic/optionsbar_color_popover.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
'source': cairo.Operator.SOURCE,
'difference': cairo.Operator.DIFFERENCE,

# "Highlight" submenu
'multiply': cairo.Operator.MULTIPLY,
'screen': cairo.Operator.SCREEN,

'hsl-hue': cairo.Operator.HSL_HUE,
'hsl-saturation': cairo.Operator.HSL_SATURATION,
Expand All @@ -40,9 +42,12 @@
'over': _("Normal"),
'clear': _("Erase"),

'difference': _("Difference"),
'multiply': _("Highlight"),
'source': _("Raw source color"),
'difference': _("Difference"),

# "Highlight" submenu
'multiply': _("Highlight") + " - " + _("Dark text on light background"),
'screen': _("Highlight") + " - " + _("Light text on dark background"),

'hsl-hue': _("Hue only"),
'hsl-saturation': _("Saturation only"),
Expand Down Expand Up @@ -84,7 +89,6 @@ def __init__(self, btn, thumbn, initial_rgba, is_main_c, cl_bar, **kwargs):

self._operator_box_1 = builder.get_object('operator-box-start')
self._operator_box_2 = builder.get_object('operator-box-end')
self._operator_menubtn = builder.get_object('op-menubtn')

########################################################################
# Color chooser widget #################################################
Expand Down Expand Up @@ -127,7 +131,6 @@ def adapt_to_operator(self, op_as_string):
self._operator_label = CAIRO_OP_LABELS[op_as_string]
# print("adapt to operator :", op_as_string)
supports_colors = self._operator_supports_color(op_as_string)
self._operator_menubtn.get_popover().popdown()
self.color_widget.set_sensitive(supports_colors)
self._set_thumbnail_color(op_as_string)

Expand Down
37 changes: 17 additions & 20 deletions src/ui/app-menus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -311,33 +311,17 @@
<attribute name="target">over</attribute>
</item>
<submenu>
<attribute name="label" translatable="yes">Other modes</attribute>
<item>
<attribute name="label" translatable="yes">Raw source color</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">source</attribute>
</item>
<attribute name="label" translatable="yes">Highlight</attribute>
<item>
<attribute name="label" translatable="yes">Highlight</attribute>
<attribute name="label" translatable="yes">Dark text on light background</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">multiply</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Difference</attribute>
<attribute name="label" translatable="yes">Light text on dark background</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">difference</attribute>
<attribute name="target">screen</attribute>
</item>
<!-- TODO ? -->
<!-- <item> -->
<!-- <attribute name="label" translatable="yes">Lighten</attribute> -->
<!-- <attribute name="action">win.cairo_operator</attribute> -->
<!-- <attribute name="target">lighten</attribute> -->
<!-- </item> -->
<!-- <item> -->
<!-- <attribute name="label" translatable="yes">Darken</attribute> -->
<!-- <attribute name="action">win.cairo_operator</attribute> -->
<!-- <attribute name="target">darken</attribute> -->
<!-- </item> -->
</submenu>
<submenu>
<attribute name="label" translatable="yes">Photo-oriented modes</attribute>
Expand All @@ -362,6 +346,19 @@
<attribute name="target">hsl-luminosity</attribute>
</item>
</submenu>
<submenu>
<attribute name="label" translatable="yes">Other modes</attribute>
<item>
<attribute name="label" translatable="yes">Raw source color</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">source</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Difference</attribute>
<attribute name="action">win.cairo_operator</attribute>
<attribute name="target">difference</attribute>
</item>
</submenu>
</section>
<section>
<attribute name="label" translatable="yes">Don't use the colors but…</attribute>
Expand Down

0 comments on commit 803c017

Please sign in to comment.