diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-03-23 19:39:06 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-03-23 19:39:06 +0100 |
commit | 38ac62651d156559476f3e147575887781d330b2 (patch) | |
tree | 99843d21369bb3ad3f5ad72071df30c99335c6f3 /src/page-icon.vala | |
parent | e2e8c38f24f25469f2a154c82d2cb9804e9f8785 (diff) | |
parent | 1676db749dc23da9fcd9c767de2f1e9a0c61b2b2 (diff) |
Update upstream source from tag 'upstream/44.0'
Update to upstream version '44.0'
with Debian dir a228d21d874f6f97e085fc1b64e77b9556d9bcfb
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; |