aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-15 14:06:13 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-15 14:06:13 +0100
commit0eb9fb424f826da3cf03bf03e2844ed61df9f594 (patch)
treed3258e3e433ce82241f34bd27eb220e5c69be901 /src/GraphicObjects
parent2def04e1eec8b2ae2ee1cf952a2975f8ca6e8b05 (diff)
draw selected tab last, try mouseIsIn
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/TabItem.cs32
-rw-r--r--src/GraphicObjects/TabView.cs51
2 files changed, 81 insertions, 2 deletions
diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs
index 1f0389d3..3ecce217 100644
--- a/src/GraphicObjects/TabItem.cs
+++ b/src/GraphicObjects/TabItem.cs
@@ -21,19 +21,27 @@
using System;
using System.Xml.Serialization;
using System.ComponentModel;
+using System.Diagnostics;
namespace Crow
{
[DefaultTemplate("#Crow.Templates.TabItem.crow")]
public class TabItem : TemplatedContainer
{
+ #region Private fields
string caption;
Container _contentContainer;
GraphicObject _tabTitle;
+ int tabOffset;
+ #endregion
+ #region CTOR
public TabItem () : base()
{
}
+ #endregion
+
+ #region TemplatedControl overrides
public override GraphicObject Content {
get {
return _contentContainer == null ? null : _contentContainer.Child;
@@ -56,16 +64,17 @@ namespace Crow
_tabTitle = this.child.FindByName ("TabTitle");
}
internal GraphicObject TabTitle { get { return _tabTitle; }}
+ #endregion
#region GraphicObject overrides
- [XmlAttributeAttribute()][DefaultValue(true)]
+ [XmlAttributeAttribute()][DefaultValue(false)]
public override bool Focusable
{
get { return base.Focusable; }
set { base.Focusable = value; }
}
#endregion
- int tabOffset;
+
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int TabOffset {
get { return tabOffset; }
@@ -86,6 +95,25 @@ namespace Crow
NotifyValueChanged ("Caption", caption);
}
}
+ public override bool MouseIsIn (Point m)
+ {
+ if (!Visible)
+ return false;
+
+ Debug.WriteLine ("Mouse Testing " + this.ToString ());
+
+ if (TabTitle.MouseIsIn (m)){
+ Debug.WriteLine ("Mouse is in title of " + this.ToString ());
+ return true;
+ }
+ if (Content.MouseIsIn (m)){
+ Debug.WriteLine ("Mouse is in content of " + this.ToString ());
+ return true;
+ }
+
+ Debug.WriteLine ("Mouse is not in " + this.ToString ());
+ return false;
+ }
protected override void onDraw (Cairo.Context gr)
{
int spacing = (Parent as TabView).Spacing;
diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs
index c9017e49..ab780673 100644
--- a/src/GraphicObjects/TabView.cs
+++ b/src/GraphicObjects/TabView.cs
@@ -23,6 +23,7 @@ using System.Xml.Serialization;
using System.ComponentModel;
using Cairo;
using System.Diagnostics;
+using OpenTK.Input;
namespace Crow
{
@@ -128,6 +129,55 @@ namespace Crow
return base.UpdateLayout(layoutType);
}
+ protected override void onDraw (Context gr)
+ {
+ Rectangle rBack = new Rectangle (Slot.Size);
+
+ Background.SetAsSource (gr, rBack);
+ CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
+ gr.Fill ();
+
+ gr.Save ();
+ //clip to client zone
+ CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+ gr.Clip ();
+
+ for (int i = 0; i < Children.Count; i++) {
+ if (i == SelectedTab)
+ continue;
+ Children [i].Paint (ref gr);
+ }
+ Children [SelectedTab].Paint (ref gr);
+
+ gr.Restore ();
+ }
+
+ #region Mouse handling
+ public override void checkHoverWidget (MouseMoveEventArgs e)
+ {
+ Debug.WriteLine ("TabView check Hover");
+
+ if (HostContainer.hoverWidget != this) {
+ HostContainer.hoverWidget = this;
+ onMouseEnter (this, e);
+ }
+ if (Children[SelectedTab].MouseIsIn(e.Position))
+ {
+ Children[SelectedTab].checkHoverWidget (e);
+ return;
+ }
+ for (int i = Children.Count - 1; i >= 0; i--) {
+ if (i == SelectedTab)
+ continue;
+ if (Children[i].MouseIsIn(e.Position))
+ {
+ Children[i].checkHoverWidget (e);
+ return;
+ }
+ }
+ base.checkHoverWidget (e);
+ }
+ #endregion
void TabTitleLayoutChanged (object sender, LayoutingEventArgs e)
{
@@ -137,6 +187,7 @@ namespace Crow
void Ti_MouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
{
SelectedTab = Children.IndexOf (sender as GraphicObject);
+ Debug.WriteLine ("selected tab: " + (selectedTab + 1).ToString ());
}
}
}