IconMargin = "1";
ToggleIconSize = "16";
-WindowBackgroundColor = "";
+WindowBackgroundColor = "DarkGrey";
WindowBorderColor = "Grey";
WindowBorderWidth = "1";
-WindowTitleBarBackground = "vgradient|0:Onyx|1:SteelBlue";
+WindowTitleBarBackground = "vgradient|0:Onyx|1:RoyalBlue";
WindowTitleBarForeground = "White";
+MenuBackground = "Jet";
+
Button, CheckBox, RadioButton, ComboBox, Expandable,
MessageBox, Popper, Slider, Spinner, TextBox {
Focusable = "true";
MouseCursor = "IBeam";
}
Menu {
- Margin = "1";
- Background = "vgradient|0:DimGrey|1:Black";
- //Background = "Transparent";
+ Margin = "0";
+ Background = "${MenuBackground}";
Height = "Fit";
Width = "Stretched";
VerticalAlignment = "Top";
SelectionBackground = "${ControlHighlight}";
+ SelectionColoring = "false";
}
MenuItem {
Caption = "MenuItem";
Width = "Stretched";
Height = "Fit";
- Background = "DimGrey";
- Foreground = "LightGrey";
+ Background = "${MenuBackground}";
+ Foreground = "${ControlCaptionColor}";
MouseEnter = "{Background=${ControlHighlight}}";
- MouseLeave = "{Background=Transparent}";
- SelectionBackground = "${ControlHighlight}";
+ MouseLeave = "{Background=${MenuBackground}}";
+ //SelectionBackground = "${ControlHighlight}";
+ SelectionBackground = "Transparent";
+ SelectionColoring = "false";
}
MessageBox {
Background = "0.1,0.1,0.2,0.85";
<?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}"
- Background="{./Background}"
- MouseEnter="./onBorderMouseEnter"
- MouseLeave="./onBorderMouseLeave">
+<Border Name="SizeHandle" Style="winBorder" CornerRadius="{./CornerRadius}" Background="{./Background}">
<VerticalStack Spacing="0">
- <HorizontalStack Background="{./TitleBarBackground}"
- Name="hs" Margin="2" Spacing="0" Height="Fit">
+ <HorizontalStack Background="${WindowTitleBarBackground}" Margin="0" Spacing="0" Height="Fit">
<Widget Width="5"/>
<Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
- <Label Width="Stretched" Foreground="{./TitleBarForeground}" Margin="1" TextAlignment="Center" Text="{./Caption}" />
+ <Label Name="MoveHandle" Width="Stretched" Foreground="${WindowTitleBarForeground" Margin="2" TextAlignment="Center" Text="{./Caption}" />
<Border CornerRadius="0" 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.Icons.exit2.svg"
</Template>
</CheckBox>
</Template>
- <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="vgradient|0:DimGrey|1:Black">
+ <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="${MenuBackground}">
<VerticalStack Name="ItemsContainer"/>
</Border>
</Popper>
\ No newline at end of file
/// </summary>
public bool IsFixed { get { return Units == Unit.Pixel; }}
public bool IsFit { get { return Value == -1 && Units == Unit.Percent; }}
+ /// <summary>
+ /// True if width is proportional to parent client rectangle
+ /// </summary>
public bool IsRelativeToParent { get { return Value >= 0 && Units == Unit.Percent; }}
#region Operators
public static implicit operator int(Measure m){
public override void onMouseClick (object sender, MouseButtonEventArgs e)
{
IsChecked = !IsChecked;
- e.Handled = true;
base.onMouseClick (sender, e);
}
}
using System;
using System.ComponentModel;
using System.Linq;
-
+using static Crow.Logger;
namespace Crow {
/// <summary>
/// group container that stacked its children horizontally or vertically
stretchedGO.Slot.Width = newW;
stretchedGO.IsDirty = true;
#if DEBUG_LAYOUTING
- Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+ LOG ($"width: {stretchedGO.ToString()}");
#endif
stretchedGO.LayoutChanged -= OnChildLayoutChanges;
stretchedGO.OnLayoutChanges (LayoutingType.Width);
stretchedGO.Slot.Height = newH;
stretchedGO.IsDirty = true;
#if DEBUG_LAYOUTING
- Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
+ LOG ($"height: {stretchedGO.ToString ()}");
#endif
stretchedGO.LayoutChanged -= OnChildLayoutChanges;
stretchedGO.OnLayoutChanges (LayoutingType.Height);
using Crow.Cairo;
using System.Threading;
+using static Crow.Logger;
namespace Crow
{
{
Widget g = sender as Widget;
+#if DEBUG_LAYOUTING
+ LOG ($"{arg.LayoutType}:{g}->{g.Slot}");
+#endif
+
switch (arg.LayoutType) {
case LayoutingType.Width:
if (Width != Measure.Fit)
void searchLargestChild (bool forceMeasure = false)
{
#if DEBUG_LAYOUTING
- Debug.WriteLine("\tSearch largest child");
+ LOG (this.ToString());
#endif
largestChild = null;
contentSize.Width = 0;
}
}
void searchTallestChild (bool forceMeasure = false)
- {
+ {
#if DEBUG_LAYOUTING
- Debug.WriteLine("\tSearch tallest child");
+ LOG (this.ToString());
#endif
tallestChild = null;
contentSize.Height = 0;
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
using Crow.Cairo;
-
+using static Crow.Logger;
namespace Crow
{
/// <summary>
if (child.localDataSourceIsNull & child.localLogicalParentIsNull)
child.OnDataSourceChanged (child, e);
}
+
+ public override int measureRawSize (LayoutingType lt)
+ {
+ if (child != null) {
+ //force measure of child if sizing on children and child has stretched size
+ switch (lt) {
+ case LayoutingType.Width:
+ if (child.Width.IsRelativeToParent)
+ contentSize.Width = child.measureRawSize (LayoutingType.Width);
+ break;
+ case LayoutingType.Height:
+ if (child.Height.IsRelativeToParent)
+ contentSize.Height = child.measureRawSize (LayoutingType.Width);
+ break;
+ }
+ }
+ return base.measureRawSize (lt);
+ }
public override bool UpdateLayout (LayoutingType layoutType)
{
if (child != null) {
- //force sizing to fit if sizing on children and child has stretched size
+ //force measure of child if sizing on children and child has stretched size
switch (layoutType) {
case LayoutingType.Width:
if (Width == Measure.Fit && child.Width.IsRelativeToParent)
- child.Width = Measure.Fit;
+ contentSize.Width = child.measureRawSize (LayoutingType.Width);
break;
case LayoutingType.Height:
if (Height == Measure.Fit && child.Height.IsRelativeToParent)
- child.Height = Measure.Fit;
+ contentSize.Height = child.measureRawSize (LayoutingType.Width);
break;
}
}
if (child == null)
return;
-
+
LayoutingType ltChild = LayoutingType.None;
if (layoutType == LayoutingType.Width) {
if (child.Height.Value < 100 && child.Top == 0)
ltChild |= LayoutingType.Y;
} else if (child.Top == 0)
- ltChild |= LayoutingType.Y;
+ ltChild |= LayoutingType.Y;
}
if (ltChild == LayoutingType.None)
return;
public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
Widget g = sender as Widget;
-
+#if DEBUG_LAYOUTING
+ LOG ($"{arg.LayoutType}:{g}->{child.Slot}");
+#endif
if (arg.LayoutType == LayoutingType.Width) {
+ contentSize.Width = g.Slot.Width;
if (Width != Measure.Fit)
return;
- contentSize.Width = g.Slot.Width;
- this.RegisterForLayouting (LayoutingType.Width);
- }else if (arg.LayoutType == LayoutingType.Height){
+ RegisterForLayouting (LayoutingType.Width);
+ } else if (arg.LayoutType == LayoutingType.Height){
+ contentSize.Height = g.Slot.Height;
if (Height != Measure.Fit)
return;
- contentSize.Height = g.Slot.Height;
- this.RegisterForLayouting (LayoutingType.Height);
+ RegisterForLayouting (LayoutingType.Height);
}
}
protected override void onDraw (Context gr)
/// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
}
+
+ internal bool firstUnresolvedFitWidth (out Widget ancestorInUnresolvedFit)
+ {
+ ancestorInUnresolvedFit = this.Parent as Widget;
+
+ while (ancestorInUnresolvedFit != null) {
+ if (ancestorInUnresolvedFit.width.IsFit)
+ return true;
+ if (!ancestorInUnresolvedFit.Width.IsRelativeToParent || ancestorInUnresolvedFit.Parent is Interface)
+ return false;
+ ancestorInUnresolvedFit = ancestorInUnresolvedFit.Parent as Widget;
+ }
+ return false;
+ }
+
public virtual bool ArrangeChildren { get { return false; } }
/// <summary> Query a layouting for the type pass as parameter, redraw only if layout changed. </summary>
public virtual void RegisterForLayouting(LayoutingType layoutType){
if (Parent != null)
tmp = Parent.ToString () + tmp;
- #if DEBUG_LAYOUTING
+ /*#if DEBUG_LAYOUTING
return Name == "unamed" ? tmp + "." + this.GetType ().Name + GraphicObjects.IndexOf(this).ToString(): tmp + "." + Name;
- #else
+ #else*/
return string.IsNullOrEmpty(Name) ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
- #endif
+ //#endif
}
/// <summary>
/// Checks to handle when widget is removed from the visible graphic tree
// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-
+using static Crow.Logger;
namespace Crow
{
/// <summary>
}
public override void OnLayoutChanges (LayoutingType layoutType)
{
- #if DEBUG_LAYOUTING
- IFace.currentLQI.Slot = LastSlots;
- IFace.currentLQI.Slot = Slot;
- #endif
+#if DEBUG_LAYOUTING
+ LOG ($"{layoutType}: {LastSlots}->{Slot}");
+#endif
switch (layoutType) {
case LayoutingType.Width:
foreach (Widget c in Children) {
gr.Rectangle (rc);
gr.StrokePreserve ();
- gr.SetSourceColor (c);
+ gr.SetSource (c);
gr.Fill ();
penY += fe.Height;
-//
-// DbgLogViewer.cs
+// Copyright (c) 2013-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 System.Collections.Generic;
using System.IO;
//if (x + w > cb.Right)
// continue;
- Color c = Color.Black;
+ Color c = Colors.Black;
if (evt.type == DbgEvtType.GOProcessLayouting) {
switch (evt.data.result) {
case LayoutingQueueItem.Result.Success:
- c = Crow.Color.Green;
+ c = Crow.Colors.Green;
break;
case LayoutingQueueItem.Result.Deleted:
- c = Crow.Color.Red;
+ c = Crow.Colors.Red;
break;
case LayoutingQueueItem.Result.Discarded:
- c = Crow.Color.OrangeRed;
+ c = Crow.Colors.OrangeRed;
break;
case LayoutingQueueItem.Result.Requeued:
- c = Crow.Color.Orange;
+ c = Crow.Colors.Orange;
break;
}
} else if (evt.type.HasFlag (DbgEvtType.GOLock))
- c = Color.BlueViolet;
+ c = Colors.BlueViolet;
else if (colors.ContainsKey (evt.type))
c = colors [evt.type];
//else
// System.Diagnostics.Debugger.Break ();
c = c.AdjustAlpha (0.2);
- gr.SetSourceColor (c);
+ gr.SetSource (c);
gr.Rectangle (x, penY, w, fe.Height);
gr.Fill ();
penY += fe.Height;
- gr.SetSourceColor (Crow.Color.Jet);
+ gr.SetSource (Crow.Colors.Jet);
gr.MoveTo (cb.X, penY - 0.5);
gr.LineTo (cb.Right, penY - 0.5);
gr.Stroke ();
double penX = 5.0 * g.xLevel + cb.Left;
if (g.yIndex == 0)
- gr.SetSourceColor (Crow.Color.LightSalmon);
+ gr.SetSource (Crow.Colors.LightSalmon);
else
Foreground.SetAsSource (gr);
gr.MoveTo (penX, penY - gr.FontExtents.Descent);
gr.ShowText (g.name);
- gr.SetSourceColor (Crow.Color.White);
+ gr.SetSource (Crow.Colors.White);
gr.MoveTo (cb.X, penY - gr.FontExtents.Descent);
gr.ShowText ((i+ ScrollY).ToString());
gr.MoveTo (leftMargin + cb.Left, cb.Top);
gr.LineTo (leftMargin + cb.Left, cb.Bottom);
- gr.SetSourceColor (Crow.Color.Grey);
+ gr.SetSource (Crow.Colors.Grey);
penY = topMargin + ClientRectangle.Top;
double x = xScale * (evt.begin - minTicks - ScrollX) ;
x += leftMargin + cb.Left;
- gr.SetSourceColor (Crow.Color.Yellow);
+ gr.SetSource (Crow.Colors.Yellow);
gr.MoveTo (x, penY);
gr.LineTo (x, cb.Bottom);
gr.Stroke ();
gr.Rectangle (x - 0.5 * te.Width , penY - te.Height, te.Width, te.Height);
gr.Fill ();
gr.MoveTo (x- 0.5 * te.Width, penY - gr.FontExtents.Descent);
- gr.SetSourceColor (Crow.Color.Jet);
+ gr.SetSource (Crow.Colors.Jet);
gr.ShowText (s);
}
Rectangle cb = ClientRectangle;
ctx.Rectangle (ctxR);
- ctx.SetSourceColor (Color.CornflowerBlue);
+ ctx.SetSource (Colors.CornflowerBlue);
ctx.Fill();
ctx.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
ctxR.Width = Math.Max (1, ctxR.Width);
ctx.Rectangle (ctxR);
//ctx.SetSourceColor (Color.LightYellow);
- ctx.SetSourceColor (Color.Jet);
+ ctx.SetSource (Colors.Jet);
ctx.Fill();
ctx.Operator = Cairo.Operator.Over;
base.onMouseMove (sender, e);
updateMouseLocalPos (e.Position);
- if (selStart >= 0 && IFace.Mouse.IsButtonDown(MouseButton.Left))
+ if (selStart >= 0 && IFace.IsDown (Glfw.MouseButton.Left))
selEnd = currentTick;
if (RegisteredLayoutings == LayoutingType.None && !IsDirty)
{
base.onKeyDown (sender, e);
- if (e.Key == Key.F3) {
+ if (e.Key == Glfw.Key.F3) {
if (selEnd < 0)
return;
if (selEnd < selStart)
-//
-// CrowDebugger.cs
+// Copyright (c) 2013-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.Collections.Generic;
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack Background="DimGrey" Margin="10" Width="Fit" Height="Fit" >
+ <VerticalStack Width="Stretched" Margin="10" Background="RoyalBlue">
+ <VerticalStack Width="Stretched" Margin="10" Background="FireBrick">
+ <VerticalStack Width="Stretched" Margin="10" Background="Teal">
+ <VerticalStack Width="Stretched" Margin="10" Background="CornflowerBlue">
+ <Label Text="{./Caption}" Width="Stretched"/>
+ <Label Text="{./Caption}" Width="Stretched"/>
+ <Label Text="{./Caption}" Width="Stretched"/>
+ <Label Text="{./Caption}" Width="Stretched"/>
+ </VerticalStack>
+ </VerticalStack>
+ </VerticalStack>
+ </VerticalStack>
+</VerticalStack>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Container Background="DimGrey" Margin="10" Width="Fit" Height="Fit" >
+ <VerticalStack Width="Stretched" Margin="10" Background="RoyalBlue">
+ <VerticalStack Width="Stretched" Margin="10" Background="FireBrick">
+ <VerticalStack Width="Stretched" Margin="10" Background="Teal">
+ <VerticalStack Width="Stretched" Margin="10" Background="CornflowerBlue">
+ <Label Text="{./Caption}" Width="Stretched"/>
+ <Label Text="{./Caption}" Width="Stretched"/>
+ <Label Text="{./Caption}" Width="Stretched"/>
+ <Label Text="{./Caption}" Width="Stretched"/>
+ </VerticalStack>
+ </VerticalStack>
+ </VerticalStack>
+ </VerticalStack>
+</Container>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Container Background="DimGrey" Margin="10" Width="Fit" Height="Fit" >
+ <Popper Width="Stretched" Margin="10" Background="RoyalBlue">
+ <Container Width="Fit" Height="Fit" Margin="10" Background="Blue">
+ <Container Width="Stretched" Margin="10" Background="Yellow">
+ <Container Width="Stretched" Margin="10" Background="FireBrick">
+ <CheckBox Width="Stretched"/>
+ </Container>
+ </Container>
+ </Container>
+ </Popper>
+</Container>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack Background="DimGrey" Margin="10" Width="Fit" Height="Fit" >
+ <CheckBox Name="cb"/>
+ <CheckBox Name="cb2"/>
+ <Container Visible="{²../cb.IsChecked}" Width="Stretched" Margin="10" Background="RoyalBlue">
+ <VerticalStack Width="Stretched" Margin="5" Background="Yellow">
+ <VerticalStack Width="Stretched" Margin="5" Background="Teal">
+ <VerticalStack Width="Stretched" Margin="1">
+ <VerticalStack Width="Stretched" Margin="10" Background="FireBrick">
+ <Label Text="{./Caption}" Width="Fit" Visible="{²../../../../../../cb2.IsChecked}"/>
+ </VerticalStack>
+ </VerticalStack>
+ </VerticalStack>
+ </VerticalStack>
+ </Container>
+</VerticalStack>
\ No newline at end of file