summaryrefslogtreecommitdiff
path: root/src/page-icon.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-28 21:39:42 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-28 21:39:42 +0200
commit408791709f23be34de957320384d02b228ea488f (patch)
treeca384fbb40da0add2aff715028fc6eff26934943 /src/page-icon.vala
parent4e699c8b150e8705f7b9b85742da2bbaab17358c (diff)
parent76380dae2a51f98cb6269e209bc39133a31372a4 (diff)
Merge branch 'release/debian/44.0-1'debian/44.0-1
Diffstat (limited to 'src/page-icon.vala')
-rw-r--r--src/page-icon.vala21
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;