Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
1.0.4 - release
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Jan 25, 2020
1 parent 90686ef commit 7d0e05b
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 8 deletions.
12 changes: 11 additions & 1 deletion data/com.github.lainsce.rakugaki.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,19 @@
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<releases>
<release version="1.0.3" date="2020-01-17">
<release version="1.0.4" date="2020-01-31">
<description>
<p>Release: Ongaku</p>
<ul>
<li>Added: Eraser function</li>
<li>Fixed: Grid should be a guide, so it is top-most.</li>
<li>And other small changes.</li>
</ul>
</description>
</release>
<release version="1.0.3" date="2020-01-17">
<description>
<p>Release: Yoru</p>
<ul>
<li>Fixed: Minor backend fixes</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions data/com.github.lainsce.rakugaki.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
<summary>Window position</summary>
<description>The y axis of window position</description>
</key>
<key name="window-maximize" type="b">
<default>false</default>
<summary>Window maximize status</summary>
<description>The state of window maximization</description>
</key>
</schema>
</schemalist>
79 changes: 79 additions & 0 deletions data/icons/symbolic/eraser-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/style.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<file alias="line-thickness-symbolic.svg">icons/symbolic/line-thickness-symbolic.svg</file>
<file alias="grid-dots-symbolic.svg">icons/symbolic/grid-dots-symbolic.svg</file>
<file alias="line-cap-symbolic.svg">icons/symbolic/line-cap-symbolic.svg</file>
<file alias="eraser-symbolic.svg">icons/symbolic/eraser-symbolic.svg</file>
</gresource>
</gresources>
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Name our project
project('com.github.lainsce.rakugaki', ['vala', 'c'],
version: '1.0.3'
version: '1.0.4'
)

# Import main lib files
Expand Down
4 changes: 4 additions & 0 deletions src/Constants/AppSettings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ namespace Rakugaki {
get { return get_int ("window-y"); }
set { set_int ("window-y", value); }
}
public bool window_maximize {
get { return get_boolean ("window-maximize"); }
set { set_boolean ("window-maximize", value); }
}

private static AppSettings? instance;
public static unowned AppSettings get_default () {
Expand Down
6 changes: 6 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ namespace Rakugaki {
if (x != -1 && y != -1) {
this.move (x, y);
}
if (settings.window_maximize) {
this.maximize ();
} else {
this.unmaximize ();
}

this.get_style_context ().add_class ("rounded");
this.get_style_context ().add_class ("dm-window");
Expand Down Expand Up @@ -357,6 +362,7 @@ namespace Rakugaki {
var settings = AppSettings.get_default ();
settings.window_x = x;
settings.window_y = y;
settings.window_maximize = is_maximized;
return false;
}
}
Expand Down
56 changes: 50 additions & 6 deletions src/Widgets/UI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Rakugaki {
public class Path {
public List<Point> points = null;
public bool is_halftone {get; set; default=false;}
public bool is_eraser {get; set; default=false;}
}

public class DrawingArea : Gtk.DrawingArea {
Expand Down Expand Up @@ -40,6 +41,7 @@ namespace Rakugaki {
public bool dirty {get; set;}
public bool see_grid {get; set; default=true;}
public bool halftone {get; set; default=false;}
public bool eraser {get; set; default=false;}

public UI (MainWindow win) {
this.win = win;
Expand All @@ -56,7 +58,14 @@ namespace Rakugaki {
current_path.is_halftone = true;
current_path.points.append (new Point (e.x, e.y));
paths.append (current_path);
} else {
}
if (eraser) {
current_path = new Path ();
current_path.is_eraser = true;
current_path.points.append (new Point (e.x, e.y));
paths.append (current_path);
}
if (!halftone && !eraser) {
current_path = new Path ();
current_path.is_halftone = false;
current_path.points.append (new Point (e.x, e.y));
Expand Down Expand Up @@ -93,7 +102,7 @@ namespace Rakugaki {
Point last = current_path.points.last ().data;
double dx = Math.fabs(last.x - x);
double dy = Math.fabs(last.y - y);
if (Math.sqrt (dx * dx + dy * dy) > 3.0) {
if (Math.sqrt (dx * dx + dy * dy) > 5.0) {
current_path.points.append (new Point (x, y));
da.queue_draw ();
}
Expand Down Expand Up @@ -208,14 +217,31 @@ namespace Rakugaki {
halftone_button.tooltip_text = (_("Change Pen Type"));

halftone_button.clicked.connect ((e) => {
eraser = false;
if (halftone) {
halftone = false;
} else {
halftone = true;
}
});

actionbar.pack_end (halftone_button);
actionbar.pack_end (halftone_button);

var eraser_button = new Gtk.Button ();
eraser_button.set_image (new Gtk.Image.from_icon_name ("eraser-symbolic", Gtk.IconSize.LARGE_TOOLBAR));
eraser_button.has_tooltip = true;
eraser_button.tooltip_text = (_("Eraser"));

eraser_button.clicked.connect ((e) => {
halftone = false;
if (eraser) {
eraser = false;
} else {
eraser = true;
}
});

actionbar.pack_end (eraser_button);

var see_grid_button = new Gtk.Button ();
see_grid_button.set_image (new Gtk.Image.from_icon_name ("grid-dots-symbolic", Gtk.IconSize.LARGE_TOOLBAR));
Expand Down Expand Up @@ -250,15 +276,20 @@ namespace Rakugaki {
public void main_draw (Cairo.Context cr) {
Gtk.Allocation allocation;
get_allocation (out allocation);
draw_grid (cr);
Cairo.ImageSurface sf2 = new Cairo.ImageSurface (Cairo.Format.ARGB32, allocation.width, allocation.height);
Cairo.Context cr2 = new Cairo.Context (sf2);
Gdk.cairo_set_source_rgba (cr2, line_color);
draws (cr2);

Cairo.ImageSurface sf3 = new Cairo.ImageSurface (Cairo.Format.ARGB32, allocation.width, allocation.height);
Cairo.Context cr3 = new Cairo.Context (sf3);
draw_grid (cr3);

cr.set_source_surface (cr2.get_target (), 0, 0);
cr.rectangle (0, 0, allocation.width, allocation.height);
cr.paint ();
cr.set_source_surface (cr3.get_target (), 0, 0);
cr.rectangle (0, 0, allocation.width, allocation.height);
cr.paint ();
}

public void draws (Cairo.Context cr) {
Expand All @@ -268,6 +299,7 @@ namespace Rakugaki {
cr.set_line_join (Cairo.LineJoin.ROUND);
foreach (var path in paths) {
if (path.is_halftone) {
Gdk.cairo_set_source_rgba (cr, line_color);
cr.set_line_width (9);
foreach (var point in path.points.next) {
cr.rectangle (point.x, point.y, 1, 1);
Expand All @@ -290,7 +322,19 @@ namespace Rakugaki {
cr.fill ();
}
cr.stroke ();
} else {
}
if (path.is_eraser) {
Gdk.cairo_set_source_rgba (cr, background_color);
cr.set_line_width (9);
Point first = path.points.first ().data;
cr.move_to (first.x, first.y);
foreach (var point in path.points.next) {
cr.line_to (point.x, point.y);
}
cr.stroke ();
}
if (!path.is_eraser && !path.is_halftone) {
Gdk.cairo_set_source_rgba (cr, line_color);
cr.set_line_width (line_thickness);
Point first = path.points.first ().data;
cr.move_to (first.x, first.y);
Expand Down

0 comments on commit 7d0e05b

Please sign in to comment.