[aseprite] 97/128: Add option to show layer edges

Tobias Hansen thansen at moszumanska.debian.org
Mon May 9 21:24:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit b60b76ff22ae4178e581bb66c69f74f6eb20fac8
Author: David Capello <davidcapello at gmail.com>
Date:   Tue May 3 16:23:38 2016 -0300

    Add option to show layer edges
---
 data/gui.xml                     |  1 +
 data/pref.xml                    |  1 +
 data/skins/default/skin.xml      |  1 +
 src/app/commands/cmd_show.cpp    | 31 +++++++++++++++++++++++++++++++
 src/app/commands/commands_list.h |  1 +
 src/app/ui/editor/editor.cpp     | 18 +++++++++++++++---
 6 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/data/gui.xml b/data/gui.xml
index e17f381..7ac9433 100644
--- a/data/gui.xml
+++ b/data/gui.xml
@@ -736,6 +736,7 @@
         <separator />
         <item command="ShowExtras" text="&Extras" />
         <menu text="&Show">
+          <item command="ShowLayerEdges" text="&Layer Edges" />
           <item command="ShowSelectionEdges" text="&Selection Edges" />
           <item command="ShowGrid" text="&Grid" />
           <item command="ShowPixelGrid" text="&Pixel Grid" />
diff --git a/data/pref.xml b/data/pref.xml
index a298666..db9fa1e 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -293,6 +293,7 @@
       <option id="auto_scroll" type="bool" default="true" />
     </section>
     <section id="show">
+      <option id="layer_edges" type="bool" default="false" />
       <option id="selection_edges" type="bool" default="true" />
       <option id="grid" type="bool" default="false" migrate="grid.visible" />
       <option id="pixel_grid" type="bool" default="false" migrate="pixel_grid.visible" />
diff --git a/data/skins/default/skin.xml b/data/skins/default/skin.xml
index 022d9cb..ce0f744 100644
--- a/data/skins/default/skin.xml
+++ b/data/skins/default/skin.xml
@@ -56,6 +56,7 @@
     <color id="editor_face" value="#655561" />
     <color id="editor_sprite_border" value="#000000" />
     <color id="editor_sprite_bottom_border" value="#41412c" />
+    <color id="editor_layer_edges" value="#0000ff" />
     <color id="listitem_normal_text" value="#000000" />
     <color id="listitem_normal_face" value="#ffffff" />
     <color id="listitem_selected_text" value="#ffffff" />
diff --git a/src/app/commands/cmd_show.cpp b/src/app/commands/cmd_show.cpp
index 7e08e6c..457260c 100644
--- a/src/app/commands/cmd_show.cpp
+++ b/src/app/commands/cmd_show.cpp
@@ -38,11 +38,15 @@ protected:
     if (docPref.show.selectionEdges()) {
       globPref.show = docPref.show;
       docPref.show.selectionEdges(false);
+      docPref.show.layerEdges(false);
       docPref.show.grid(false);
       docPref.show.pixelGrid(false);
     }
     else {
       docPref.show.selectionEdges(true);
+      docPref.show.layerEdges(
+        docPref.show.layerEdges() ||
+        globPref.show.layerEdges());
       docPref.show.grid(
         docPref.show.grid() ||
         globPref.show.grid());
@@ -53,6 +57,28 @@ protected:
   }
 };
 
+class ShowLayerEdgesCommand : public Command {
+public:
+  ShowLayerEdgesCommand()
+    : Command("ShowLayerEdges",
+              "Show Layer Edges",
+              CmdUIOnlyFlag) {
+  }
+
+  Command* clone() const override { return new ShowLayerEdgesCommand(*this); }
+
+protected:
+  bool onChecked(Context* ctx) override {
+    DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
+    return docPref.show.layerEdges();
+  }
+
+  void onExecute(Context* ctx) override {
+    DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
+    docPref.show.layerEdges(!docPref.show.layerEdges());
+  }
+};
+
 class ShowGridCommand : public Command {
 public:
   ShowGridCommand()
@@ -161,6 +187,11 @@ Command* CommandFactory::createShowPixelGridCommand()
   return new ShowPixelGridCommand;
 }
 
+Command* CommandFactory::createShowLayerEdgesCommand()
+{
+  return new ShowLayerEdgesCommand;
+}
+
 Command* CommandFactory::createShowSelectionEdgesCommand()
 {
   return new ShowSelectionEdgesCommand;
diff --git a/src/app/commands/commands_list.h b/src/app/commands/commands_list.h
index 7a514cd..5bd933e 100644
--- a/src/app/commands/commands_list.h
+++ b/src/app/commands/commands_list.h
@@ -119,6 +119,7 @@ FOR_EACH_COMMAND(SetSameInk)
 FOR_EACH_COMMAND(ShowBrushPreview)
 FOR_EACH_COMMAND(ShowExtras)
 FOR_EACH_COMMAND(ShowGrid)
+FOR_EACH_COMMAND(ShowLayerEdges)
 FOR_EACH_COMMAND(ShowOnionSkin)
 FOR_EACH_COMMAND(ShowPixelGrid)
 FOR_EACH_COMMAND(ShowSelectionEdges)
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index ba6bb9f..53bbcc3 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -307,11 +307,14 @@ void Editor::setLayer(const Layer* layer)
   m_layer = const_cast<Layer*>(layer);
   m_observers.notifyAfterLayerChanged(this);
 
-  // If the onion skinning depends on the active layer, we've to
-  // redraw the whole editor.
   if (m_document && changed) {
-    if (m_docPref.onionskin.currentLayer())
+    if (// If the onion skinning depends on the active layer
+        m_docPref.onionskin.currentLayer() ||
+        // If the user want to see the active layer edges...
+        m_docPref.show.layerEdges()) {
+      // We've to redraw the whole editor
       invalidate();
+    }
   }
 
   // The active layer has changed.
@@ -679,6 +682,15 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
       enclosingRect.x, enclosingRect.y+enclosingRect.h, enclosingRect.w);
   }
 
+  // Draw active cel edges
+  if (m_docPref.show.layerEdges()) {
+    Cel* cel = (m_layer ? m_layer->cel(m_frame): nullptr);
+    if (cel) {
+      g->drawRect(theme->colors.editorLayerEdges(),
+                  editorToScreen(cel->bounds()).offset(-bounds().origin()));
+    }
+  }
+
   // Draw the mask
   if (m_document->getMaskBoundaries())
     drawMask(g);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list