summaryrefslogtreecommitdiff
path: root/src/page-icon.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-06-30 20:45:42 +0200
committerJörg Frings-Fürst <debian@jff.email>2024-06-30 20:45:42 +0200
commit26d8dd51f3ecc4bd6861ed5155acb3090a1983d4 (patch)
tree08d9369065e32f20a80f9cf916a5b1a468b39527 /src/page-icon.vala
parent1676db749dc23da9fcd9c767de2f1e9a0c61b2b2 (diff)
New upstream version 46.0upstream/46.0upstream
Diffstat (limited to 'src/page-icon.vala')
-rw-r--r--src/page-icon.vala135
1 files changed, 0 insertions, 135 deletions
diff --git a/src/page-icon.vala b/src/page-icon.vala
deleted file mode 100644
index 3e3fa93..0000000
--- a/src/page-icon.vala
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2009-2017 Canonical Ltd.
- * Author: Robert Ancell <robert.ancell@canonical.com>,
- * Eduard Gotwig <g@ox.io>
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-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, 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)
- {
- minimum_width = natural_width = MINIMUM_WIDTH;
- }
-
- public override void get_preferred_height (out int minimum_height, out int natural_height)
- {
- minimum_height = natural_height = (int) Math.round (MINIMUM_WIDTH * Math.SQRT2);
- }
-
- public override void get_preferred_height_for_width (int width, out int minimum_height, out int natural_height)
- {
- minimum_height = natural_height = (int) (width * Math.SQRT2);
- }
-
- public override void get_preferred_width_for_height (int height, out int minimum_width, out int natural_width)
- {
- minimum_width = natural_width = (int) (height / Math.SQRT2);
- }
-
- public override bool draw (Cairo.Context c)
- {
- var w = get_allocated_width ();
- var h = get_allocated_height ();
- if (w * Math.SQRT2 > h)
- w = (int) Math.round (h / Math.SQRT2);
- else
- h = (int) Math.round (w * Math.SQRT2);
-
- c.translate ((get_allocated_width () - w) / 2, (get_allocated_height () - h) / 2);
-
- bool dark = Hdy.StyleManager.get_default ().dark;
- bool hc = Hdy.StyleManager.get_default ().high_contrast;
-
- if (dark && !hc)
- c.rectangle (1, 1, w - 2, h - 2);
- else
- c.rectangle (0, 0, w, h);
-
- Gdk.RGBA rgba = {};
-
- switch (side)
- {
- case 'F':
- /* Purple 2 */
- rgba.parse ("#c061cb");
- break;
- case 'B':
- /* 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 = {};
- start.parse ("#f6d32d");
- end.parse ("#ed333b");
-
- double progress = position / 5.0;
- rgba.red = start.red + (end.red - start.red) * progress;
- rgba.green = start.green + (end.green - start.green) * progress;
- rgba.blue = start.blue + (end.blue - start.blue) * progress;
- break;
- }
-
- rgba.alpha = 0.3;
-
- Gdk.cairo_set_source_rgba (c, rgba);
- c.fill ();
-
- c.set_line_width (1.0);
- if (hc && dark)
- c.set_source_rgba (1, 1, 1, 0.5);
- else if (hc)
- c.set_source_rgba (0, 0, 0, 0.5);
- else
- c.set_source_rgba (0, 0, 0, 0.15);
-
- c.rectangle (0.5, 0.5, w - 1, h - 1);
- c.stroke ();
-
- if (dark)
- c.set_source_rgb (1, 1, 1);
- else
- c.set_source_rgb (0, 0, 0);
-
- 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, 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;
- }
-}