diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-03-23 19:39:03 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-03-23 19:39:03 +0100 |
commit | 1676db749dc23da9fcd9c767de2f1e9a0c61b2b2 (patch) | |
tree | d575e4db5a722421795ed6194da81d50d5a7fae4 /src/page-icon.vala | |
parent | c4ee1d5857bc5b93d501a42a070be1d9faa3a48a (diff) |
New upstream version 44.0upstream/44.0upstream
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; |