From: Jean-Philippe Bruyère Date: Sun, 12 Jan 2020 04:26:56 +0000 (+0100) Subject: debug window move&resize when win is in container X-Git-Tag: v0.9.5-beta~137^2~5 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=16da190e44dac0bc3f03444243fa6a2aa482388c;p=jp%2Fcrow.git debug window move&resize when win is in container --- diff --git a/Crow/Default.style b/Crow/Default.style index 8865efc0..c357b1d3 100644 --- a/Crow/Default.style +++ b/Crow/Default.style @@ -110,6 +110,14 @@ Window { Width = "150"; Height = "150"; } +WindowIconBorder { + BorderWidth="1"; + Foreground="Transparent"; + Height="12"; + Width="12"; + MouseEnter="{Foreground=White}"; + MouseLeave="{Foreground=Transparent}"; +} ToolWindow { Caption = "Window"; Template = "#Crow.ToolWindow.template"; diff --git a/Crow/Templates/Window.template b/Crow/Templates/Window.template index 4517279a..4c0c0f1f 100755 --- a/Crow/Templates/Window.template +++ b/Crow/Templates/Window.template @@ -1,39 +1,31 @@  + > - - - - - - - + + + + + diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 72f01bee..ee4f04c6 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -215,7 +215,7 @@ namespace Crow /// If true, mouse focus is given when mouse is over control public static bool FOCUS_ON_HOVER = true; /// Threshold to catch borders for sizing - public static int BorderThreshold = 5; + public static int BorderThreshold = 10; /// delay before tooltip appears public static int TOOLTIP_DELAY = 500; /// Double click threshold in milisecond diff --git a/Crow/src/Widgets/Slider.cs b/Crow/src/Widgets/Slider.cs index acceced0..c4caadb7 100644 --- a/Crow/src/Widgets/Slider.cs +++ b/Crow/src/Widgets/Slider.cs @@ -1,34 +1,9 @@ -// -// Slider.cs +// Copyright (c) 2020 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// 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. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) -using System; using Crow.Cairo; -using System.Xml.Serialization; using System.ComponentModel; -using System.Diagnostics; namespace Crow { diff --git a/Crow/src/Widgets/Window.cs b/Crow/src/Widgets/Window.cs index 23496530..b2cc3b29 100644 --- a/Crow/src/Widgets/Window.cs +++ b/Crow/src/Widgets/Window.cs @@ -272,43 +272,46 @@ namespace Crow Interface otkgw = IFace; - /*if (!hoverBorder) { + if (HasFocus) { + if (movable) { + if (e.Mouse.IsButtonDown (MouseButton.Left)) { + MoveAndResize (e.XDelta, e.YDelta, currentDirection); + return; + } + } + } else { currentDirection = Direction.None; - IFace.MouseCursor = MouseCursor.Arrow; return; - }*/ - - if (this.HasFocus && movable) { - if (e.Mouse.IsButtonDown (MouseButton.Left)) { - MoveAndResize (e.XDelta, e.YDelta, currentDirection); - return; - } } + + + Point m = Parent is Widget ? (Parent as Widget).ScreenPointToLocal (e.Position) : e.Position; + if (Resizable) { Direction lastDir = currentDirection; - if (Math.Abs (e.Position.Y - this.Slot.Y) < Interface.BorderThreshold) { - if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold) + if (Math.Abs (m.Y - this.Slot.Y) < Interface.BorderThreshold) { + if (Math.Abs (m.X - this.Slot.X) < Interface.BorderThreshold) currentDirection = Direction.NW; - else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold) + else if (Math.Abs (m.X - this.Slot.Right) < Interface.BorderThreshold) currentDirection = Direction.NE; else currentDirection = Direction.N; - } else if (Math.Abs (e.Position.Y - this.Slot.Bottom) < Interface.BorderThreshold) { - if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold) + } else if (Math.Abs (m.Y - this.Slot.Bottom) < Interface.BorderThreshold) { + if (Math.Abs (m.X - this.Slot.X) < Interface.BorderThreshold) currentDirection = Direction.SW; - else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold) + else if (Math.Abs (m.X - this.Slot.Right) < Interface.BorderThreshold) currentDirection = Direction.SE; else currentDirection = Direction.S; - } else if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold) + } else if (Math.Abs (m.X - this.Slot.X) < Interface.BorderThreshold) currentDirection = Direction.W; - else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold) + else if (Math.Abs (m.X - this.Slot.Right) < Interface.BorderThreshold) currentDirection = Direction.E; else currentDirection = Direction.None; - if (currentDirection != lastDir) { + //if (currentDirection != lastDir) { switch (currentDirection) { case Direction.None: otkgw.MouseCursor = MouseCursor.Move; @@ -338,9 +341,15 @@ namespace Crow otkgw.MouseCursor = MouseCursor.BottomRight; break; } - } + //} } } + public override void onMouseLeave (object sender, MouseMoveEventArgs e) + { + base.onMouseLeave (sender, e); + currentDirection = Direction.None; + IFace.MouseCursor = MouseCursor.Arrow; + } public override void onMouseDown (object sender, MouseButtonEventArgs e) { base.onMouseDown (sender, e); @@ -397,17 +406,6 @@ namespace Crow Minimize.Raise (sender, e); } - protected virtual void onBorderMouseLeave (object sender, MouseMoveEventArgs e) - { - hoverBorder = false; - currentDirection = Direction.None; - IFace.MouseCursor = MouseCursor.Arrow; - } - protected virtual void onBorderMouseEnter (object sender, MouseMoveEventArgs e) - { - hoverBorder = true; - } - protected void butQuitPress (object sender, MouseButtonEventArgs e) {