[Xfce4-commits] <xfce4-notes-plugin:master> Add LeftArrow/RightArrow to Xnp.TitleBarButton

Mike Massonnet noreply at xfce.org
Sat Nov 6 21:52:04 CET 2010


Updating branch refs/heads/master
         to 0aff7fedf64d60e82d73d9d31d77aebbdb1c7d56 (commit)
       from b058ce6fb84ce78e6853e5e1288dac50a6039e5d (commit)

commit 0aff7fedf64d60e82d73d9d31d77aebbdb1c7d56
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sat Nov 6 18:24:25 2010 +0100

    Add LeftArrow/RightArrow to Xnp.TitleBarButton

 lib/icon-button.vala |   95 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 80 insertions(+), 15 deletions(-)

diff --git a/lib/icon-button.vala b/lib/icon-button.vala
index 9e9088f..dbf495d 100644
--- a/lib/icon-button.vala
+++ b/lib/icon-button.vala
@@ -101,6 +101,8 @@ namespace Xnp {
 
 	public enum TitleBarButtonType {
 		EMPTY,
+		LEFT_ARROW,
+		RIGHT_ARROW,
 		CLOSE,
 	}
 
@@ -117,12 +119,18 @@ namespace Xnp {
 				case TitleBarButtonType.CLOSE:
 					draw_close_button (cr, width, height);
 					break;
+				case TitleBarButtonType.LEFT_ARROW:
+					draw_left_arrow_button (cr, width, height);
+					break;
+				case TitleBarButtonType.RIGHT_ARROW:
+					draw_right_arrow_button (cr, width, height);
+					break;
 				default:
 					break;
 			}
 		}
 
-		private void draw_close_button (Cairo.Context cr, int width, int height) {
+		private void draw_left_arrow_button (Cairo.Context cr, int width, int height) {
 			int border = 4;
 			int x1 = border;
 			int x2 = width - border;
@@ -134,25 +142,82 @@ namespace Xnp {
 
 			cr.set_line_cap (Cairo.LineCap.ROUND);
 
-			cr.set_source_rgba (1, 1, 1, active ? 0.4 : 0.2);
-			cr.set_line_width (4);
-			cr.move_to (x1, y1);
-			cr.line_to (x2, y2);
-			cr.move_to (x2, y1);
-			cr.line_to (x1, y2);
+			for (int i = 0; i < 2; i++) {
+				if (i == 0) {
+					cr.set_source_rgba (1, 1, 1, active ? 0.4 : 0.2);
+					cr.set_line_width (4);
+				}
+				else {
+					set_widget_source_color (cr);
+					cr.set_line_width (2.66);
+				}
+				cr.move_to (x1, height / 2);
+				cr.line_to (x2, height / 2);
+				cr.move_to (width / 2, y1);
+				cr.line_to (x1, height / 2);
+				cr.line_to (width / 2, y2);
+				cr.stroke ();
+			}
+		}
 
-			cr.stroke ();
+		private void draw_right_arrow_button (Cairo.Context cr, int width, int height) {
+			int border = 4;
+			int x1 = border;
+			int x2 = width - border;
+			int y1 = border;
+			int y2 = height - border;
+			if (x2 <= x1 || y2 <= y1) {
+				return;
+			}
 
-			set_widget_source_color (cr);
-			cr.set_line_width (2.66);
-			cr.move_to (x1, y1);
-			cr.line_to (x2, y2);
-			cr.move_to (x2, y1);
-			cr.line_to (x1, y2);
+			cr.set_line_cap (Cairo.LineCap.ROUND);
 
-			cr.stroke ();
+			for (int i = 0; i < 2; i++) {
+				if (i == 0) {
+					cr.set_source_rgba (1, 1, 1, active ? 0.4 : 0.2);
+					cr.set_line_width (4);
+				}
+				else {
+					set_widget_source_color (cr);
+					cr.set_line_width (2.66);
+				}
+				cr.move_to (x1, height / 2);
+				cr.line_to (x2, height / 2);
+				cr.move_to (width / 2, y1);
+				cr.line_to (x2, height / 2);
+				cr.line_to (width / 2, y2);
+				cr.stroke ();
+			}
 		}
 
+		private void draw_close_button (Cairo.Context cr, int width, int height) {
+			int border = 4;
+			int x1 = border;
+			int x2 = width - border;
+			int y1 = border;
+			int y2 = height - border;
+			if (x2 <= x1 || y2 <= y1) {
+				return;
+			}
+
+			cr.set_line_cap (Cairo.LineCap.ROUND);
+
+			for (int i = 0; i < 2; i++) {
+				if (i == 0) {
+					cr.set_source_rgba (1, 1, 1, active ? 0.4 : 0.2);
+					cr.set_line_width (4);
+				}
+				else {
+					set_widget_source_color (cr);
+					cr.set_line_width (2.66);
+				}
+				cr.move_to (x1, y1);
+				cr.line_to (x2, y2);
+				cr.move_to (x2, y1);
+				cr.line_to (x1, y2);
+				cr.stroke ();
+			}
+		}
 	}
 
 }



More information about the Xfce4-commits mailing list