<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<Optimize>false</Optimize>
<OutputPath>$(SolutionDir)build\Debug</OutputPath>
- <DefineConstants>DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;DEBUG_LAYOUTING0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+ <DefineConstants>DESIGN_MODE;DEBUG_LAYOUTING;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
void initCommands () {
CMDNew = new Command(new Action(() => newFile())) { Caption = "New", Icon = new SvgPicture("#Crow.Coding.ui.icons.blank-file.svg"), CanExecute = true};
- CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#Crow.Coding.ui.icons.outbox.svg")};
- CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false};
- CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false};
+ CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#Crow.Coding.icons.open.svg")};
+ CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.icons.save.svg"), CanExecute = false};
+ CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#Crow.Coding.icons.save.svg"), CanExecute = false};
CMDQuit = new Command(new Action(() => Quit (null, null))) { Caption = "Quit", Icon = new SvgPicture("#Crow.Coding.ui.icons.sign-out.svg")};
CMDUndo = new Command(new Action(() => undo())) { Caption = "Undo", Icon = new SvgPicture("#Crow.Coding.icons.undo.svg"), CanExecute = false};
CMDRedo = new Command(new Action(() => redo())) { Caption = "Redo", Icon = new SvgPicture("#Crow.Coding.icons.redo.svg"), CanExecute = false};
CMDOptions = new Command(new Action(() => loadWindow("#Crow.Coding.ui.Options.crow"))) { Caption = "Editor Options", Icon = new SvgPicture("#Crow.Coding.icons.tools.svg")};
cmdCloseSolution = new Command(new Action(() => closeSolution()))
- { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.ui.icons.paste-on-document.svg"), CanExecute = false};
+ { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.icons.paste-on-document.svg"), CanExecute = false};
CMDViewErrors = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winErrors.crow",this)))
{ Caption = "Errors pane"};
CMDViewDesign = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winDesign.crow",this)))
{ Caption = "Quick Design", CanExecute = true};
CMDViewToolbox = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winToolbox.crow",this)))
- { Caption = "Toolbox", CanExecute = false};
+ { Caption = "Toolbox", CanExecute = true};
CMDViewSchema = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winSchema.crow",this)))
{ Caption = "IML Shematic View", CanExecute = true};
CMDViewStyling = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winStyleView.crow",this)))
}
}
}
- [DefaultValue("BlueGray")]
+ [DefaultValue("SlateGray")]
public virtual Color SelectionBackground {
get { return selBackground; }
set {
RegisterForGraphicUpdate ();
}
}
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
if (lt == LayoutingType.Height)
return (int)Math.Ceiling((fe.Ascent+fe.Descent) * buffer.LineCount) + Margin * 2;
RegisterForGraphicUpdate ();
}
}
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
if (lt == LayoutingType.Height)
return (int)Math.Ceiling((fe.Ascent+fe.Descent) * buffer.LineCount) + Margin * 2;
#endregion
#region GraphicObject overrides
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
if (_pic == null)
return 2 * Margin;
void initCommands (){
cmdSave = new Crow.Command (new Action (() => Save ()))
- { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false };
+ { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = false };
cmdSaveAs = new Crow.Command (new Action (() => SaveAs ()))
- { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false };
+ { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = false };
cmdOpen = new Crow.Command (new Action (() => Open ()))
- { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false };
+ { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.icons.open.svg"), CanExecute = false };
cmdUndo = new Crow.Command (new Action (() => Undo (null)))
{ Caption = "Undo", Icon = new SvgPicture ("#Crow.Coding.icons.undo.svg"), CanExecute = false };
cmdRedo = new Crow.Command (new Action (() => Redo (null)))
Foreground="Transparent"
Background="{./Background}">
<HorizontalStack HorizontalAlignment="Left" Margin="1">
- <Image MaximumSize="10,10" Picture="{../../../../../Icon}"/>
+ <Image Width="10" Height="10" Picture="{../../../../../Icon}" />
<Label Text="{./Caption}"
Foreground="{./Foreground}"
Font="{./Font}" />
<?xml version="1.0"?>
<Border Style="ControlBorder" Foreground="{./Foreground}" Background="{./Background}">
<VerticalStack>
- <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand">
+ <HorizontalStack Width="Stretched" Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand">
<Container Margin="1" Width="9" Height="9" Focusable="true" MouseDown="./onClickForExpand"
MouseEnter="{Background=LightGray}"
MouseLeave="{Background=Transparent}">
Visible="{./IsExpandable}"
SvgSub="{./IsExpanded}"/>
</Container>
- <Label Style="ControlCaption" Text="{./Caption}"/>
+ <Label Style="ControlCaption" Text="{./Caption}" Width="Stretched"/>
</HorizontalStack>
<Container Name="Content" Visible="false"/>
</VerticalStack>
namespace Tests
{
+ public class TestContainer : TestItem {
+ public List<TestItem> Children;
+ }
+ public class TestItem {
+ public string Name;
+ }
class BasicTests : CrowWindow
{
public BasicTests ()
}
}
+
+
#region Test values for Binding
public List<Crow.Command> Commands;
public int intValue = 500;
DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
+ public List<TestContainer> TestTree = new List<TestContainer>(
+ new TestContainer[] {
+ new TestContainer() { Name = "main", Children = new List<TestItem>(
+ new TestItem[] {
+ new TestItem() { Name="item1"},
+ new TestItem() { Name="item2"}
+ }
+ )}});
//DirectoryInfo curDir = new DirectoryInfo (@"/mnt/data/Images");
public FileSystemInfo[] CurDirectory {
get { return curDir.GetFileSystemInfos (); }
this.KeyDown += KeyboardKeyDown1;
//testFiles = new string [] { @"Interfaces/Experimental/testDock.crow" };
- //testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
+ testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
//testFiles = new string [] { @"Interfaces/Divers/0.crow" };
- testFiles = new string [] { @"Interfaces/TemplatedContainer/testTreeView.crow" };
+ //testFiles = new string [] { @"Interfaces/TemplatedContainer/testTreeView.crow" };
//testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
// testFiles = new string[] { @"Interfaces/TemplatedControl/testItemTemplateTag.crow" };
Load(testFiles[idx]).DataSource = this;
+ showTarget = FindByName ("ShowTarget");
// LoadIMLFragment (@"<DockWindow Width=""150"" Height=""150"" Background=""DarkRed"" />", 0);
// LoadIMLFragment (@"<DockWindow Width=""200"" Height=""150"" Background=""DarkGreen"" />", 0);
// LoadIMLFragment (@"<DockWindow Width=""250"" Height=""150"" Background=""Brown"" />", 0);
}
+ GraphicObject showTarget;
void KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
try {
Quit (null, null);
return;
} else if (e.Key == OpenTK.Input.Key.F1) {
- TestList.Add ("new string");
- NotifyValueChanged ("TestList", TestList);
+// TestList.Add ("new string");
+// NotifyValueChanged ("TestList", TestList);
+ showTarget.Visible = !showTarget.Visible;
return;
} else if (e.Key == OpenTK.Input.Key.F4) {
GraphicObject w = Load ("Interfaces/TemplatedContainer/testWindow.goml");
public TechBorder () : base() {}
public TechBorder (Interface iface): base (iface){}
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
return base.measureRawSize (lt) + 6;
}
<?xml version="1.0"?>
-<ColorCircleSelector />
\ No newline at end of file
+<!--<VerticalStack Width="Fit">
+ <Label Background="Brown" />
+ <Slider Orientation="Vertical" Height="Stretched" Width="20" Background="DimGray"/>
+ <Label Name="ShowTarget" Background="DarkBlue"/>
+</VerticalStack>-->
+<Slider Orientation="Horizontal" Height="10" Width="100" Background="DimGray"/>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Container Width="500">
+ <TreeView Data="{TestTree}" Focusable="true">
+ <Template>
+ <VerticalStack
+ Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+ </Template>
+ <ItemTemplate DataType="Tests.TestContainer" Data="Children">
+ <Expandable Caption="{Name}" Focusable="true">
+ <Template>
+ <VerticalStack>
+ <HorizontalStack Spacing="1" Margin="3" Background="Brown">
+ <Image Margin="1" Width="9" Height="9" Focusable="true" MouseDown="./onClickForExpand"
+ Path="{./Image}"
+ Visible="{./IsExpandable}"
+ SvgSub="{./IsExpanded}"
+ MouseEnter="{Background=LightGray}"
+ MouseLeave="{Background=Transparent}"/>
+ <Label Text="{./Caption}"/>
+ </HorizontalStack>
+ <Container Name="Content" Visible="false"/>
+ </VerticalStack>
+ </Template>
+ <VerticalStack Height="Fit" Name="ItemsContainer"/>
+ </Expandable>
+ </ItemTemplate>
+ <ItemTemplate DataType="Tests.TestItem" >
+ <HorizontalStack Margin="0" Background="Teal">
+ <GraphicObject Width="5" Height="5" Background="Green"/>
+ <Label Text="{Name}" Width="Stretched"/>
+ </HorizontalStack>
+ </ItemTemplate>
+
+ </TreeView>
+</Container>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<TreeView Data="{TestTree}">
+ <Template>
+ <VerticalStack
+ Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+ </Template>
+ <ItemTemplate DataType="Tests.TestContainer" Data="Children">
+ <Expandable Caption="{Name}" >
+ <Template>
+ <VerticalStack>
+ <Border Style="TreeItemBorder" Focusable="false" MouseDoubleClick="./onClickForExpand">
+ <HorizontalStack Spacing="1">
+ <Image Margin="1" Width="9" Height="9" Focusable="true" MouseDown="./onClickForExpand"
+ Path="{./Image}"
+ Visible="{./IsExpandable}"
+ SvgSub="{./IsExpanded}"
+ MouseEnter="{Background=LightGray}"
+ MouseLeave="{Background=Transparent}"/>
+ <Image Style="TreeIcon"
+ Path="#Crow.Icons.crowproj.svg"/>
+ <GraphicObject Width="2" Height="9" Background="Green" Visible="{IsStartupProject}"/>
+ <Label Text="{./Caption}"/>
+ </HorizontalStack>
+ </Border>
+ <Container Name="Content" Visible="false"/>
+ </VerticalStack>
+ </Template>
+ <HorizontalStack Height="Fit">
+ <GraphicObject Width="8" Height="10"/>
+ <VerticalStack Height="Fit" Name="ItemsContainer"/>
+ </HorizontalStack>
+ </Expandable>
+ </ItemTemplate>
+ <ItemTemplate DataType="Tests.TestItem" >
+ <Border Style="TreeItemBorder">
+ <HorizontalStack>
+ <GraphicObject Width="5" Height="5"/>
+ <Image Style="TreeIcon"
+ Path="#Crow.Icons.assembly.svg"/>
+ <Label Text="{Name}" Width="Stretched"/>
+ </HorizontalStack>
+ </Border>
+ </ItemTemplate>
+
+</TreeView>
\ No newline at end of file
<None Include="Interfaces\TemplatedContainer\testTabView2.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\TemplatedContainer\testTreeView2.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\TemplatedContainer\testTreeView1.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
Font = "droid, 8";
Width = "50%";
}
+TreeItemBorder {
+ CornerRadius="2";
+ Margin="0";
+ Focusable="true";
+ Height="Fit";
+ Width="Stretched";
+ Foreground="Transparent";
+ MouseEnter="{Foreground=DimGray}";
+ MouseLeave="{Foreground=Transparent}";
+}
+TreeIcon {
+ Margin="0";
+ Width="14";
+ Height="14";
+}
\ No newline at end of file
sharedPicture sp = sharedResources [path];
image = (byte[])sp.Data;
Dimensions = sp.Dims;
- return;
- }
- using (Stream stream = iface.GetStreamFromPath (path)) {
- loadBitmap (new System.Drawing.Bitmap (stream));
+ } else {
+ using (Stream stream = iface.GetStreamFromPath (path)) {
+ loadBitmap (new System.Drawing.Bitmap (stream));
+ }
+ sharedResources [path] = new sharedPicture (image, Dimensions);
}
- sharedResources [path] = new sharedPicture (image, Dimensions);
+ Loaded = true;
}
//load image via System.Drawing.Bitmap, cairo load png only
}
}
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
int tmp = base.measureRawSize (lt);
return tmp < 0 ? tmp : tmp + 2 * BorderWidth;
protected override void onDraw (Context gr)
{
drawborder2 (gr);
+ if (child != null) {
+ gr.Save ();
+ if (ClipToClientRect) {
+ //clip to client zone
+ CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
+ gr.Clip ();
+ }
- gr.Save ();
- if (ClipToClientRect) {
- //clip to client zone
- CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
- gr.Clip ();
+ if (child.requestedLayoutings != LayoutingType.None)
+ child.RegisterForLayouting ();
+ else if (child.Visible)
+ child.Paint (ref gr);
+ gr.Restore ();
}
-
- if (child != null)
- child.Paint (ref gr);
- gr.Restore ();
}
void drawborder2(Context gr){
Rectangle rBack = new Rectangle (Slot.Size);
childrenRWLock.EnterReadLock ();
- foreach (GraphicObject g in Children)
- g.Paint (ref gr);
+ foreach (GraphicObject g in Children) {
+ if (!g.Visible)
+ continue;
+ if (g.requestedLayoutings != LayoutingType.None)
+ g.RegisterForLayouting ();
+ else
+ g.Paint (ref gr);
+ }
childrenRWLock.ExitReadLock ();
Collapse.Raise (this, e);
}
+
+ public override void onKeyDown (object sender, KeyboardKeyEventArgs e)
+ {
+ base.onKeyDown (sender, e);
+
+ if (e.Key == Key.Plus || e.Key == Key.KeypadPlus)
+ IsExpanded = !IsExpanded;
+ }
}
}
else
layoutType &= (~LayoutingType.Y);
}
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
childrenRWLock.EnterReadLock ();
int totSpace = Math.Max(0, Spacing * (Children.Count (c => c.Visible) - 1));
childrenRWLock.ExitReadLock ();
if (lt == LayoutingType.Width) {
- if (Orientation == Orientation.Horizontal)
+ if (Orientation == Orientation.Horizontal) {
+ if (stretchedGO != null)
+ totSpace += stretchedGO.Slot.Width;
return contentSize.Width + totSpace + 2 * Margin;
- }else if (Orientation == Orientation.Vertical)
- return contentSize.Height + totSpace + 2 * Margin;
+ }
+ } else if (Orientation == Orientation.Vertical) {
+ if (stretchedGO != null)
+ totSpace += stretchedGO.Slot.Height;
+ return contentSize.Height + totSpace + 2 * Margin;
+ }
return base.measureRawSize (lt);
}
void adjustStretchedGo (LayoutingType lt){
if (stretchedGO == null)
return;
+ if (!stretchedGO.Visible) {
+ stretchedGO = null;
+ return;
+ }
+
if (lt == LayoutingType.Width) {
- int newW = Math.Max (
+ int newW = 0;
+
+ if (Width == Measure.Fit)
+ newW = stretchedGO.measureRawSize (LayoutingType.Width);
+ else
+ newW = Math.Max (
this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
stretchedGO.MinimumSize.Width);
+
if (stretchedGO.MaximumSize.Width > 0)
newW = Math.Min (newW, stretchedGO.MaximumSize.Width);
if (newW != stretchedGO.Slot.Width) {
stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
}
} else {
- int newH = Math.Max (
- this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
- stretchedGO.MinimumSize.Height);
+ int newH = 0;
+
+ if (Height == Measure.Fit)
+ newH = stretchedGO.measureRawSize (LayoutingType.Height);
+ else
+ newH = Math.Max (
+ this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
+ stretchedGO.MinimumSize.Height);
+
if (stretchedGO.MaximumSize.Height > 0)
newH = Math.Min (newH, stretchedGO.MaximumSize.Height);
if (newH != stretchedGO.Slot.Height) {
case LayoutingType.Width:
if (Orientation == Orientation.Horizontal) {
if (go.Width == Measure.Stretched) {
- if (stretchedGO == null && Width != Measure.Fit)
+ if (stretchedGO == null)
stretchedGO = go;
else if (stretchedGO != go) {
go.Slot.Width = 0;
case LayoutingType.Height:
if (Orientation == Orientation.Vertical) {
if (go.Height == Measure.Stretched) {
- if (stretchedGO == null && Height != Measure.Fit)
+ if (stretchedGO == null)
stretchedGO = go;
else if (stretchedGO != go){
go.Slot.Height = 0;
else
adjustStretchedGo (LayoutingType.Height);
}
+// public override void LayoutingDiscardCheck (LayoutingType lt)
+// {
+// if ((lt == LayoutingType.Height && _orientation == Orientation.Horizontal) ||
+// (lt == LayoutingType.Width && _orientation == Orientation.Vertical))
+// base.LayoutingDiscardCheck (lt);
+// }
}
}
Measure.Stretched : height;
}
set {
+ if (Name == "colIco" && value == Measure.Fit)
+ Debugger.Break ();
if (height == value)
return;
if (value.IsFixed) {
protected void EnqueueForRepaint (){
//if no layouting remains in queue for item, registre for redraw
if (requestedLayoutings != LayoutingType.None)
- RegisterForLayouting (LayoutingType.None);
+ RegisterForLayouting ();
else if (RegisteredLayoutings == LayoutingType.None && IsDirty)
IFace.EnqueueForRepaint (this);
}
#region Layouting
/// <summary> return size of content + margins </summary>
- protected virtual int measureRawSize (LayoutingType lt) {
+ public virtual int measureRawSize (LayoutingType lt) {
return lt == LayoutingType.Width ?
contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
}
public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
}
public virtual bool ArrangeChildren { get { return false; } }
- public virtual void RegisterForLayouting(LayoutingType layoutType){
+ public virtual void RegisterForLayouting(LayoutingType layoutType = LayoutingType.None){
if (Parent == null || !Monitor.TryEnter(IFace.LayoutMutex)) {
requestedLayoutings |= layoutType;
// if (registeredLayoutings != LayoutingType.None)
// Debug.WriteLine ("\t\t{2}: {0} => {1}",LastSlots,Slot,this.name);
// }
// #endif
-
switch (layoutType) {
case LayoutingType.Width:
RegisterForLayouting (LayoutingType.X);
switch (layoutType) {
case LayoutingType.X:
- if (Left == 0) {
+ if (Visible) {
+ if (Left == 0) {
- if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) ||
- RegisteredLayoutings.HasFlag (LayoutingType.Width))
- return false;
+ if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) ||
+ RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return false;
- switch (HorizontalAlignment) {
- case HorizontalAlignment.Left:
- Slot.X = 0;
- break;
- case HorizontalAlignment.Right:
- Slot.X = Parent.ClientRectangle.Width - Slot.Width;
- break;
- case HorizontalAlignment.Center:
- Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
- break;
- }
+ switch (HorizontalAlignment) {
+ case HorizontalAlignment.Left:
+ Slot.X = 0;
+ break;
+ case HorizontalAlignment.Right:
+ Slot.X = Parent.ClientRectangle.Width - Slot.Width;
+ break;
+ case HorizontalAlignment.Center:
+ Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
+ break;
+ }
+ } else
+ Slot.X = Left;
} else
- Slot.X = Left;
+ Slot.X = 0;
if (LastSlots.X == Slot.X)
break;
LastSlots.X = Slot.X;
break;
case LayoutingType.Y:
- if (Top == 0) {
+ if (Visible) {
+ if (Top == 0) {
- if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) ||
- RegisteredLayoutings.HasFlag (LayoutingType.Height))
- return false;
+ if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) ||
+ RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ return false;
- switch (VerticalAlignment) {
- case VerticalAlignment.Top://this could be processed even if parent Height is not known
- Slot.Y = 0;
- break;
- case VerticalAlignment.Bottom:
- Slot.Y = Parent.ClientRectangle.Height - Slot.Height;
- break;
- case VerticalAlignment.Center:
- Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
- break;
- }
+ switch (VerticalAlignment) {
+ case VerticalAlignment.Top://this could be processed even if parent Height is not known
+ Slot.Y = 0;
+ break;
+ case VerticalAlignment.Bottom:
+ Slot.Y = Parent.ClientRectangle.Height - Slot.Height;
+ break;
+ case VerticalAlignment.Center:
+ Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
+ break;
+ }
+ } else
+ Slot.Y = Top;
} else
- Slot.Y = Top;
-
+ Slot.Y = 0;
+
if (LastSlots.Y == Slot.Y)
break;
return true;
}
+ /// <summary>
+ /// Run after layouting item has been discarded for the first time,
+ /// check if sizing has no conflicting rules like fit container, and children all
+ /// stretched.
+ /// </summary>
+ public virtual void LayoutingDiscardCheck (LayoutingType lt) {
+ //#if DEBUG_LAYOUTING
+ Debug.WriteLine ("LayoutingDiscardCheck for {0}",this.ToString());
+ // #endif
+ }
#endregion
#region Rendering
#region Keyboard handling
public virtual void onKeyDown(object sender, KeyboardKeyEventArgs e){
+ GraphicObject p = focusParent;
+ if (p != null)
+ p.onKeyDown(sender,e);
+
KeyDown.Raise (sender, e);
}
public virtual void onKeyUp(object sender, KeyboardKeyEventArgs e){
+ GraphicObject p = focusParent;
+ if (p != null)
+ p.onKeyUp(sender,e);
+
KeyUp.Raise (sender, e);
}
public virtual void onKeyPress(object sender, KeyPressEventArgs e){
Disabled.Raise (this, e);
}
protected virtual void onParentChanged(object sender, DataSourceChangeEventArgs e) {
- RegisterForLayouting (LayoutingType.None);
+ RegisterForLayouting ();
ParentChanged.Raise (this, e);
if (logicalParent == null)
using System.Diagnostics;
using System.Reflection;
using System.Threading;
+using System.Linq;
namespace Crow
}
return false;
}
- protected override int measureRawSize (LayoutingType lt)
+ public override int measureRawSize (LayoutingType lt)
{
- if (Children.Count > 0) {
- if (lt == LayoutingType.Width) {
- if (largestChild == null)
- searchLargestChild ();
- if (largestChild == null) {
- //if still null, not possible to determine a width
- //because all children are stretched, force first one to fit
- //Children [0].Width = Measure.Fit;
- return -1;//cancel actual sizing to let child computation take place
- }
- } else {
- if (tallestChild == null)
- searchTallestChild ();
- if (tallestChild == null) {
- //Children [0].Height = Measure.Fit;
+ if (lt == LayoutingType.Width) {
+ if (largestChild == null) {
+ if (!searchLargestChild ())
return -1;
- }
}
+ } else if (tallestChild == null) {
+ if (!searchTallestChild ())
+ return -1;
}
return base.measureRawSize (lt);
}
}
childrenRWLock.ExitReadLock ();
}
+ // TODO: this could be reworked to measure each item
+ public override void LayoutingDiscardCheck (LayoutingType lt)
+ {
+ if (Children.Count == 0)
+ return;
+ base.LayoutingDiscardCheck (lt);
+ if (lt == LayoutingType.Height) {
+ //if (HeightPolicy == Measure.Fit) {
+ if (tallestChild == null)
+ searchTallestChild (true);
+ //}
+ } else if (lt == LayoutingType.Width) {
+ //if (WidthPolicy == Measure.Fit) {
+ if (largestChild == null)
+ searchLargestChild (true);
+ //}
+ }
+ }
protected override void onDraw (Context gr)
{
base.onDraw (gr);
}
childrenRWLock.EnterReadLock ();
+ List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList ();
+ childrenRWLock.ExitReadLock ();
+ if (visibles.Count == 0)
+ return;
- foreach (GraphicObject g in Children) {
- g.Paint (ref gr);
+ foreach (GraphicObject g in visibles) {
+ if (g.requestedLayoutings != LayoutingType.None)
+ g.RegisterForLayouting ();
+ else
+ g.Paint (ref gr);
}
- childrenRWLock.ExitReadLock ();
gr.Restore ();
}
protected override void UpdateCache (Context ctx)
}
childrenRWLock.EnterReadLock ();
-
- foreach (GraphicObject c in Children) {
- if (!c.Visible)
- continue;
+ List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList();
+ childrenRWLock.ExitReadLock ();
+ if (visibles.Count == 0)
+ return;
+
+ foreach (GraphicObject c in visibles) {
if (Clipping.Contains (c.Slot + ClientRectangle.Position) == RegionOverlap.Out)
continue;
- c.Paint (ref gr);
+ if (c.requestedLayoutings != LayoutingType.None)
+ c.RegisterForLayouting ();
+ else
+ c.Paint (ref gr);
}
- childrenRWLock.ExitReadLock ();
-
#if DEBUG_CLIP_RECTANGLE
Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
#endif
tallestChild = null;
contentSize = 0;
}
- void searchLargestChild(){
+ bool searchLargestChild(bool measure = false){
#if DEBUG_LAYOUTING
Debug.WriteLine("\tSearch largest child");
#endif
largestChild = null;
contentSize.Width = 0;
childrenRWLock.EnterReadLock ();
- for (int i = 0; i < Children.Count; i++) {
- if (!Children [i].Visible)
- continue;
- if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
- continue;
- if (Children [i].Slot.Width > contentSize.Width) {
- contentSize.Width = Children [i].Slot.Width;
- largestChild = Children [i];
+ List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList();
+ childrenRWLock.ExitReadLock ();
+ if (visibles.Count == 0)
+ return true;
+ foreach (GraphicObject c in visibles) {
+ int childWidth = 0;
+ if (measure)
+ childWidth = c.measureRawSize (LayoutingType.Width);
+ else {
+ if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return false;
+ childWidth = c.Slot.Width;
+ }
+ if (childWidth > contentSize.Width) {
+ contentSize.Width = childWidth;
+ largestChild = c;
}
}
- childrenRWLock.ExitReadLock ();
+ return true;
}
- void searchTallestChild(){
+ bool searchTallestChild(bool measure = false){
#if DEBUG_LAYOUTING
Debug.WriteLine("\tSearch tallest child");
#endif
tallestChild = null;
contentSize.Height = 0;
childrenRWLock.EnterReadLock ();
- for (int i = 0; i < Children.Count; i++) {
- if (!Children [i].Visible)
- continue;
- if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
- continue;
- if (Children [i].Slot.Height > contentSize.Height) {
- contentSize.Height = Children [i].Slot.Height;
- tallestChild = Children [i];
+ List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList();
+ childrenRWLock.ExitReadLock ();
+ if (visibles.Count == 0)
+ return true;
+ foreach (GraphicObject c in visibles) {
+ int childHeight = 0;
+ if (measure)
+ childHeight = c.measureRawSize (LayoutingType.Height);
+ else {
+ if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ return false;
+ childHeight = c.Slot.Height;
+ }
+ if (childHeight > contentSize.Height) {
+ contentSize.Height = childHeight;
+ tallestChild = c;
}
}
- childrenRWLock.ExitReadLock ();
+ return true;
}
}
base.checkHoverWidget (e);
}
-// public override bool PointIsIn (ref Point m)
-// {
-// if (!base.PointIsIn (ref m))
-// return false;
-// if (CurrentInterface.HoverWidget == this)
-// return true;
-// lock (Children) {
-// for (int i = Children.Count - 1; i >= 0; i--) {
-// if (Children [i].Slot.ContainsOrIsEqual (m) && !(bool)CurrentInterface.HoverWidget?.IsOrIsInside(Children[i])) {
-// return false;
-// }
-// }
-// }
-// return true;
-// }
#endregion
protected override void Dispose (bool disposing)
if (_pic == value)
return;
_pic = value;
+ if (_pic!=null){
+ if (!_pic.Loaded)
+ _pic.Load (IFace, _pic.Path);
+ Scaled = _pic.Scaled;
+ KeepProportions = _pic.KeepProportions;
+ }
NotifyValueChanged ("Picture", _pic);
RegisterForGraphicUpdate ();
}
#endregion
#region GraphicObject overrides
- protected override int measureRawSize (LayoutingType lt)
+ public override int measureRawSize (LayoutingType lt)
{
if (_pic == null)
return 2 * Margin;
Size cachedTextSize = default(Size);
#region GraphicObject overrides
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
if (lines == null)
lines = getLines;
{
base.onDraw (gr);
- gr.Save ();
+ if (child != null) {
+ gr.Save ();
- if (ClipToClientRect) {
- //clip to client zone
- CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
- gr.Clip ();
- }
+ if (ClipToClientRect) {
+ //clip to client zone
+ CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+ gr.Clip ();
+ }
- if (child != null) {
- if (child.Visible)
+ if (child.requestedLayoutings != LayoutingType.None)
+ child.RegisterForLayouting ();
+ else if (child.Visible)
child.Paint (ref gr);
+
+ gr.Restore ();
}
- gr.Restore ();
}
protected override void UpdateCache (Context ctx)
{
CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
gr.Fill ();
- gr.Save ();
- if (ClipToClientRect) {
- //clip to scrolled client zone
- CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
- gr.Clip ();
+ if (child != null) {
+ gr.Save ();
+ if (ClipToClientRect) {
+ //clip to scrolled client zone
+ CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+ gr.Clip ();
+ }
+
+ gr.Translate (-ScrollX, -ScrollY);
+ if (child.requestedLayoutings != LayoutingType.None)
+ child.RegisterForLayouting ();
+ else if (child.Visible)
+ child.Paint (ref gr);
}
-
- gr.Translate (-ScrollX, -ScrollY);
- if (child != null)
- child.Paint (ref gr);
gr.Restore ();
}
}
}
}
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0)) {
using (Surface drawing = new ImageSurface (Format.A1, 1,1)) {
/// <param name="gr">Backend context</param>
protected override void onDraw (Context gr)
{
- gr.Save ();
+ if (child != null) {
- if (ClipToClientRect) {
- //clip to client zone
- CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
- gr.Clip ();
+ gr.Save ();
+
+ if (ClipToClientRect) {
+ //clip to client zone
+ CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+ gr.Clip ();
+ }
+
+ if (child.requestedLayoutings != LayoutingType.None)
+ child.RegisterForLayouting ();
+ else if (child.Visible)
+ child.Paint (ref gr);
+
+ gr.Restore ();
}
- if (child != null)
- child.Paint (ref gr);
- gr.Restore ();
+
}
#endregion
}
#region GraphicObject overrides
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
if (lines == null)
lines = getLines;
// THE SOFTWARE.
using System;
+using Cairo;
namespace Crow
{
#endregion
#region GraphicObject Overrides
- protected override int measureRawSize(LayoutingType lt)
+ public override int measureRawSize(LayoutingType lt)
{
int tmp = 0;
//Wrapper can't fit in the opposite direction of the wrapper, this func is called only if Fit
#endif
switch (layoutType) {
case LayoutingType.Width:
+ childrenRWLock.EnterReadLock ();
foreach (GraphicObject c in Children) {
if (c.Width.IsRelativeToParent)
c.RegisterForLayouting (LayoutingType.Width);
}
+ childrenRWLock.ExitReadLock ();
if (Height == Measure.Fit)
RegisterForLayouting (LayoutingType.Height);
RegisterForLayouting (LayoutingType.X);
break;
case LayoutingType.Height:
+ childrenRWLock.EnterReadLock ();
foreach (GraphicObject c in Children) {
if (c.Height.IsRelativeToParent)
c.RegisterForLayouting (LayoutingType.Height);
}
+ childrenRWLock.ExitReadLock ();
if (Width == Measure.Fit)
RegisterForLayouting (LayoutingType.Width);
RegisterForLayouting (LayoutingType.Y);
public const int MaxCacheSize = 2048;
/// <summary> Above this count, the layouting is discard from the current
/// update cycle and requeued for the next</summary>
- public const int MaxLayoutingTries = 3;
+ public const int MaxLayoutingTries = 30;
/// <summary> Above this count, the layouting is discard for the widget and it
/// will not be rendered on screen </summary>
- public const int MaxDiscardCount = 5;
+ public const int MaxDiscardCount = 3;
/// <summary> Global font rendering settings for Cairo </summary>
public static FontOptions FontRenderingOptions;
/// <summary> Global font rendering settings for Cairo </summary>
#if DEBUG_LAYOUTING
Debug.WriteLine ("\t\tDiscarded");
#endif
+ go.LayoutingDiscardCheck (LayoutType);
LayoutingTries = 0;
DiscardCount++;
Layoutable.RegisteredLayoutings |= LayoutType;
/// </summary>
public bool Scaled = true;
+ public bool Loaded = false;
+
#region CTOR
/// <summary>
/// Initializes a new instance of Picture.
sharedPicture sp = sharedResources [path];
hSVG = (Rsvg.Handle)sp.Data;
Dimensions = sp.Dims;
- return;
- }
- using (Stream stream = iface.GetStreamFromPath (path)) {
- using (MemoryStream ms = new MemoryStream ()) {
- stream.CopyTo (ms);
-
- hSVG = new Rsvg.Handle (ms.ToArray ());
- Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+ } else {
+ using (Stream stream = iface.GetStreamFromPath (path)) {
+ using (MemoryStream ms = new MemoryStream ()) {
+ stream.CopyTo (ms);
+
+ hSVG = new Rsvg.Handle (ms.ToArray ());
+ Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+ }
}
+ sharedResources [path] = new sharedPicture (hSVG, Dimensions);
}
- sharedResources [path] = new sharedPicture (hSVG, Dimensions);
+ Loaded = true;
}
public void LoadSvgFragment (string fragment) {
hSVG = new Rsvg.Handle (System.Text.Encoding.Unicode.GetBytes(fragment));
Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+ Loaded = true;
}
#region implemented abstract members of Fill
-
public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle))
{
float widthRatio = 1f;