Skip to content

Commit

Permalink
Add UI elements for #332, and for "invert selection" (#369)
Browse files Browse the repository at this point in the history
issue 332:
- define selection as current image
- expand canvas so the selection fits

corresponding actions aren't implemented
  • Loading branch information
maoschanz committed May 11, 2021
1 parent c95a84c commit eada619
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 14 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ These tools can edit the whole image, or edit a selected part of it.

----

### Settings

The settings are managed by the `Gio.Settings` abstraction, which will probably
corresponds to the `dconf` database once the app is installed as a native
package.

With flatpak however, the settings are stored in a key-value file, which can be
found (and edited) at `~/.var/app/com.github.maoschanz.drawing/config/glib-2.0/settings/keyfile`.

----

[Donations (paypal)](https://paypal.me/maoschannz)

[To contribute](./CONTRIBUTING.md)
Expand Down
15 changes: 1 addition & 14 deletions documentation/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@




# Syntax and comments

- Use 2 spaces in `.ui` or `.xml` files.
Expand All @@ -18,16 +15,6 @@ welcome.
- Use double quotes for strings the user might see, and single quotes otherwise
(paths, constants, enumerations, dict keys, …)

# Settings

The settings are managed by the `Gio.Settings` abstraction, which will probably
corresponds to the `dconf` database once the app is installed as a native
package.

With flatpak however, which includes the recommended development setup, the
settings are stored in a key-value file, which can be found (and edited) at
`~/.var/app/com.github.maoschanz.drawing/config/glib-2.0/settings/keyfile`.

----

# Structure of the code
Expand Down Expand Up @@ -93,7 +80,7 @@ instead of directly connecting buttons/menu-items to a method.

In my opinion, the difficulties with the code can come mainly from 3 points:

- tools are window-wide, while [the operations they produce](./design-tools#command-pattern),
- tools are window-wide, while [the operations they produce](./design-tools.md#command-pattern),
which are stored in the history, are image-wide.
- the interactions between the tools and the selection manager are ridiculously
complex and numerous _(defining, explicit applying, explicit canceling, import,
Expand Down
34 changes: 34 additions & 0 deletions src/optionsbars/selection/optionsbar-selection.ui
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@
<attribute name="label" translatable="yes">Unselect</attribute>
<attribute name="action">win.unselect</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Invert selection</attribute>
<attribute name="action">win.selection_invert</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Close selection</attribute>
<attribute name="action">win.selection_close</attribute>
Expand All @@ -263,6 +268,18 @@
<attribute name="verb-icon">edit-copy-symbolic</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Define as current image</attribute>
<attribute name="action">win.selection-replace-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Expand image to fit</attribute>
<attribute name="action">win.selection-expand-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Open As New Image</attribute>
Expand Down Expand Up @@ -291,11 +308,28 @@
<attribute name="label" translatable="yes">Unselect</attribute>
<attribute name="action">win.unselect</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Invert selection</attribute>
<attribute name="action">win.selection_invert</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Close selection</attribute>
<attribute name="action">win.selection_close</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Define as current image</attribute>
<attribute name="action">win.selection-replace-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Expand image to fit</attribute>
<attribute name="action">win.selection-expand-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Open As New Image</attribute>
Expand Down
17 changes: 17 additions & 0 deletions src/tools/ui/selection.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<attribute name="label" translatable="yes">Unselect</attribute>
<attribute name="action">win.unselect</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Invert selection</attribute>
<attribute name="action">win.selection_invert</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Close selection</attribute>
<attribute name="action">win.selection_close</attribute>
Expand Down Expand Up @@ -74,6 +79,18 @@
<attribute name="verb-icon">edit-copy-symbolic</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Define as current image</attribute>
<attribute name="action">win.selection-replace-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Expand image to fit</attribute>
<attribute name="action">win.selection-expand-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Open As New Image</attribute>
Expand Down
22 changes: 22 additions & 0 deletions src/ui/selection-manager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@
<section>
<submenu>
<attribute name="label" translatable="yes">More actions</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Invert selection</attribute>
<attribute name="action">win.selection_invert</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
</section>
<section>
<item>
<!-- Define the image as being the currently selected area -->
<attribute name="label" translatable="yes">Define as current image</attribute>
<attribute name="action">win.selection-replace-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<!-- Expand the canvas of the current image to make the current -->
<!-- selection fit in it -->
<attribute name="label" translatable="yes">Expand image to fit</attribute>
<attribute name="action">win.selection-expand-canvas</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Open As New Image</attribute>
Expand Down
9 changes: 9 additions & 0 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,15 @@ def import_from_path(self, file_path):
def action_selection_export(self, *args):
return self.saving_manager.save_current_image(True, True, True, True)

def action_selection_replace_canvas(self, *args):
pass

def action_selection_expand_canvas(self, *args):
pass

def action_selection_invert(self, *args):
pass

def get_selection_tool(self):
if 'rect_select' in self.tools:
return self.tools['rect_select']
Expand Down

0 comments on commit eada619

Please sign in to comment.