[hyena] [Hyena.Gui] New GrabHandle widget
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] [Hyena.Gui] New GrabHandle widget
- Date: Wed, 13 Oct 2010 21:35:27 +0000 (UTC)
commit 37c984fc7254403c5ca8ed0095616f3af9715e79
Author: Gabriel Burt <gabriel burt gmail com>
Date: Wed Oct 13 16:35:14 2010 -0500
[Hyena.Gui] New GrabHandle widget
Hyena.Gui/Hyena.Gui.csproj | 1 +
Hyena.Gui/Hyena.Widgets/GrabHandle.cs | 90 +++++++++++++++++++++++++++++++++
Hyena.Gui/Makefile.am | 1 +
3 files changed, 92 insertions(+), 0 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui.csproj b/Hyena.Gui/Hyena.Gui.csproj
index a428722..37f0e6b 100644
--- a/Hyena.Gui/Hyena.Gui.csproj
+++ b/Hyena.Gui/Hyena.Gui.csproj
@@ -178,6 +178,7 @@
<Compile Include="Hyena.Gui\ActionManager.cs" />
<Compile Include="Hyena.Gui\HyenaActionGroup.cs" />
<Compile Include="Hyena.Widgets\GenericToolItem.cs" />
+ <Compile Include="Hyena.Widgets\GrabHandle.cs" />
<Compile Include="Hyena.Widgets\HigMessageDialog.cs" />
<Compile Include="Hyena.Widgets\EntryPopup.cs" />
<Compile Include="Hyena.Widgets\SimpleTable.cs" />
diff --git a/Hyena.Gui/Hyena.Widgets/GrabHandle.cs b/Hyena.Gui/Hyena.Widgets/GrabHandle.cs
new file mode 100644
index 0000000..82e1e90
--- /dev/null
+++ b/Hyena.Gui/Hyena.Widgets/GrabHandle.cs
@@ -0,0 +1,90 @@
+//
+// GrabHandle.cs
+//
+// Author:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Gtk;
+
+namespace Hyena.Widgets
+{
+ public class GrabHandle : EventBox
+ {
+ Gtk.DrawingArea da;
+
+ public GrabHandle () : this (5, 28) {}
+
+ public GrabHandle (int w, int h)
+ {
+ da = new DrawingArea ();
+ da.SetSizeRequest (w, h);
+ Orientation = Gtk.Orientation.Vertical;
+
+ Child = da;
+ ShowAll ();
+
+ ButtonPressEvent += (o, a) => Dragging = true;
+ ButtonReleaseEvent += (o, a) => Dragging = false;
+ EnterNotifyEvent += (o, a) => Inside = true;
+ LeaveNotifyEvent += (o, a) => Inside = false;
+
+ da.ExposeEvent += (o, a) => {
+ if (da.IsDrawable) {
+ Gtk.Style.PaintHandle (da.Style, da.GdkWindow, da.State, ShadowType.In,
+ a.Event.Area, this, "entry", 0, 0, da.Allocation.Width, da.Allocation.Height, Orientation);
+ }
+ };
+ }
+
+ public void ControlWidthOf (Widget widget, int min, int max, bool grabberOnRight)
+ {
+ MotionNotifyEvent += (o, a) => {
+ var x = a.Event.X;
+ var w = Math.Min (max, Math.Max (min, widget.WidthRequest + (grabberOnRight ? 1 : -1 ) * x));
+ widget.WidthRequest = (int)w;
+ };
+ }
+
+ public Gtk.Orientation Orientation { get; set; }
+
+ private bool inside, dragging;
+ private bool Inside {
+ set {
+ inside = value;
+ GdkWindow.Cursor = dragging || inside ? resize_cursor : null;
+ }
+ }
+
+ private bool Dragging {
+ set {
+ dragging = value;
+ GdkWindow.Cursor = dragging || inside ? resize_cursor : null;
+ }
+ }
+
+ private static Gdk.Cursor resize_cursor = new Gdk.Cursor (Gdk.CursorType.SbHDoubleArrow);
+ }
+}
diff --git a/Hyena.Gui/Makefile.am b/Hyena.Gui/Makefile.am
index 756ac3e..a3a5018 100644
--- a/Hyena.Gui/Makefile.am
+++ b/Hyena.Gui/Makefile.am
@@ -103,6 +103,7 @@ SOURCES = \
Hyena.Widgets/ComplexMenuItem.cs \
Hyena.Widgets/EntryPopup.cs \
Hyena.Widgets/GenericToolItem.cs \
+ Hyena.Widgets/GrabHandle.cs \
Hyena.Widgets/HigMessageDialog.cs \
Hyena.Widgets/ImageButton.cs \
Hyena.Widgets/MenuButton.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]