]> O.S.I.I.S - jp/crow.git/commitdiff
maximize and minimize for window
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 24 Jan 2017 00:54:22 +0000 (01:54 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 24 Jan 2017 00:54:22 +0000 (01:54 +0100)
Crow.csproj
Default.style
Images/Icons/exit.svg
Images/Icons/maximize.svg [new file with mode: 0644]
Images/Icons/minimize.svg [new file with mode: 0644]
Images/Icons/normalize.svg [new file with mode: 0644]
Templates/ToolWindow.template [new file with mode: 0755]
Templates/Window.template
src/GraphicObjects/Window.cs

index b541152c14e9b51ab86461903379d2a274986c27..d66d6f66b4a37a904f3df81a8b74162ff07e0db9 100644 (file)
     <EmbeddedResource Include="Templates\ColorPicker.template">
       <LogicalName>Crow.ColorPicker.template</LogicalName>
     </EmbeddedResource>
+    <EmbeddedResource Include="Templates\ToolWindow.template">
+      <LogicalName>Crow.ToolWindow.template</LogicalName>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Images\Icons\maximize.svg" />
+    <EmbeddedResource Include="Images\Icons\minimize.svg" />
+    <EmbeddedResource Include="Images\Icons\normalize.svg" />
   </ItemGroup>
   <ItemGroup>
     <None Include="README.md" />
index dc8abd8651d3d0d6099f53c478e4f37fdb4fd59e..de3e8d8c2e2242a13095fe891fe6d07166b6b530 100644 (file)
@@ -61,6 +61,13 @@ TextBox {
        Margin = 1;
 }
 Window {
+       Focusable = true;
+       MinimumSize=5,5;
+       Width = 150;
+       Height = 150;
+}
+ToolWindow {
+       Template = #Crow.ToolWindow.template;
        Focusable = true;
        MinimumSize=50,50;
        Width = 150;
index 3d688cc7d0ede775b91a1c1b7f9f004b6fbb230c..cb8d1c27328c62eee7a8cd05ae22ab9b3056bd95 100644 (file)
@@ -1,62 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
 <svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
    width="64"
    height="64"
-   viewBox="0 0 64 64.000002"
-   id="svg2"
-   version="1.1"
-   inkscape:version="0.91 r13725"
-   sodipodi:docname="exit.svg">
-  <defs
-     id="defs4" />
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="2.6992188"
-     inkscape:cx="-13.949137"
-     inkscape:cy="63.946457"
-     inkscape:document-units="px"
-     inkscape:current-layer="svg2"
-     showgrid="false"
-     units="px"
-     inkscape:window-width="1280"
-     inkscape:window-height="984"
-     inkscape:window-x="0"
-     inkscape:window-y="16"
-     inkscape:window-maximized="1" />
-  <metadata
-     id="metadata7">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <rect
-     style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1"
-     id="rect4136"
-     width="55.122551"
-     height="55.122551"
-     x="4.4468598"
-     y="4.3914709"
-     ry="8.8907347" />
+   viewBox="0 0 64 64">
   <path
      style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:9;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
      d="m 13.884262,15.143117 c 24.231966,13.49131 34.18672,34.186719 34.18672,34.186719"
diff --git a/Images/Icons/maximize.svg b/Images/Icons/maximize.svg
new file mode 100644 (file)
index 0000000..b70604a
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   width="14"
+   height="14"
+   viewBox="0 0 14 14">
+       <path
+               style="fill:none;stroke:#ffffff;stroke-width:2"
+               d="m 2,2 10,0 0,10 -10,0 z"/>
+</svg>
diff --git a/Images/Icons/minimize.svg b/Images/Icons/minimize.svg
new file mode 100644 (file)
index 0000000..dc3dcd2
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   width="64"
+   height="64"
+   viewBox="0 0 14 14">
+       <path
+               style="fill:#ffffff;stroke:none"
+               d="m 1,6 12,0 0,4 -12,0 z"/>
+</svg>
diff --git a/Images/Icons/normalize.svg b/Images/Icons/normalize.svg
new file mode 100644 (file)
index 0000000..b8b44bd
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   width="14"
+   height="14"
+   viewBox="0 0 14 14">
+<!--   <rect y="7" x="7" height="40" width="40"
+     style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" />
+   <rect y="7" x="7" height="10" width="40"
+     style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" />
+   <rect y="17" x="17" height="40" width="40"
+     style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" />
+   <rect y="17" x="17" height="10" width="40"
+     style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" />-->
+       <path
+               style="fill:none;stroke:#ffffff;stroke-width:1"
+               d="m 1,1 8,0 0,8 -8,0 z"/>
+       <path
+               style="fill:none;stroke:#ffffff;stroke-width:1"
+               d="m 4,4 8,0 0,8 -8,0 z"/>
+</svg>
diff --git a/Templates/ToolWindow.template b/Templates/ToolWindow.template
new file mode 100755 (executable)
index 0000000..7325193
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<Border BorderWidth="1" Foreground="White" 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="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
+                                       Name="hs" Margin="2" Spacing="0" Height="Fit">
+                               <GraphicObject Width="5"/>
+                               <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
+                               <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Title}" />
+                               <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
+                                       MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
+                                       <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Images.Icons.exit2.svg"
+                                                MouseClick="./butQuitPress"/>
+                               </Border>
+                               <GraphicObject Width="5"/>
+                       </HorizontalStack>
+<!--           </Border>-->
+               <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/>
+       </VerticalStack>
+</Border>
index 7325193c9018d867b14a603c2931c19f4401e840..d729021c14665a2496154752b26ecd0e5040288b 100755 (executable)
                                        Name="hs" Margin="2" Spacing="0" Height="Fit">
                                <GraphicObject Width="5"/>
                                <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
-                               <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Title}" />
-                               <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
+                               <Label Width="Stretched" Foreground="White" Margin="2" TextAlignment="Center" Text="{./Title}" />
+                               <Border Visible="{./ShowMinimize}" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
                                        MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
-                                       <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Images.Icons.exit2.svg"
+                                       <Image Focusable="true" Path="#Crow.Images.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.Images.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.Images.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.Images.Icons.exit2.svg"
                                                 MouseClick="./butQuitPress"/>
                                </Border>
                                <GraphicObject Width="5"/>
                        </HorizontalStack>
 <!--           </Border>-->
-               <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/>
+               <Container Name="Content" MinimumSize="0,0" Background="0.5,0.5,0.5,0.5"/>
        </VerticalStack>
 </Border>
index 86f05d8646771a115f013fbcc501a4e6459f5379..0b203dfd11e4208bb77cd3fcd24c792ad0a51e91 100644 (file)
@@ -46,15 +46,19 @@ namespace Crow
                bool _resizable;
                bool _movable;
                bool hoverBorder = false;
-               bool isMaximized = false;
-               Measure savedH, savedW;
+
+               Rectangle savedBounds;
+               bool _minimized = false;
 
                Container _contentContainer;
                Direction currentDirection = Direction.None;
 
+               #region Events
                public event EventHandler Closing;
                public event EventHandler Maximized;
                public event EventHandler Unmaximized;
+               public event EventHandler Minimize;
+               #endregion
 
                #region CTOR
                public Window () : base() {
@@ -64,73 +68,98 @@ namespace Crow
 
                #region TemplatedContainer overrides
                public override GraphicObject Content {
-                       get {
-                               return _contentContainer == null ? null : _contentContainer.Child;
-                       }
-                       set {
-                               _contentContainer.SetChild(value);
-                       }
+                       get { return _contentContainer == null ? null : _contentContainer.Child; }
+                       set { _contentContainer.SetChild(value); }
                }
                protected override void loadTemplate(GraphicObject template = null)
                {
                        base.loadTemplate (template);
                        _contentContainer = this.child.FindByName ("Content") as Container;
+
+                       NotifyValueChanged ("ShowNormal", false);
+                       NotifyValueChanged ("ShowMinimize", true);
+                       NotifyValueChanged ("ShowMaximize", true);
                }
                #endregion
 
                #region public properties
-               [XmlAttributeAttribute()][DefaultValue("Window")]
+               [XmlAttributeAttribute][DefaultValue("Window")]
                public string Title {
                        get { return _title; } 
                        set {
+                               if (_title == value)
+                                       return;
                                _title = value;
                                NotifyValueChanged ("Title", _title);
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.crow.png")]
+               [XmlAttributeAttribute][DefaultValue("#Crow.Images.Icons.crow.png")]
                public string Icon {
                        get { return _icon; } 
                        set {
+                               if (_icon == value)
+                                       return;
                                _icon = value;
                                NotifyValueChanged ("Icon", _icon);
                        }
                } 
-               [XmlAttributeAttribute()][DefaultValue(true)]
+               [XmlAttributeAttribute][DefaultValue(true)]
                public bool Resizable {
                        get {
                                return _resizable;
                        }
                        set {
+                               if (_resizable == value)
+                                       return;
                                _resizable = value;
                                NotifyValueChanged ("Resizable", _resizable);
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue(true)]
+               [XmlAttributeAttribute][DefaultValue(true)]
                public bool Movable {
                        get {
                                return _movable;
                        }
                        set {
+                               if (_movable == value)
+                                       return;
                                _movable = value;
                                NotifyValueChanged ("Movable", _movable);
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue(false)]
-               public bool IsMaximized {
-                       get { return isMaximized; }
+               [XmlAttributeAttribute][DefaultValue(false)]
+               public bool IsMinimized {
+                       get { return _minimized; }
                        set{
-                               if (value == isMaximized)
+                               if (value == IsMinimized)
                                        return;
-                               isMaximized = value;
 
-                               if (isMaximized)
-                                       onMaximized (this, null);
-                               else
-                                       onUnmaximized (this, null);
+                               _minimized = value;
+                               _contentContainer.Visible = !_minimized;
 
-                               NotifyValueChanged ("IsMaximized", isMaximized);
+                               NotifyValueChanged ("IsMinimized", _minimized);
                        }
                }
+               [XmlIgnore]public bool IsMaximized {
+                       get { return Width == Measure.Stretched & Height == Measure.Stretched & !_minimized; }
+               }
+               [XmlIgnore]public bool IsNormal {
+                       get { return !(IsMaximized|_minimized); }
+               }
+//             [XmlAttributeAttribute()][DefaultValue(WindowState.Normal)]
+//             public virtual WindowState State {
+//                     get { return _state; }
+//                     set {
+//                             if (_state == value)
+//                                     return;
+//                             _state = value;
+//                             NotifyValueChanged ("State", _state);
+//                             NotifyValueChanged ("IsNormal", IsNormal);
+//                             NotifyValueChanged ("IsMaximized", IsMaximized);
+//                             NotifyValueChanged ("IsMinimized", IsMinimized);
+//                             NotifyValueChanged ("IsNotMinimized", IsNotMinimized);
+//                     }
+//             } 
                #endregion
 
                #region GraphicObject Overrides
@@ -219,14 +248,6 @@ namespace Crow
                                        return;
                                }
                        }
-//                     GraphicObject firstFocusableAncestor = otkgw.hoverWidget;
-//                     while (firstFocusableAncestor != this) {
-//                             if (firstFocusableAncestor == null)
-//                                     return;
-//                             if (firstFocusableAncestor.Focusable)
-//                                     return;
-//                             firstFocusableAncestor = firstFocusableAncestor.Parent as GraphicObject;
-//                     }
                        if (Resizable) {
                                Direction lastDir = currentDirection;
 
@@ -289,21 +310,56 @@ namespace Crow
                        base.onMouseDown (sender, e);
                }
                #endregion
+
                protected void onMaximized (object sender, EventArgs e){
-                       savedW = this.Width;
-                       savedH = this.Height;
-                       this.Width = Measure.Stretched;
-                       this.Height = Measure.Stretched;
+                       lock (CurrentInterface.LayoutMutex) {
+                               if (!IsMinimized)
+                                       savedBounds = this.LastPaintedSlot;
+                               this.Left = this.Top = 0;
+                               this.RegisterForLayouting (LayoutingType.Positioning);
+                               this.Width = this.Height = Measure.Stretched;
+                               IsMinimized = false;
+                               Resizable = false;
+                               NotifyValueChanged ("ShowNormal", true);
+                               NotifyValueChanged ("ShowMinimize", true);
+                               NotifyValueChanged ("ShowMaximize", false);
+                       }
 
                        Maximized.Raise (sender, e);
+
+
+
                }
                protected void onUnmaximized (object sender, EventArgs e){
-                       this.Width = savedW;
-                       this.Height = savedH;
+                       lock (CurrentInterface.LayoutMutex) {
+                               this.Left = savedBounds.Left;
+                               this.Top = savedBounds.Top;
+                               this.Width = savedBounds.Width;
+                               this.Height = savedBounds.Height;
+                               IsMinimized = false;
+                               Resizable = true;
+                               NotifyValueChanged ("ShowNormal", false);
+                               NotifyValueChanged ("ShowMinimize", true);
+                               NotifyValueChanged ("ShowMaximize", true);
+                       }
 
                        Unmaximized.Raise (sender, e);
                }
+               protected void onMinimized (object sender, EventArgs e){
+                       lock (CurrentInterface.LayoutMutex) {
+                               if (IsNormal)
+                                       savedBounds = this.LastPaintedSlot;
+                               Width = 200;
+                               Height = 20;
+                               Resizable = false;
+                               IsMinimized = true;
+                               NotifyValueChanged ("ShowNormal", true);
+                               NotifyValueChanged ("ShowMinimize", false);
+                               NotifyValueChanged ("ShowMaximize", true);
+                       }
 
+                       Minimize.Raise (sender, e);
+               }
                protected void onBorderMouseLeave (object sender, MouseMoveEventArgs e)
                {
                        hoverBorder = false;
@@ -316,9 +372,6 @@ namespace Crow
                }
 
 
-               protected void butMaximizePress (object sender, MouseButtonEventArgs e){
-                       IsMaximized = !IsMaximized;
-               }
                protected void butQuitPress (object sender, MouseButtonEventArgs e)
                {
                        CurrentInterface.MouseCursor = XCursor.Default;