]> O.S.I.I.S - jp/crow.git/commitdiff
debug window move&resize when win is in container
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 12 Jan 2020 04:26:56 +0000 (05:26 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 12 Jan 2020 04:26:56 +0000 (05:26 +0100)
Crow/Default.style
Crow/Templates/Window.template
Crow/src/Interface.cs
Crow/src/Widgets/Slider.cs
Crow/src/Widgets/Window.cs

index 8865efc0bd6f893c6f68d19e5330ebac613682d4..c357b1d336dfab8ff5c01a9edda5a91dd4a9742d 100644 (file)
@@ -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";
index 4517279ae7de1cdd97faa8fae4269a43625811fb..4c0c0f1fbef98fffaf660f5f938cc0964736d2ab 100755 (executable)
@@ -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>
index 72f01bee3f51b30772a59d20c936b4e54011fd7f..ee4f04c64ee29abe2c1e0185cd1623da7c8f7899 100644 (file)
@@ -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>
index acceced0413001e19767a819e590180f20d8f2a4..c4caadb7bf36facabbffab58647d44437b21b2f7 100644 (file)
@@ -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
 {
index 23496530026f0d4685497fd6b51307a16b1d7d79..b2cc3b2907b49de254b9c6c46d4fc70b6184f773 100644 (file)
@@ -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)
                {