summaryrefslogtreecommitdiff
path: root/src/book.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-03-23 19:39:24 +0100
committerJörg Frings-Fürst <debian@jff.email>2023-03-23 19:39:24 +0100
commit6737d0d3861c600844df1f8aff167612adc32788 (patch)
tree99843d21369bb3ad3f5ad72071df30c99335c6f3 /src/book.vala
parente2e8c38f24f25469f2a154c82d2cb9804e9f8785 (diff)
parent38ac62651d156559476f3e147575887781d330b2 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'src/book.vala')
-rw-r--r--src/book.vala26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/book.vala b/src/book.vala
index d2aa54d..e25eb35 100644
--- a/src/book.vala
+++ b/src/book.vala
@@ -11,6 +11,12 @@
public delegate void ProgressionCallback (double fraction);
+// Assumes first page has index 0
+public enum FlipEverySecond {
+ Even = 1,
+ Odd = 0,
+}
+
public class Book : Object
{
private List<Page> pages;
@@ -99,6 +105,26 @@ public class Book : Object
changed ();
}
+ public void flip_every_second (FlipEverySecond flip)
+ {
+ var new_pages = new List<Page> ();
+ for (var i = 0; i < n_pages; i++)
+ {
+ var page = pages.nth_data (i);
+ if (i % 2 == (int)flip) {
+ page.rotate_left();
+ page.rotate_left();
+ new_pages.append (page);
+ } else {
+ new_pages.append (page);
+ }
+ }
+ pages = (owned) new_pages;
+
+ reordered ();
+ changed ();
+ }
+
public void combine_sides_reverse ()
{
var new_pages = new List<Page> ();