diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-12-06 17:36:21 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-12-06 17:36:21 +0100 |
| commit | 309945235a6bfd0c16cd64b8a0ad2501d7b62b50 (patch) | |
| tree | 42ca544a3b08175f2389709958fe860ba7d487fe /src/GraphicObjects | |
| parent | 78592468fe75f09299e12d8a8fbb94635a2befd6 (diff) | |
wip
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/DockStack.cs | 11 | ||||
| -rw-r--r-- | src/GraphicObjects/DockWindow.cs | 13 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 58 | ||||
| -rw-r--r-- | src/GraphicObjects/TabItem.cs | 41 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedGroup.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/TreeView.cs | 8 |
6 files changed, 75 insertions, 58 deletions
diff --git a/src/GraphicObjects/DockStack.cs b/src/GraphicObjects/DockStack.cs index aa7c33da..75f0d2bb 100644 --- a/src/GraphicObjects/DockStack.cs +++ b/src/GraphicObjects/DockStack.cs @@ -116,9 +116,9 @@ namespace Crow { if (IsDropTarget) { DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow; - if (dw.IsDocked) { - base.onMouseMove (sender, e); - return; + if (dw == null || dw.IsDocked) { + base.onMouseMove (sender, e); + return; } Alignment curDockPos = dw.DockingPosition; @@ -416,6 +416,9 @@ namespace Crow dw.Width = Measure.Parse (getConfAttrib (conf, ref i)); dw.Height = Measure.Parse (getConfAttrib (conf, ref i)); dw.DockingPosition = (Alignment)Enum.Parse (typeof(Alignment), getConfAttrib (conf, ref i)); + dw.savedSlot = Rectangle.Parse (getConfAttrib (conf, ref i)); + dw.wasResizable = Boolean.Parse (getConfAttrib (conf, ref i)); + dw.IsDocked = true; dw.DataSource = dataSource; this.AddChild (dw); @@ -450,7 +453,7 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (Children [i] is DockWindow) { DockWindow dw = Children [i] as DockWindow; - tmp.Append (string.Format("WIN;{0};{1};{2};{3};",dw.Name, dw.Width, dw.Height, dw.DockingPosition)); + tmp.Append (string.Format("WIN;{0};{1};{2};{3};{4};{5};",dw.Name, dw.Width, dw.Height, dw.DockingPosition, dw.savedSlot, dw.wasResizable)); } else if (Children [i] is DockStack) { DockStack ds = Children [i] as DockStack; tmp.Append (string.Format("STK;{0};{1};{2};{3}", ds.Width, ds.Height, ds.Orientation, ds.exportConfig())); diff --git a/src/GraphicObjects/DockWindow.cs b/src/GraphicObjects/DockWindow.cs index d6385057..e368db51 100644 --- a/src/GraphicObjects/DockWindow.cs +++ b/src/GraphicObjects/DockWindow.cs @@ -40,8 +40,8 @@ namespace Crow Alignment docking = Alignment.Undefined; Point undockingMousePosOrig; //mouse pos when docking was donne, use for undocking on mouse move - Rectangle savedSlot; //last undocked slot recalled when view is undocked - bool wasResizable; + internal Rectangle savedSlot; //last undocked slot recalled when view is undocked + internal bool wasResizable; public bool IsDocked { get { return isDocked; } @@ -64,7 +64,6 @@ namespace Crow NotifyValueChanged ("DockingPosition", DockingPosition); } } - public override bool PointIsIn (ref Point m) { if (!base.PointIsIn(ref m)) @@ -136,10 +135,10 @@ namespace Crow IFace.AddWidget (this); - this.Left = savedSlot.Left; - this.Top = savedSlot.Top; - this.Width = savedSlot.Width; - this.Height = savedSlot.Height; + Left = savedSlot.Left; + Top = savedSlot.Top; + Width = savedSlot.Width; + Height = savedSlot.Height; IsDocked = false; DockingPosition = Alignment.Undefined; diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 747609b0..ec4fa173 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -277,14 +277,14 @@ namespace Crow Fill background = Color.Transparent; Fill foreground = Color.White; Font font = "droid, 10"; - Measure width, height; + protected Measure width, height; int left, top; double cornerRadius = 0; int margin = 0; bool focusable = false; bool hasFocus = false; bool isActive = false; - bool isHover = false; + //bool isHover = false; bool mouseRepeat; protected bool isVisible = true; bool isEnabled = true; @@ -436,9 +436,9 @@ namespace Crow /// <summary>Occurs when this object loose focus</summary> public event EventHandler Unfocused; /// <summary>Occurs when mouse is over</summary> - public event EventHandler Hover; + //public event EventHandler Hover; /// <summary>Occurs when this control is no longer the Hover one</summary> - public event EventHandler UnHover; + //public event EventHandler UnHover; /// <summary>Occurs when this object loose focus</summary> public event EventHandler Enabled; /// <summary>Occurs when the enabled state this object is set to false</summary> @@ -744,7 +744,7 @@ namespace Crow /// <summary> /// true if this control has the pointer hover /// </summary> - [XmlIgnore]public virtual bool IsHover { + /*[XmlIgnore]public virtual bool IsHover { get { return isHover; } set { if (value == isHover) @@ -759,7 +759,7 @@ namespace Crow NotifyValueChanged ("IsHover", isHover); } - } + }*/ /// <summary> /// true if holding mouse button down should trigger multiple click events /// </summary> @@ -866,8 +866,12 @@ namespace Crow RegisterForLayouting (LayoutingType.Sizing); - if (!isVisible) - unshownPostActions (); + if (!isVisible && IFace.HoverWidget != null) { + if (IFace.HoverWidget.IsOrIsInside (this)) { + //IFace.HoverWidget = null; + IFace.ProcessMouseMove (IFace.Mouse.X, IFace.Mouse.Y); + } + } NotifyValueChanged ("Visible", isVisible); } @@ -1877,20 +1881,7 @@ namespace Crow #if DEBUG_FOCUS Debug.WriteLine("MouseEnter => " + this.ToString()); #endif - MouseEnter.Raise (this, e); - } - public virtual void onMouseLeave(object sender, MouseMoveEventArgs e) - { - #if DEBUG_FOCUS - Debug.WriteLine("MouseLeave => " + this.ToString()); - #endif - MouseLeave.Raise (this, e); - } - public virtual void onHover(object sender, EventArgs e) - { - #if DEBUG_FOCUS - Debug.WriteLine("MouseHover => " + this.ToString()); - #endif + if (IFace.DragAndDropOperation != null) { GraphicObject g = this; while (g != null) { @@ -1905,15 +1896,18 @@ namespace Crow g = g.focusParent; } } - Hover.Raise (this, e); + + MouseEnter.Raise (this, e); } - public virtual void onUnHover(object sender, EventArgs e) + public virtual void onMouseLeave(object sender, MouseMoveEventArgs e) { #if DEBUG_FOCUS - Debug.WriteLine("MouseUnHover => " + this.ToString()); + Debug.WriteLine("MouseLeave => " + this.ToString()); #endif - UnHover.Raise (this, e); + + MouseLeave.Raise (this, e); } + #endregion protected virtual void onFocused(object sender, EventArgs e){ @@ -1981,6 +1975,12 @@ namespace Crow /// Checks to handle when widget is removed from the visible graphic tree /// </summary> void unshownPostActions () { + if (IFace.HoverWidget != null) { + if (IFace.HoverWidget.IsOrIsInside (this)) { + IFace.HoverWidget = null; + IFace.ProcessMouseMove (IFace.Mouse.X, IFace.Mouse.Y); + } + } if (IFace.ActiveWidget != null) { if (IFace.ActiveWidget.IsOrIsInside (this)) IFace.ActiveWidget = null; @@ -1989,12 +1989,6 @@ namespace Crow if (IFace.FocusedWidget.IsOrIsInside (this)) IFace.FocusedWidget = null; } - if (IFace.HoverWidget != null) { - if (IFace.HoverWidget.IsOrIsInside (this)) { - IFace.HoverWidget = null; - IFace.ProcessMouseMove (IFace.Mouse.X, IFace.Mouse.Y); - } - } } } } diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index 8ddd7a8e..52fdbfef 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -49,6 +49,7 @@ namespace Crow int tabOffset; bool isSelected; Measure tabThickness; + Fill selectedBackground = Color.Transparent; #endregion #region TemplatedControl overrides @@ -115,8 +116,30 @@ namespace Crow set { if (isSelected == value) return; + + if (tview != null) + tview.SelectedTab = tview.Children.IndexOf(this); + isSelected = value; NotifyValueChanged ("IsSelected", isSelected); + RegisterForRedraw (); + } + } + + /// <summary> + /// background fill of the control, maybe solid color, gradient, image, or svg + /// </summary> + [DesignCategory ("Appearance")][DefaultValue("DimGrey")] + public virtual Fill SelectedBackground { + get { return selectedBackground; } + set { + if (selectedBackground == value) + return; + if (value == null) + return; + selectedBackground = value; + NotifyValueChanged ("SelectedBackground", selectedBackground); + RegisterForRedraw (); } } protected override void onDraw (Context gr) @@ -150,7 +173,11 @@ namespace Crow gr.StrokePreserve (); gr.ClipPreserve (); - Background.SetAsSource (gr); + if (IsSelected) + SelectedBackground.SetAsSource (gr, ClientRectangle); + else + Background.SetAsSource (gr, ClientRectangle); + gr.Fill (); base.onDraw (gr); @@ -162,14 +189,8 @@ namespace Crow int dragThreshold = 16; int dis = 128; internal TabView savedParent = null; - public override Fill Background { - get { - return base.Background; - } - set { - base.Background = value; - } - } + + void makeFloating (TabView tv) { lock (IFace.UpdateMutex) { ImageSurface di = new ImageSurface (Format.Argb32, dis, dis); @@ -252,7 +273,7 @@ namespace Crow public override void onMouseUp (object sender, MouseButtonEventArgs e) { base.onMouseUp (sender, e); - tview.UpdateLayout (LayoutingType.ArrangeChildren); + tview?.UpdateLayout (LayoutingType.ArrangeChildren); } public override void onMouseMove (object sender, MouseMoveEventArgs e) { diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index 73681b9d..4d236dab 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -148,7 +148,7 @@ namespace Crow : items.Children; } } - [XmlAttributeAttribute][DefaultValue(-1)]public virtual int SelectedIndex{ + [DefaultValue(-1)]public virtual int SelectedIndex{ get { return _selectedIndex; } set { if (value == _selectedIndex) diff --git a/src/GraphicObjects/TreeView.cs b/src/GraphicObjects/TreeView.cs index 2c3f817f..12a99fb3 100644 --- a/src/GraphicObjects/TreeView.cs +++ b/src/GraphicObjects/TreeView.cs @@ -67,13 +67,13 @@ namespace Crow GraphicObject tmp = sender as GraphicObject; if (!tmp.HasFocus) return; - if (selectedItemContainer != null) { + /*if (selectedItemContainer != null) { selectedItemContainer.Foreground = Color.Transparent; selectedItemContainer.Background = Color.Transparent; - } + }*/ selectedItemContainer = tmp; - selectedItemContainer.Foreground = SelectionForeground; - selectedItemContainer.Background = SelectionBackground; + //selectedItemContainer.Foreground = SelectionForeground; + //selectedItemContainer.Background = SelectionBackground; NotifyValueChanged ("SelectedItem", SelectedItem); raiseSelectedItemChanged (); } |