From: Jean-Philippe Bruyère Date: Fri, 30 Nov 2018 20:47:39 +0000 (+0100) Subject: various fixes X-Git-Tag: v0.9.5-beta~149^2~7 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=a64627699d4919d389522d92032ce4f05704d313;p=jp%2Fcrow.git various fixes --- diff --git a/Crow.csproj b/Crow.csproj index 6ad0c309..0afb1db9 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -32,7 +32,7 @@ true false $(SolutionDir)build\Debug - DEBUG_LOG;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0 + 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 diff --git a/Default.style b/Default.style index 29b5edea..9709eef9 100644 --- a/Default.style +++ b/Default.style @@ -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"; diff --git a/Templates/ScrollBar.template b/Templates/ScrollBar.template index c19b5680..de1eaf3b 100755 --- a/Templates/ScrollBar.template +++ b/Templates/ScrollBar.template @@ -1,5 +1,5 @@ - + + Background="hgradient|0:DimGrey|0.1:Grey|0.95:Grey|1:White"/> \ No newline at end of file diff --git a/Tests/BasicTests.cs b/Tests/BasicTests.cs index 4f9fd128..c3d3a781 100644 --- a/Tests/BasicTests.cs +++ b/Tests/BasicTests.cs @@ -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 (@""); + app.LoadIMLFragment (@""); + app.LoadIMLFragment (@""); + /*app.LoadIMLFragment (@""); + app.LoadIMLFragment (@""); + app.LoadIMLFragment (@"");*/ + 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 index 00000000..2d39bd4b --- /dev/null +++ b/Tests/Interfaces/Experimental/DockWindow.template @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/Tests/Interfaces/Experimental/testDock.crow b/Tests/Interfaces/Experimental/testDock.crow index 0b05e76d..62a5203c 100644 --- a/Tests/Interfaces/Experimental/testDock.crow +++ b/Tests/Interfaces/Experimental/testDock.crow @@ -1,8 +1,9 @@  - - + + + - diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 0aef448b..049ab6f9 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -420,6 +420,9 @@ Crow.TabItem.template + + Crow.DockWindow.template + diff --git a/src/GraphicObjects/DockStack.cs b/src/GraphicObjects/DockStack.cs index ae8b9c89..f2174024 100644 --- a/src/GraphicObjects/DockStack.cs +++ b/src/GraphicObjects/DockStack.cs @@ -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) { diff --git a/src/GraphicObjects/DockWindow.cs b/src/GraphicObjects/DockWindow.cs index ca4b93f4..1ae3b0b4 100644 --- a/src/GraphicObjects/DockWindow.cs +++ b/src/GraphicObjects/DockWindow.cs @@ -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); } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index e67b3523..2bf20f27 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -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 } /// diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs index 5c9665fb..47bd978f 100644 --- a/src/GraphicObjects/MenuItem.cs +++ b/src/GraphicObjects/MenuItem.cs @@ -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) diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index 473fc313..8ddd7a8e 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -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); diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index f7c93763..73681b9d 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -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); diff --git a/src/Interface.cs b/src/Interface.cs index 743bbb0f..77137761 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -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 } } /// - /// 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 /// - /// return the new instance for convenience, may be ignored + /// return the new instantiator /// a valid IML string 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); diff --git a/src/backends/xcb/XCBKeyboard.cs b/src/backends/xcb/XCBKeyboard.cs index c5e68654..c7484f50 100644 --- a/src/backends/xcb/XCBKeyboard.cs +++ b/src/backends/xcb/XCBKeyboard.cs @@ -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));