]> O.S.I.I.S - jp/crow.git/commitdiff
various fixes
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 30 Nov 2018 20:47:39 +0000 (21:47 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 30 Nov 2018 20:47:39 +0000 (21:47 +0100)
15 files changed:
Crow.csproj
Default.style
Templates/ScrollBar.template
Tests/BasicTests.cs
Tests/Interfaces/Experimental/DockWindow.template [new file with mode: 0755]
Tests/Interfaces/Experimental/testDock.crow
Tests/Tests.csproj
src/GraphicObjects/DockStack.cs
src/GraphicObjects/DockWindow.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/MenuItem.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TemplatedGroup.cs
src/Interface.cs
src/backends/xcb/XCBKeyboard.cs

index 6ad0c309f7a20d0b65aedc365dc7a78aaccbce6d..0afb1db900e6b5fa566f8d405fa2333f94f3eee7 100644 (file)
@@ -32,7 +32,7 @@
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
     <Optimize>false</Optimize>
     <OutputPath>$(SolutionDir)build\Debug</OutputPath>
-    <DefineConstants>DEBUG_LOG;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>DEBUG_DRAGNDROP0;DEBUG_LOG0;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
     <EnvironmentVariables>
       <EnvironmentVariables>
         <Variable name="MONO_CAIRO_DEBUG_DISPOSE" value="1" />
index 29b5edeaa653e5a6b56f0ceea41d66d2d83b10c4..9709eef9864fa73c23be0b31cb6d0725a12f8fb0 100644 (file)
@@ -128,13 +128,14 @@ DockStack {
        //EndDrag="{Background=Jet}";
 }
 DockWindow {
-       Background = "Onyx";
+       //Background = "Onyx";
        Focusable = "true";
        AllowDrag = "true";
        AlwaysOnTop = "true";
        Margin="0";
        Width="200";
        Height="200";
+       //MinimumSize="50,50";
 }
 FileDialog {
        Template = "#Crow.FileDialog.template";
index c19b5680fb0e2f333c367563f71fc167b8c4db78..de1eaf3bb17903d9855ffc78aa73a3f072ee29c1 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="Black" >
+<Border BorderWidth="1" Foreground="DimGrey" >
        <GenericStack Orientation="{./Orientation}" Spacing="0">
                <Shape Style="ArrowBut" MouseDown="./onScrollBack" Path="{./ScrollBackShape}"/>
                <Slider Name="Slider"                   
@@ -10,9 +10,9 @@
                        Height="{./HeightPolicy}" Width="{./WidthPolicy}"
                        LargeIncrement="{./LargeIncrement}"
                        SmallIncrement="{./SmallIncrement}"
-                       CursorColor="hgradient|0:Grey|1:Onyx"
+                       CursorColor="hgradient|0:Grey|1:DimGrey"
                        Foreground="DimGrey"
-                       Background="hgradient|0:Grey|1:White"/>
+                       Background="hgradient|0:DimGrey|0.1:Grey|0.95:Grey|1:White"/>
                <Shape Style="ArrowBut" MouseDown="./onScrollForth" Path="M 0.5,0.5 L 10.5,0.5 L 5.5,10.5 Z"/>
        </GenericStack>
 </Border>
\ No newline at end of file
index 4f9fd128f09b515439c687b67609945873614e6d..c3d3a78112f82cd6ac1da332058f4129b05d2f7e 100644 (file)
@@ -23,7 +23,16 @@ namespace tests
                                //app.AddWidget (@"Interfaces/Container/0.crow").DataSource = app;
                                //app.AddWidget (@"Interfaces/Divers/colorPicker.crow").DataSource = app;
                                //app.AddWidget ("Interfaces/Divers/perfMeasures.crow").DataSource = app;
-                               app.AddWidget ("#Tests.ui.dbgLog.crow").DataSource = app;
+                               //app.AddWidget ("#Tests.ui.dbgLog.crow").DataSource = app;
+                               app.AddWidget (@"Interfaces/Experimental/testDock.crow").DataSource = app;
+
+                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock1'/>");
+                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock2'/>");
+                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock3'/>");
+                               /*app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
+                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
+                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");*/
+
                
                                while (true) {
                                        #if MEASURE_TIME
@@ -55,11 +64,11 @@ namespace tests
                {
                        Console.WriteLine((byte)e.Key);
                        //#if DEBUG_LOG
-                       switch (e.Key) {
+                       /*switch (e.Key) {
                        case Key.F2:                            
                                DebugLog.save (app);
                                break;
-                       }
+                       }*/
                        //#endif
                }
        }
diff --git a/Tests/Interfaces/Experimental/DockWindow.template b/Tests/Interfaces/Experimental/DockWindow.template
new file mode 100755 (executable)
index 0000000..2d39bd4
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--<GraphicObject Background="{./Background}"/>-->
+<Border BorderWidth="1" Foreground="Black" CornerRadius="{./CornerRadius}"
+                               Background="{./Background}"
+                               MouseEnter="./onBorderMouseEnter"
+                               MouseLeave="./onBorderMouseLeave">
+       <VerticalStack Spacing="0">
+               <HorizontalStack Height="Fit">
+                       <Label  Text="{./Name}" TextAlignment="Left" Width="Fit"
+                                        Foreground="White" />
+                       <Label  Text="{./DockingPosition}" TextAlignment="Left" Width="Fit"
+                                        Foreground="White" />
+               </HorizontalStack>
+               <HorizontalStack Visible="{./IsDocked}" Height="Fit" Margin="1" Background="Grey">
+                       <Label  Text="{./Caption}" TextAlignment="Left" Width="Stretched"
+                                        Foreground="Jet" />
+                       <Image Width="8" Height="8" Focusable="true" Margin="0" Path="#Crow.Images.Icons.exit2.svg"
+                                        MouseClick="./butQuitPress"/>
+               </HorizontalStack>
+               <HorizontalStack Background="vgradient|0:0.5,0.6,0.5,0.5|1:0.2,0.3,0.3,0.7"
+                               Name="hs" Margin="0" Spacing="0" Height="Fit" Visible="{./IsFloating}">
+                       <GraphicObject Width="5"/>
+                       <Image Margin="1" Width="10" Height="10" Path="{./Icon}"/>
+                       <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Left" Text="{./Caption}" />
+                       <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="10" Width="10"
+                               MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
+                               <Image Focusable="true" Name="Image" Margin="0" Path="#Crow.Images.Icons.exit2.svg"
+                                        MouseClick="./butQuitPress"/>
+                       </Border>
+                       <GraphicObject Width="5"/>
+               </HorizontalStack>
+               <Container Name="Content" MinimumSize="50,50"/>
+       </VerticalStack>
+</Border>
index 0b05e76d139f3ecb4e8e4242b82320c301848441..62a5203c83624b024f1b29471ee14c3f2bfea592 100644 (file)
@@ -1,8 +1,9 @@
 <?xml version="1.0"?>
-<Window Height="50%" Width="60%">
-       <DockStack Background="#60101050" Margin="10"/>
+<Window Width="Stretched" Height="Stretched">
+       <DockStack Background="#60101050" Margin="20">
+       </DockStack>
 </Window>
-<!---          <DockWindow Left="400" Top="400" Width="150" Height="150" Background="MediumSeaGreen"/>
+<!---          
                <DockWindow Left="450" Top="450" Width="150" Height="150" Background="Maize"/>-->
        
 
index 0aef448b586cc2458feb7a98f97978e5c0f7aadd..049ab6f91557fe5222b3645327a9ca3fe13486f8 100644 (file)
       <LogicalName>Crow.TabItem.template</LogicalName>
     </EmbeddedResource>
     <EmbeddedResource Include="ui\dbgLog.crow" />
+    <EmbeddedResource Include="Interfaces\Experimental\DockWindow.template">
+      <LogicalName>Crow.DockWindow.template</LogicalName>
+    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Crow.csproj">
index ae8b9c89093a9fec17bba8be91606f602c2726e7..f217402480f81dda039698eff3f42a0883645e3b 100644 (file)
@@ -25,6 +25,7 @@
 // THE SOFTWARE.
 using System;
 using Crow.IML;
+using System.Linq;
 
 namespace Crow
 {
@@ -36,6 +37,13 @@ namespace Crow
                public DockStack (Interface iface) : base (iface) {}
                #endregion
 
+               /*static int color = 10;
+
+               protected override void onInitialized (object sender, EventArgs e)
+               {
+                       base.onInitialized (sender, e);
+                       Background = Color.ColorDic.Values.ToList()[color++];
+               }*/
                public override void AddChild (GraphicObject g)
                {
                        base.AddChild (g);
@@ -68,8 +76,9 @@ namespace Crow
                                                return false;
                                        }
                                }
+                               childrenRWLock.ExitReadLock ();
                        }
-                       childrenRWLock.ExitReadLock ();
+
                        return Slot.ContainsOrIsEqual(m);
                }
 
@@ -172,8 +181,8 @@ namespace Crow
                protected override void onDragLeave (object sender, DragDropEventArgs e)
                {
                        DockWindow dw = e.DragSource as DockWindow;
-                       if (dw != null)
-                               dw.DockingPosition = Alignment.Undefined;
+                       //if (dw != null)
+                       //      dw.DockingPosition = Alignment.Undefined;
                        base.onDragLeave (sender, e);
                        RegisterForGraphicUpdate ();
                }
@@ -307,14 +316,16 @@ namespace Crow
                                break;
                        }
                }
-               public void Undock (DockWindow dw){
+               public void Undock (DockWindow dw){                     
                        int idx = Children.IndexOf(dw);
 
+                       Console.WriteLine ("undocking child index: {0} ; name={1}; pos:{2} ; childcount:{3}",idx, dw.Name, dw.DockingPosition, Children.Count);
+
                        RemoveChild(dw);
 
                        if (Children.Count == 0)
                                return;
-
+                       
                        if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top) {                              
                                RemoveChild (idx);
                                if (stretchedChild == dw) {
index ca4b93f4bbc006946e2c7edf5f28fdf685184201..1ae3b0b450eb3947e3bda6fd95017851429c9133 100644 (file)
@@ -109,8 +109,8 @@ namespace Crow
                                undockingMousePosOrig = e.Position;
                }
                public bool CheckUndock (Point mousePos) {
-                       if (DockingPosition == Alignment.Center)
-                               return false;
+                       //if (DockingPosition == Alignment.Center)
+                       //      return false;
                        if (Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold ||
                            Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold)
                                return false;
@@ -126,7 +126,7 @@ namespace Crow
                }
                protected override void onDrop (object sender, DragDropEventArgs e)
                {
-                       if (!isDocked && DockingPosition != Alignment.Undefined)
+                       if (!isDocked && DockingPosition != Alignment.Undefined && e.DropTarget is DockStack)
                                Dock (e.DropTarget as DockStack);
                        base.onDrop (sender, e);
                }
index e67b3523002101386f1c7a9e8f4a67ca38a3e93d..2bf20f27bf2e517b4c0653d3f94b21ddded97307 100644 (file)
@@ -1386,7 +1386,7 @@ namespace Crow
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
                public void RegisterForRedraw ()
                {
-                       //IsDirty = true;
+                       IsDirty = true;
                        if (RegisteredLayoutings == LayoutingType.None)
                                IFace.EnqueueForRepaint (this);
                }
@@ -1789,8 +1789,6 @@ namespace Crow
                        Debug.WriteLine("MOUSE DOWN => " + this.ToString());
                        #endif
 
-                       if (IFace.ActiveWidget == null)
-                               IFace.ActiveWidget = this;
                        if (this.Focusable && !Interface.FocusOnHover) {
                                BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
                                if (be.Focused == null) {
@@ -1956,7 +1954,7 @@ namespace Crow
                        #if DEBUG_LAYOUTING
                        return Name == "unamed" ? tmp + "." + this.GetType ().Name + GraphicObjects.IndexOf(this).ToString(): tmp + "." + Name;
                        #else
-                       return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
+                       return string.IsNullOrEmpty(Name) ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
                        #endif
                }
                /// <summary>
index 5c9665fb4ae9784d31d4749af625387cdf8057e1..47bd978f03c3ff34e5d45c77894e8aec19b97a08 100644 (file)
@@ -164,7 +164,10 @@ namespace Crow
                public override void onMouseEnter (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseEnter (sender, e);
-                       if ((LogicalParent as Menu).AutomaticOpenning && items.Children.Count>0)
+                       Menu menu = LogicalParent as Menu;
+                       if (menu == null)
+                               return;
+                       if (menu.AutomaticOpenning && items.Children.Count>0)
                                IsOpened = true;
                }
                public override void onMouseLeave (object sender, MouseMoveEventArgs e)
index 473fc313e4c11dd59c0fb37313a914e7745ca218..8ddd7a8ecf3b6388b1d70fa46f96db7b5f798b9b 100644 (file)
@@ -148,8 +148,13 @@ namespace Crow
                        gr.LineWidth = 1;
                        Foreground.SetAsSource (gr);
                        gr.StrokePreserve ();
-                       gr.Clip ();
+                       gr.ClipPreserve ();
+
+                       Background.SetAsSource (gr);
+                       gr.Fill ();
+
                        base.onDraw (gr);
+
                        gr.Restore ();
                }
 
@@ -157,7 +162,14 @@ namespace Crow
                int dragThreshold = 16;
                int dis = 128;
                internal TabView savedParent = null;
-
+               public override Fill Background {
+                       get {
+                               return base.Background;
+                       }
+                       set {
+                               base.Background = value;
+                       }
+               }
                void makeFloating (TabView tv) {                        
                        lock (IFace.UpdateMutex) {                              
                                ImageSurface di = new ImageSurface (Format.Argb32, dis, dis);
index f7c937638bb2c2e4ea6259625d6d41e6c0bdaa98..73681b9de7fe0c3f12d930157c6ed2f18c22465a 100644 (file)
@@ -154,17 +154,17 @@ namespace Crow
                                if (value == _selectedIndex)
                                        return;
 
-                               if (_selectedIndex >= 0 && Items.Count > _selectedIndex) {
+                               /*if (_selectedIndex >= 0 && Items.Count > _selectedIndex) {
                                        Items[_selectedIndex].Foreground = Color.Transparent;
                                        Items[_selectedIndex].Background = Color.Transparent;
-                               }
+                               }*/
 
                                _selectedIndex = value;
 
-                               if (_selectedIndex >= 0 && Items.Count > _selectedIndex) {
+                               /*if (_selectedIndex >= 0 && Items.Count > _selectedIndex) {
                                        Items[_selectedIndex].Foreground = SelectionForeground;
                                        Items[_selectedIndex].Background = SelectionBackground;
-                               }
+                               }*/
 
                                NotifyValueChanged ("SelectedIndex", _selectedIndex);
                                NotifyValueChanged ("SelectedItem", SelectedItem);
index 743bbb0f5142937ad74565139f4e0e660cd7e46d..771377619d15c9effe8bb744a10f0633f3e9eb65 100644 (file)
@@ -128,6 +128,9 @@ namespace Crow
                        Keyboard.KeyUp += Keyboard_KeyUp;
                        Keyboard.KeyPress += Keyboard_KeyPress;
 
+                       initTooltip ();
+                       initContextMenus ();
+
                        Thread t = new Thread (interfaceThread);
                        t.IsBackground = true;
                        t.Start ();
@@ -161,7 +164,7 @@ namespace Crow
                        //                      keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc);
                        //                      keyboardRepeatThread.IsBackground = true;
                        //                      keyboardRepeatThread.Start ();
-               }
+               }
 
                void interfaceThread()
                {                       
@@ -212,8 +215,6 @@ namespace Crow
                        //loadCursors ();
                        loadStyling ();
                        findAvailableTemplates ();
-                       //initTooltip ();
-                       //initContextMenus ();
 
                        #if MEASURE_TIME
                        PerfMeasures.Add (updateMeasure);
@@ -500,9 +501,9 @@ namespace Crow
                        }
                }
                /// <summary>
-               /// Add the content of the IML fragment to the graphic tree of this interface
+               /// Create an instantiator bound to this interface from the IML fragment
                /// </summary>
-               /// <returns>return the new instance for convenience, may be ignored</returns>
+               /// <returns>return the new instantiator</returns>
                /// <param name="imlFragment">a valid IML string</param>
                public Instantiator CreateITorFromIMLFragment (string imlFragment) {                    
                        return Instantiator.CreateFromImlFragment (this, imlFragment);
@@ -816,7 +817,7 @@ namespace Crow
                                        clipping = new Region ();
                                        //}
                                        //surf.WriteToPng (@"/mnt/data/test.png");
-                                       surf.Flush();
+
                                        backend?.Flush ();
                                }
                        }
@@ -1125,6 +1126,9 @@ namespace Crow
 
                        if (FocusedWidget == null)
                                return true;
+
+                       ActiveWidget = FocusedWidget;
+
                        if (!FocusedWidget.MouseRepeat)
                                return true;
                        mouseRepeatThread = new Thread (mouseRepeatThreadFunc);
index c5e6865456f966cd5293657af8476deceb917ca7..c7484f50ea327d187dd93dd370cce1697b43ac5d 100644 (file)
@@ -2548,9 +2548,10 @@ namespace Crow.XKB
                                Marshal.Copy (ptrKeySyms, keySyms, 0, nbKeySyms);
 
                                uint utf32 = xkb_state_key_get_utf32 (xkbState, keycode);
+                               char c = char.ConvertFromUtf32 ((int)utf32) [0];
 
-                               if (utf32 > 0)
-                                       KeyPress.Raise (this, new KeyPressEventArgs (char.ConvertFromUtf32 ((int)utf32) [0]));
+                               if (!char.IsControl(c))
+                                       KeyPress.Raise (this, new KeyPressEventArgs (c));
                        } else {
                                keyDir = xkb_key_direction.KEY_UP;
                                KeyUp.Raise (this, new KeyEventArgs ((Key)ks, false));