From: jpbruyere Date: Sun, 7 Jun 2015 09:08:14 +0000 (+0200) Subject: * Tests.csproj: X-Git-Tag: 0.2~88 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=d54616114dc1a3a3ca269e067c62fda2cde70202;p=jp%2Fcrow.git * Tests.csproj: * GOLIBTest_2.cs: * GOLIBTest_Spinner.cs: * test2.goml: * test4.goml: * testSpinner.goml: tests * GOLib.csproj: divers * OpenTK: * BmpPicture.cs: center image when keepProportions is on * Group.cs: Align children in group even if group size is FIT * Label.cs: - text selectable or not * Spinner.cs: clean --- diff --git a/GOLib.csproj b/GOLib.csproj index c281a642..15e126f0 100644 --- a/GOLib.csproj +++ b/GOLib.csproj @@ -54,222 +54,60 @@ anycpu --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -299,34 +137,13 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Tests/GOLIBTest_2.cs b/Tests/GOLIBTest_2.cs index 6b9f832a..4af54367 100644 --- a/Tests/GOLIBTest_2.cs +++ b/Tests/GOLIBTest_2.cs @@ -22,7 +22,7 @@ namespace test : base(1024, 600,"test") {} - Container g; + Group g; protected override void OnLoad (EventArgs e) { diff --git a/Tests/GOLIBTest_Spinner.cs b/Tests/GOLIBTest_Spinner.cs new file mode 100644 index 00000000..c3b36f03 --- /dev/null +++ b/Tests/GOLIBTest_Spinner.cs @@ -0,0 +1,55 @@ +#define MONO_CAIRO_DEBUG_DISPOSE + + +using System; +using System.Runtime.InteropServices; +using OpenTK; +using OpenTK.Graphics.OpenGL; +using OpenTK.Input; + +using System.Diagnostics; + +//using GGL; +using go; +using System.Threading; + + +namespace test +{ + class GOLIBTest_Spinner : OpenTKGameWindow + { + public GOLIBTest_Spinner () + : base(1024, 600,"test") + {} + + Container g; + + protected override void OnLoad (EventArgs e) + { + base.OnLoad (e); + LoadInterface("Interfaces/testSpinner.goml", out g); + + } + protected override void OnRenderFrame (FrameEventArgs e) + { + GL.Clear (ClearBufferMask.ColorBufferBit); + base.OnRenderFrame (e); + SwapBuffers (); + } + + protected override void OnUpdateFrame (FrameEventArgs e) + { + base.OnUpdateFrame (e); + } + + [STAThread] + static void Main () + { + Console.WriteLine ("starting example"); + + using (GOLIBTest_Spinner win = new GOLIBTest_Spinner( )) { + win.Run (30.0); + } + } + } +} \ No newline at end of file diff --git a/Tests/Interfaces/test2.goml b/Tests/Interfaces/test2.goml index 69ac77ec..05cecda3 100755 --- a/Tests/Interfaces/test2.goml +++ b/Tests/Interfaces/test2.goml @@ -1,9 +1,9 @@  - - - - --> + + + - \ No newline at end of file + \ No newline at end of file diff --git a/Tests/Interfaces/test4.goml b/Tests/Interfaces/test4.goml index 37bc8f37..914bce00 100755 --- a/Tests/Interfaces/test4.goml +++ b/Tests/Interfaces/test4.goml @@ -72,7 +72,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - PreserveNewest - - - - PreserveNewest - - PreserveNewest PreserveNewest - - + + + PreserveNewest - - - - - - - - + + diff --git a/src/BmpPicture.cs b/src/BmpPicture.cs index 6e8d1e52..053c8fbf 100644 --- a/src/BmpPicture.cs +++ b/src/BmpPicture.cs @@ -85,12 +85,18 @@ namespace go float heightRatio = (float)rect.Height / Dimensions.Height; float ratio = Math.Min (widthRatio, heightRatio); +// if (KeepProportions) +// widthRatio = heightRatio = ratio; + Rectangle rImg = rect; gr.Save (); - if (KeepProportions) + if (KeepProportions) { + gr.Translate ((rect.Width - (float)Dimensions.Width * ratio)/2f, + (rect.Height - (float)Dimensions.Height * ratio)/2f); gr.Scale (ratio, ratio); - else + + }else gr.Scale (widthRatio, heightRatio); using (ImageSurface imgSurf = new ImageSurface (image, Format.Argb32, diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index a2a04e0b..42da7983 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -119,10 +119,28 @@ namespace go return tmp; } - - public override void RegisterForLayouting (int layoutType) + + protected override void OnLayoutChanges (LayoutingType layoutType) { - base.RegisterForLayouting (layoutType); + base.OnLayoutChanges (layoutType); + + //position smaller objects in group when group size is fit + switch (layoutType) { + case LayoutingType.Width: + if (Width < 0) { + int crw = ClientRectangle.Width; + foreach (GraphicObject c in Children.Where(ch => ch.Slot.Width != crw)) + c.RegisterForLayouting ((int)LayoutingType.X); + } + break; + case LayoutingType.Height: + if (Height < 0) { + int crh = ClientRectangle.Height; + foreach (GraphicObject c in Children.Where(ch => ch.Slot.Height != crh)) + c.RegisterForLayouting ((int)LayoutingType.Y); + } + break; + } } public override Rectangle ContextCoordinates(Rectangle r){ diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index 1e5332ca..27a766d2 100755 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -35,6 +35,7 @@ namespace go bool _multiline = false; Color selColor; Color selFontColor; + bool _selectable; Point mouseLocalPos; //mouse coord in widget space, filled only when clicked int _currentCol; //0 based cursor position in string int _currentLine; @@ -66,6 +67,11 @@ namespace go registerForGraphicUpdate (); } } + [XmlAttributeAttribute()][DefaultValue(false)] + public virtual bool Selectable { + get { return _selectable; } + set { _selectable = value; } + } [XmlAttributeAttribute()][DefaultValue(Alignment.LeftCenter)] public Alignment TextAlignment @@ -259,10 +265,15 @@ namespace go te = tmp; } fe = gr.FontExtents; - size = new Size ((int)Math.Ceiling (te.XAdvance) + Margin * 2, (int)(fe.Height * lines.Count) + Margin*2); + int lc = lines.Count; + //ensure minimal height = text line height + if (lc == 0) + lc = 1; + size = new Size ((int)Math.Ceiling (te.XAdvance) + Margin * 2, (int)(fe.Height * lc) + Margin*2); } } - return size;// +borderWidth; + + return size;; } protected override void onDraw (Context gr) { @@ -402,7 +413,7 @@ namespace go else computeTextCursorPosition(gr); - if (HasFocus) + if (HasFocus && Selectable) { //TODO: gr.Color = Foreground; @@ -502,14 +513,16 @@ namespace go if ((sender as OpenTKGameWindow).activeWidget != this) return; + if (!Selectable) + return; + SelectionInProgress = true; mouseLocalPos = e.Position - ScreenCoordinates(ClientRectangle).TopLeft; registerForGraphicUpdate(); - } public override void onMouseButtonDown (object sender, MouseButtonEventArgs e) { - if (this.HasFocus){ + if (this.HasFocus && Selectable){ mouseLocalPos = e.Position - ScreenCoordinates(ClientRectangle).TopLeft; selBegin = -1; selRelease = -1; diff --git a/src/GraphicObjects/Spinner.cs b/src/GraphicObjects/Spinner.cs index 46961966..4706effe 100644 --- a/src/GraphicObjects/Spinner.cs +++ b/src/GraphicObjects/Spinner.cs @@ -32,8 +32,7 @@ namespace go public Spinner (double minimum, double maximum, double step) : base (minimum, maximum, step) { -// butUp = new Button (); -// butUp.setChild (new Image ("go.Image.Icons.updown.svg")); + } public Spinner () : base() {