banshee r3102 - in trunk/banshee: . src/Core/Hyena.Gui src/Core/Hyena.Gui/Hyena.Data.Gui src/Core/Hyena.Gui/Hyena.Widgets src/Core/Nereid/Nereid
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3102 - in trunk/banshee: . src/Core/Hyena.Gui src/Core/Hyena.Gui/Hyena.Data.Gui src/Core/Hyena.Gui/Hyena.Widgets src/Core/Nereid/Nereid
- Date: Wed, 30 Jan 2008 22:07:44 +0000 (GMT)
Author: abock
Date: Wed Jan 30 22:07:43 2008
New Revision: 3102
URL: http://svn.gnome.org/viewvc/banshee?rev=3102&view=rev
Log:
2008-01-30 Aaron Bockover <abock gnome org>
* src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs: Added a DrawFrame
method to simply draw the entire ListView like frame around a rect
* src/Core/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs: A widget like the
standard Gtk.Frame, except it uses our ListViewGraphics to draw a sexy
rounded frame that blends in with the list views
* src/Core/Hyena.Gui/Hyena.Widgets/ScrolledWindow.cs: A custom
ScrolledWindow that proxies Hadjustmend and Vadjustment of the child
of a RoundedFrame if one is added to the ScrolledWindow
* src/Core/Nereid/Nereid/PlayerInterface.cs: Use a Hyena ScrolledWindow
with AddFrame to make the source view TreeView look like our ListView
widgets - dead sexy
Added:
trunk/banshee/src/Core/Hyena.Gui/Hyena.Widgets/
trunk/banshee/src/Core/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Widgets/ScrolledWindow.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp
trunk/banshee/src/Core/Hyena.Gui/Makefile.am
trunk/banshee/src/Core/Nereid/Nereid/PlayerInterface.cs
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs Wed Jan 30 22:07:43 2008
@@ -203,6 +203,23 @@
}
}
+ public void DrawFrame (Cairo.Context cr, Gdk.Rectangle alloc, bool baseColor)
+ {
+ CairoCorners corners = CairoCorners.All;
+
+ cr.Color = baseColor
+ ? GetWidgetColor (GtkColorClass.Base, StateType.Normal)
+ : GetWidgetColor (GtkColorClass.Background, StateType.Normal);
+ CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, BorderRadius, corners);
+ cr.Fill ();
+
+ cr.LineWidth = 1.0;
+ cr.Translate (0.5, 0.5);
+ cr.Color = border_color;
+ CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height - 1, BorderRadius, corners);
+ cr.Stroke();
+ }
+
public void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset)
{
Cairo.Color gtk_selection_color = GetWidgetColor(GtkColorClass.Background, StateType.Selected);
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp Wed Jan 30 22:07:43 2008
@@ -28,6 +28,9 @@
<File name="Hyena.Gui/GtkUtilities.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Gui/CellContext.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Gui/IHeaderCell.cs" subtype="Code" buildaction="Compile" />
+ <File name="Hyena.Widgets" subtype="Directory" buildaction="Compile" />
+ <File name="Hyena.Widgets/ScrolledWindow.cs" subtype="Code" buildaction="Compile" />
+ <File name="Hyena.Widgets/RoundedFrame.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Added: trunk/banshee/src/Core/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs Wed Jan 30 22:07:43 2008
@@ -0,0 +1,158 @@
+//
+// RoundedFrame.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 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;
+using Cairo;
+
+using Hyena.Gui;
+using Hyena.Data.Gui;
+
+namespace Hyena.Widgets
+{
+ public class RoundedFrame : Bin
+ {
+ private ListViewGraphics graphics;
+ private int frame_width = 4;
+ private int border_width = 0;
+
+ private Widget child;
+ private Gdk.Rectangle child_allocation;
+
+
+ public RoundedFrame ()
+ {
+ }
+
+#region Gtk.Widget Overrides
+
+ protected override void OnRealized ()
+ {
+ base.OnRealized ();
+
+ graphics = new ListViewGraphics (this);
+ graphics.RefreshColors ();
+ }
+
+ protected override void OnSizeRequested (ref Requisition requisition)
+ {
+ if (child == null) {
+ return;
+ }
+
+ int width = requisition.Width;
+ int height = requisition.Height;
+
+ child.GetSizeRequest (out width, out height);
+ if (width == -1 || height == -1) {
+ width = height = 80;
+ }
+
+ SetSizeRequest (width + (border_width + frame_width) * 2,
+ height + (border_width + frame_width) * 2);
+ }
+
+ protected override void OnSizeAllocated (Gdk.Rectangle allocation)
+ {
+ base.OnSizeAllocated (allocation);
+
+ child_allocation = new Gdk.Rectangle ();
+
+ if (child == null || !child.Visible) {
+ return;
+ }
+
+ child_allocation.X = border_width + frame_width;
+ child_allocation.Y = border_width + frame_width;
+ child_allocation.Width = (int)Math.Max (1, Allocation.Width - child_allocation.X * 2);
+ child_allocation.Height = (int)Math.Max (1, Allocation.Height - child_allocation.Y -
+ border_width - frame_width);
+
+ child_allocation.X += Allocation.X;
+ child_allocation.Y += Allocation.Y;
+
+ child.SizeAllocate (child_allocation);
+ }
+
+ protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ {
+ if (!IsDrawable) {
+ return false;
+ }
+
+ Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window);
+
+ try {
+ DrawFrame (cr, evnt.Area);
+ return false;
+ } finally {
+ ((IDisposable)cr.Target).Dispose ();
+ ((IDisposable)cr).Dispose ();
+ }
+ }
+
+ private void DrawFrame (Cairo.Context cr, Gdk.Rectangle clip)
+ {
+ int x = child_allocation.X - frame_width;
+ int y = child_allocation.Y - frame_width;
+ int width = child_allocation.Width + 2 * frame_width;
+ int height = child_allocation.Height + 2 * frame_width;
+
+ graphics.DrawFrame (cr, new Gdk.Rectangle (x, y, width, height), true);
+ }
+
+#endregion
+
+#region Gtk.Container Overrides
+
+ protected override void OnAdded (Widget widget)
+ {
+ child = widget;
+ base.OnAdded (widget);
+ }
+
+ protected override void OnRemoved (Widget widget)
+ {
+ if (child == widget) {
+ child = null;
+ }
+
+ base.OnRemoved (widget);
+ }
+
+#endregion
+
+ public int BorderWidth {
+ get { return border_width; }
+ set {
+ border_width = value;
+ QueueResize ();
+ }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Hyena.Gui/Hyena.Widgets/ScrolledWindow.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Widgets/ScrolledWindow.cs Wed Jan 30 22:07:43 2008
@@ -0,0 +1,122 @@
+//
+// ScrolledWindow.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 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 System.Reflection;
+
+using Gtk;
+using Gdk;
+using Cairo;
+
+using Hyena.Gui;
+using Hyena.Data.Gui;
+
+namespace Hyena.Widgets
+{
+ public class ScrolledWindow : Gtk.ScrolledWindow
+ {
+ private Widget adjustable;
+ private RoundedFrame rounded_frame;
+
+ public ScrolledWindow ()
+ {
+ }
+
+ public void AddWithFrame (Widget widget)
+ {
+ RoundedFrame frame = new RoundedFrame ();
+ frame.Add (widget);
+ frame.Show ();
+
+ Add (frame);
+ ProbeAdjustable (widget);
+ }
+
+ protected override void OnAdded (Widget widget)
+ {
+ if (widget is RoundedFrame) {
+ rounded_frame = (RoundedFrame)widget;
+ rounded_frame.Added += OnFrameWidgetAdded;
+ rounded_frame.Removed += OnFrameWidgetRemoved;
+ }
+
+ base.OnAdded (widget);
+ }
+
+ protected override void OnRemoved (Widget widget)
+ {
+ if (widget == rounded_frame) {
+ rounded_frame.Added -= OnFrameWidgetAdded;
+ rounded_frame.Removed -= OnFrameWidgetRemoved;
+ rounded_frame = null;
+ }
+
+ base.OnRemoved (widget);
+ }
+
+ private void OnFrameWidgetAdded (object o, AddedArgs args)
+ {
+ if (rounded_frame != null) {
+ ProbeAdjustable (args.Widget);
+ }
+ }
+
+ private void OnFrameWidgetRemoved (object o, RemovedArgs args)
+ {
+ if (adjustable != null && adjustable == args.Widget) {
+ Hadjustment = null;
+ Vadjustment = null;
+ adjustable = null;
+ }
+ }
+
+ private void ProbeAdjustable (Widget widget)
+ {
+ Type type = widget.GetType ();
+
+ PropertyInfo hadj_prop = type.GetProperty ("Hadjustment");
+ PropertyInfo vadj_prop = type.GetProperty ("Vadjustment");
+
+ if (hadj_prop == null || vadj_prop == null) {
+ return;
+ }
+
+ object hadj_value = hadj_prop.GetValue (widget, null);
+ object vadj_value = vadj_prop.GetValue (widget, null);
+
+ if (hadj_value == null || vadj_value == null
+ || hadj_value.GetType () != typeof (Adjustment)
+ || vadj_value.GetType () != typeof (Adjustment)) {
+ return;
+ }
+
+ Hadjustment = (Adjustment)hadj_value;
+ Vadjustment = (Adjustment)vadj_value;
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Hyena.Gui/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Makefile.am (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Makefile.am Wed Jan 30 22:07:43 2008
@@ -21,7 +21,9 @@
Hyena.Gui/EntryEraseAction.cs \
Hyena.Gui/EntryInsertAction.cs \
Hyena.Gui/EntryUndoAdapter.cs \
- Hyena.Gui/GtkUtilities.cs
+ Hyena.Gui/GtkUtilities.cs \
+ Hyena.Widgets/RoundedFrame.cs \
+ Hyena.Widgets/ScrolledWindow.cs
include $(top_srcdir)/build/build.mk
Modified: trunk/banshee/src/Core/Nereid/Nereid/PlayerInterface.cs
==============================================================================
--- trunk/banshee/src/Core/Nereid/Nereid/PlayerInterface.cs (original)
+++ trunk/banshee/src/Core/Nereid/Nereid/PlayerInterface.cs Wed Jan 30 22:07:43 2008
@@ -169,9 +169,8 @@
source_view = new SourceView ();
composite_view = new CompositeTrackListView ();
- ScrolledWindow source_scroll = new ScrolledWindow ();
- source_scroll.ShadowType = ShadowType.In;
- source_scroll.Add (source_view);
+ Hyena.Widgets.ScrolledWindow source_scroll = new Hyena.Widgets.ScrolledWindow ();
+ source_scroll.AddWithFrame (source_view);
composite_view.TrackView.HeaderVisible = false;
view_container.Content = composite_view;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]