diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-03-23 19:39:24 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-03-23 19:39:24 +0100 |
commit | 6737d0d3861c600844df1f8aff167612adc32788 (patch) | |
tree | 99843d21369bb3ad3f5ad72071df30c99335c6f3 /src/page-icon.vala | |
parent | e2e8c38f24f25469f2a154c82d2cb9804e9f8785 (diff) | |
parent | 38ac62651d156559476f3e147575887781d330b2 (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'src/page-icon.vala')
-rw-r--r-- | src/page-icon.vala | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/page-icon.vala b/src/page-icon.vala index f1a25ea..3e3fa93 100644 --- a/src/page-icon.vala +++ b/src/page-icon.vala @@ -14,12 +14,14 @@ public class PageIcon : Gtk.DrawingArea { private char side; private int position; + private int angle; private const int MINIMUM_WIDTH = 20; - public PageIcon (char side, int position) + public PageIcon (char side, int position, int angle) { this.side = side; this.position = position; + this.angle = angle; } public override void get_preferred_width (out int minimum_width, out int natural_width) @@ -73,6 +75,14 @@ public class PageIcon : Gtk.DrawingArea /* Orange 3 */ rgba.parse ("#ff7800"); break; + case 'U': + /* green 4 */ + rgba.parse ("#5cc02e"); + break; + case 'R': + /* blue 4 */ + rgba.parse ("#0deee7"); + break; default: /* Yellow 3 to Red 2 */ Gdk.RGBA start = {}, end = {}; @@ -109,8 +119,15 @@ public class PageIcon : Gtk.DrawingArea var text = @"$(position + 1)"; Cairo.TextExtents extents; + + var rad = Math.PI / 180.0 * angle; c.text_extents (text, out extents); - c.translate ((w - extents.width) * 0.5 - 0.5, (h + extents.height) * 0.5 - 0.5); + c.translate ((w - extents.width) * 0.5 - 0.5, extents.height + (h - extents.height) * 0.5 - 0.5); + c.rotate(rad); + // only correct for 0 and 180 degree + var tx = (1.0 - Math.sin(rad)) * extents.width / 2; + var ty = (1.0 - Math.sin(rad)) * extents.height / 2; + c.translate(-tx, +ty); c.show_text (text); return true; |