base.OnLoad (e);
//this.CrowInterface.LoadInterface ("#CrowIDE.ui.imlEditor.crow").DataSource = this;
- GraphicObject go = this.CrowInterface.LoadInterface (@"ui/test.crow");
+ //GraphicObject go = this.CrowInterface.LoadInterface (@"ui/test.crow");
+ GraphicObject go = this.CrowInterface.LoadInterface (@"#CrowIDE.ui.imlEditor.crow");
go.DataSource = this;
- Interface i = go.CurrentInterface;
}
}
}
\ No newline at end of file
using System.Threading;
using System.Xml.Serialization;
using System.ComponentModel;
+using System.IO;
namespace CrowIDE
{
set {
if (imlPath == value)
return;
+ if (!File.Exists (value))
+ return;
imlPath = value;
NotifyValueChanged ("ImlPath", imlPath);
+ imlVE.ClearInterface ();
+ imlVE.LoadInterface (imlPath);
}
}
bool drawGrid;
public ImlVisualEditor () : base()
{
imlVE = new Interface ();
+ Thread t = new Thread (interfaceThread);
+ t.IsBackground = true;
+ t.Start ();
+ }
+
+ void interfaceThread()
+ {
+ while (true) {
+ imlVE.Update ();
+
+ bool isDirty = false;
+ lock (imlVE.RenderMutex)
+ isDirty = imlVE.IsDirty;
+
+ if (imlVE.IsDirty) {
+ lock (CurrentInterface.UpdateMutex)
+ RegisterForRedraw ();
+ }
+
+ Thread.Sleep (5);
+ }
+ }
+ public override void OnLayoutChanges (LayoutingType layoutType)
+ {
+ base.OnLayoutChanges (layoutType);
+ switch (layoutType) {
+ case LayoutingType.Width:
+ case LayoutingType.Height:
+ imlVE.ProcessResize (this.ClientRectangle.Size);
+ break;
+ }
+ }
+ public override void RegisterForRedraw ()
+ {
+ base.RegisterForRedraw ();
+ lock(imlVE.UpdateMutex)
+ imlVE.clipping.AddRectangle (imlVE.ClientRectangle);
}
protected override void onDraw (Cairo.Context gr)
{
Rectangle cb = ClientRectangle;
-
+ const double gridLineWidth = 0.1;
+ double glhw = gridLineWidth / 2.0;
int nbLines = cb.Width / gridSpacing ;
- double x = gridSpacing + cb.Center.X - nbLines * gridSpacing;
+ double d = cb.Left + gridSpacing;
for (int i = 0; i < nbLines; i++) {
- gr.MoveTo (x-0.5, cb.Y);
- gr.LineTo (x-0.5, cb.Y);
+ gr.MoveTo (d-glhw, cb.Y);
+ gr.LineTo (d-glhw, cb.Bottom);
+ d += gridSpacing;
}
-
- gr.LineWidth = 1.0;
+ nbLines = cb.Height / gridSpacing;
+ d = cb.Top + gridSpacing;
+ for (int i = 0; i < nbLines; i++) {
+ gr.MoveTo (cb.X, d - glhw);
+ gr.LineTo (cb.Right, d -glhw);
+ d += gridSpacing;
+ }
+ gr.LineWidth = gridLineWidth;
Foreground.SetAsSource (gr, cb);
gr.Stroke ();
+
+ lock (imlVE.RenderMutex) {
+ if (imlVE.IsDirty) {
+ using (Cairo.Surface surf = new Cairo.ImageSurface (imlVE.dirtyBmp, Cairo.Format.Argb32,
+ imlVE.DirtyRect.Width, imlVE.DirtyRect.Height, imlVE.DirtyRect.Width * 4)) {
+ gr.SetSourceSurface (surf, imlVE.DirtyRect.Left, imlVE.DirtyRect.Top);
+ gr.Paint ();
+ }
+ imlVE.IsDirty = false;
+ }
+ }
}
}
}
<?xml version="1.0"?>
<Window Height="80%" Width="80%" CornerRadius="20">
- <HorizontalStack>
- <DirectoryView Name="dv" Root="./" SelectedItemChanged="Tv_SelectedItemChanged"
- Width="20%" Height="100%" Margin="10"/>
- <Splitter/>
- <VerticalStack Width="80%" Height="100%">
- <Container Height="50%" Margin="10" MinimumSize="10,10"
- Name="crowContainer"/>
- <Container/>
- <HorizontalStack Height="50%" Margin="10" MinimumSize="10,1">
- <Scroller Name="scroller1" Background="White"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
- ValueChanged="./_scroller_ValueChanged">
- <TextBox Background="White" Height="Fit"
- VerticalAlignment="Top"
- TextAlignment="TopLeft" Font="mono, 12"
- TextChanged="onImlSourceChanged"
- Text="{CurSources}" Multiline="true"/>
- </Scroller>
- <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
- Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
- Width="14" />
- </HorizontalStack>
- </VerticalStack>
- </HorizontalStack>
+ <VerticalStack>
+ <Border Margin="1" Background="Onyx" Height="Fit">
+ <Label Width="Stretched" Margin="1" Text="{../../dv.SelectedItem}"/>
+ </Border>
+ <HorizontalStack>
+ <DirectoryView Name="dv" Root="./" SelectedItemChanged="Tv_SelectedItemChanged"
+ Width="20%" Height="100%" Margin="10"/>
+ <Splitter/>
+ <VerticalStack Width="80%" Height="100%">
+ <ImlVisualEditor Height="50%" Margin="0" MinimumSize="10,10" Foreground="SkyBlue"
+ ImlPath="{../../../dv.SelectedItem}"
+ Name="crowContainer" Background="Onyx"/>
+ <Splitter/>
+ <HorizontalStack Height="50%" Margin="10" MinimumSize="10,1">
+ <Scroller Name="scroller1" Background="White"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
+ ValueChanged="./_scroller_ValueChanged">
+ <TextBox Background="White" Height="Fit"
+ VerticalAlignment="Top"
+ TextAlignment="TopLeft" Font="mono, 12"
+ TextChanged="onImlSourceChanged"
+ Text="{CurSources}" Multiline="true"/>
+ </Scroller>
+ <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
+ Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
+ Width="14" />
+ </HorizontalStack>
+ </VerticalStack>
+ </HorizontalStack>
+ </VerticalStack>
</Window>
<Container Margin="20" Background="Onyx">
-<!-- <ImlVisualEditor Margin="10" MinimumSize="10,10"
- Name="crowContainer" Background="Green"/>-->
+ <ImlVisualEditor Width="80%" Height="80%" Margin="0" MinimumSize="10,10" Foreground="SkyBlue"
+ Name="crowContainer" Background="Onyx"/>
</Container>
get { return new DirectoryInfo (Root).GetFileSystemInfos (); }
}
public void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
+ if (e.NewValue == SelectedItem)
+ return;
SelectedItem = e.NewValue;
SelectedItemChanged.Raise (this, e);
}
}
/// <summary> query an update of the content, a redraw </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void RegisterForRedraw ()
+ public virtual void RegisterForRedraw ()
{
bmp = null;
if (RegisteredLayoutings == LayoutingType.None)
internal override void itemClick (object sender, MouseButtonEventArgs e)
{
GraphicObject tmp = sender as GraphicObject;
+ if (!tmp.HasFocus)
+ return;
if (selectedItemContainer != null) {
selectedItemContainer.Foreground = Color.Transparent;
selectedItemContainer.Background = Color.Transparent;