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";
<?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>
/// <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>
-//
-// 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
{
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;
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);
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)
{