diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2020-01-12 05:26:56 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2020-01-12 05:26:56 +0100 |
| commit | 16da190e44dac0bc3f03444243fa6a2aa482388c (patch) | |
| tree | 837323f7b89d017ac9ee9a334970fd13ff7a2f1e | |
| parent | b7d2519698c3f1c6ff78fdc881ffef056cc91781 (diff) | |
debug window move&resize when win is in container
| -rw-r--r-- | Crow/Default.style | 8 | ||||
| -rwxr-xr-x | Crow/Templates/Window.template | 58 | ||||
| -rw-r--r-- | Crow/src/Interface.cs | 2 | ||||
| -rw-r--r-- | Crow/src/Widgets/Slider.cs | 29 | ||||
| -rw-r--r-- | Crow/src/Widgets/Window.cs | 58 |
5 files changed, 64 insertions, 91 deletions
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 @@ <?xml version="1.0"?> <Border BorderWidth="1" Foreground="Grey" CornerRadius="{./CornerRadius}" Background="{./Background}" - MouseEnter="./onBorderMouseEnter" - MouseLeave="./onBorderMouseLeave"> + > <VerticalStack Spacing="0"> -<!-- <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit" - Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">--> - <HorizontalStack Background="{./TitleBarBackground}" - Name="hs" Margin="2" Spacing="0" Height="Fit"> - <Widget Width="5"/> - <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/> - <Label Width="Stretched" Foreground="{./TitleBarForeground}" Margin="2" TextAlignment="Center" Text="{./Caption}" /> - <Border Visible="{./ShowMinimize}" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" - MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> - <Image Focusable="true" Path="#Crow.Icons.minimize.svg" - MouseClick="./onMinimized"/> - </Border> - <Border Visible="{./ShowNormal}" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" - MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> - <Image Focusable="true" Path="#Crow.Icons.normalize.svg" - MouseClick="./onUnmaximized"/> - </Border> - <Border Visible="{./ShowMaximize}" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" - MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> - <Image Focusable="true" Path="#Crow.Icons.maximize.svg" - MouseClick="./onMaximized"/> - </Border> - <Border BorderWidth="1" Foreground="Transparent" Height="14" Width="14" - MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> - <Image Focusable="true" Path="#Crow.Icons.exit2.svg" - MouseClick="./butQuitPress"/> - </Border> - <Widget Width="5"/> - </HorizontalStack> -<!-- </Border>--> - <Container Name="Content" MinimumSize="0,0"/> + <HorizontalStack Background="{./TitleBarBackground}" + Name="hs" Margin="0" Spacing="0" Height="Fit"> + <Widget Width="5"/> + <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/> + <Label Width="Stretched" Foreground="{./TitleBarForeground}" Margin="2" TextAlignment="Center" Text="{./Caption}" /> + <Border Visible="{./ShowMinimize}" Style="WindowIconBorder"> + <Image Focusable="true" Path="#Crow.Icons.minimize.svg" + MouseClick="./onMinimized"/> + </Border> + <Border Visible="{./ShowNormal}" Style="WindowIconBorder"> + <Image Focusable="true" Path="#Crow.Icons.normalize.svg" + MouseClick="./onUnmaximized"/> + </Border> + <Border Visible="{./ShowMaximize}" Style="WindowIconBorder"> + <Image Focusable="true" Path="#Crow.Icons.maximize.svg" + MouseClick="./onMaximized"/> + </Border> + <Border BorderWidth="1" Style="WindowIconBorder"> + <Image Focusable="true" Path="#Crow.Icons.exit2.svg" + MouseClick="./butQuitPress"/> + </Border> + <Widget Width="5"/> + </HorizontalStack> + <Container Name="Content" MinimumSize="0,0" Margin="4"/> </VerticalStack> </Border> 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 /// <summary>If true, mouse focus is given when mouse is over control</summary> public static bool FOCUS_ON_HOVER = true; /// <summary> Threshold to catch borders for sizing </summary> - public static int BorderThreshold = 5; + public static int BorderThreshold = 10; /// <summary> delay before tooltip appears </summary> public static int TOOLTIP_DELAY = 500; /// <summary>Double click threshold in milisecond</summary> 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 <jp_bruyere@hotmail.com> // -// Author: -// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> -// -// 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) { |