Skip to content

Commit 58d3928

Browse files
authored
Make artboards feature complete (#401)
* Allow controlling the artboard fill color * Implement hide and lock options for artboard layer * Implement hover effects for artboard layers * Add release notes
1 parent 4257ca3 commit 58d3928

File tree

6 files changed

+105
-2
lines changed

6 files changed

+105
-2
lines changed

data/com.github.akiraux.akira.appdata.xml.in.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
<description>
3737
<p>Bug fixes and Artboards improvements</p>
3838
<ul>
39+
<li>Control Artboards background color.</li>
40+
<li>Hide and Lock Artbaords from the Layers panel.</li>
3941
<li>Items inside Artboards are masked when extending outside the edges of the Artboard.</li>
4042
<li>Fix items reordering with the layers panel drag and drop</li>
4143
<li>Fix random segfault at startup while setting accelerators</li>

data/css/artboard.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
color: @fg_color;
3636
}
3737

38+
/* Hovered */
39+
.artboard.hovered:not(:selected) .artboard-handle {
40+
box-shadow: inset 0 0 0 2px @highlight;
41+
}
42+
3843
.artboard-container {
3944
background-color: @bg_color;
4045
}

debian/changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
com.github.akiraux.akira (0.0.12) xenial; urgency=medium
22

3+
* Control Artboards background color.
4+
* Hide and Lock Artbaords from the Layers panel.
35
* Items inside Artboards are masked when extending outside the edges of the Artboard.
46
* Fix items reordering with the layers panel drag and drop.
57
* Fix random segfault at startup while setting accelerators.

src/Layouts/Partials/Artboard.vala

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,13 @@ public class Akira.Layouts.Partials.Artboard : Gtk.ListBoxRow {
223223

224224
handle.enter_notify_event.connect (event => {
225225
get_style_context ().add_class ("hover");
226+
window.event_bus.hover_over_layer (model);
226227
return false;
227228
});
228229

229230
handle.leave_notify_event.connect (event => {
230231
get_style_context ().remove_class ("hover");
232+
window.event_bus.hover_over_layer (null);
231233
return false;
232234
});
233235

@@ -237,6 +239,20 @@ public class Akira.Layouts.Partials.Artboard : Gtk.ListBoxRow {
237239
var item_model = item as Akira.Lib.Models.CanvasItem;
238240
return new Akira.Layouts.Partials.Layer (window, item_model, container);
239241
});
242+
243+
lock_actions ();
244+
hide_actions ();
245+
246+
window.event_bus.hover_over_item.connect (on_hover_over_item);
247+
}
248+
249+
private void on_hover_over_item (Lib.Models.CanvasItem? item) {
250+
if (item == model) {
251+
get_style_context ().add_class ("hovered");
252+
return;
253+
}
254+
255+
get_style_context ().remove_class ("hovered");
240256
}
241257

242258
private void build_drag_and_drop () {
@@ -461,4 +477,71 @@ public class Akira.Layouts.Partials.Artboard : Gtk.ListBoxRow {
461477
window.event_bus.disconnect_typing_accel ();
462478
return false;
463479
}
480+
481+
private void lock_actions () {
482+
button_locked.bind_property ("active", model, "locked",
483+
BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
484+
485+
button_locked.toggled.connect (() => {
486+
var active = button_locked.get_active ();
487+
button_locked.tooltip_text = active ? _("Unlock Layer") : _("Lock Layer");
488+
489+
if (active) {
490+
button_locked.get_style_context ().add_class ("show");
491+
} else {
492+
button_locked.get_style_context ().remove_class ("show");
493+
}
494+
495+
icon_unlocked.visible = active;
496+
icon_unlocked.no_show_all = ! active;
497+
498+
icon_locked.visible = ! active;
499+
icon_locked.no_show_all = active;
500+
501+
if (active) {
502+
window.event_bus.item_locked (model);
503+
(parent as Gtk.ListBox).unselect_row (this);
504+
}
505+
506+
window.event_bus.set_focus_on_canvas ();
507+
window.event_bus.file_edited ();
508+
});
509+
}
510+
511+
private void hide_actions () {
512+
button_hidden.bind_property ("active", model, "visibility",
513+
BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE,
514+
(binding, srcval, ref targetval) => {
515+
Goo.CanvasItemVisibility status = (bool) srcval.get_boolean ()
516+
? Goo.CanvasItemVisibility.INVISIBLE
517+
: Goo.CanvasItemVisibility.VISIBLE;
518+
targetval.set_enum (status);
519+
return true;
520+
},
521+
(binding, srcval, ref targetval) => {
522+
var status = ((Goo.CanvasItemVisibility) srcval.get_enum ()) == Goo.CanvasItemVisibility.INVISIBLE;
523+
targetval.set_boolean (status);
524+
return true;
525+
});
526+
527+
button_hidden.toggled.connect (() => {
528+
var active = button_hidden.get_active ();
529+
button_hidden.tooltip_text = active ? _("Show Layer") : _("Hide Layer");
530+
531+
if (active) {
532+
button_hidden.get_style_context ().add_class ("show");
533+
} else {
534+
button_hidden.get_style_context ().remove_class ("show");
535+
}
536+
537+
icon_visible.visible = active;
538+
icon_visible.no_show_all = ! active;
539+
540+
icon_hidden.visible = ! active;
541+
icon_hidden.no_show_all = active;
542+
543+
window.event_bus.set_focus_on_canvas ();
544+
window.event_bus.file_edited ();
545+
});
546+
}
464547
}

src/Layouts/Partials/Layer.vala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ public class Akira.Layouts.Partials.Layer : Gtk.ListBoxRow {
704704
}
705705

706706
window.event_bus.set_focus_on_canvas ();
707+
window.event_bus.file_edited ();
707708
});
708709
}
709710

@@ -738,6 +739,9 @@ public class Akira.Layouts.Partials.Layer : Gtk.ListBoxRow {
738739

739740
icon_hidden.visible = ! active;
740741
icon_hidden.no_show_all = active;
742+
743+
window.event_bus.set_focus_on_canvas ();
744+
window.event_bus.file_edited ();
741745
});
742746
}
743747

src/Lib/Models/CanvasArtboard.vala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,15 @@ public class Akira.Lib.Models.CanvasArtboard : Goo.CanvasItemSimple, Goo.CanvasI
115115
y = 0;
116116

117117
show_border_radius_panel = false;
118-
show_fill_panel = false;
118+
show_fill_panel = true;
119119
show_border_panel = false;
120120
is_radius_uniform = true;
121121
is_radius_autoscale = false;
122122

123+
var fill_rgba = Gdk.RGBA ();
124+
fill_rgba.parse ("rgba (255, 255, 255, 1)");
125+
color = fill_rgba;
126+
123127
set_transform (Cairo.Matrix.identity ());
124128

125129
// Keep the item always in the origin
@@ -209,7 +213,10 @@ public class Akira.Lib.Models.CanvasArtboard : Goo.CanvasItemSimple, Goo.CanvasI
209213
cr.clip ();
210214

211215
cr.rectangle (x, y, width, height);
212-
cr.set_source_rgba (1, 1, 1, 1);
216+
217+
// If the user hides or delete the fill color, set the opacity to 0.
218+
var alpha = hidden_fill || !has_fill ? 0 : color.alpha;
219+
cr.set_source_rgba (color.red, color.green, color.blue, alpha);
213220
cr.fill ();
214221

215222
if (items.get_n_items () > 0) {

0 commit comments

Comments
 (0)