Menu {
Margin = "1";
Background = "vgradient|0:DimGrey|1:Black";
+ //Background = "Transparent";
Height = "Fit";
Width = "Stretched";
VerticalAlignment = "Top";
Caption = "MenuItem";
Width = "Stretched";
Height = "Fit";
- Background = "Transparent";
+ //Background = "vgradient|0:DimGrey|1:Black";
+ //Background = "Transparent";
Foreground = "LightGrey";
- MouseEnter = "{Background = vgradient|0:SteelBlue|1:Jet;Foreground=White;}";
- MouseLeave = "{Foreground=LightGrey;Background=Transparent;}";
+ MouseEnter = "{Background=SteelBlue;}";
+ MouseLeave = "{Background=Transparent;}";
+ //MouseEnter = "{Background = vgradient|0:SteelBlue|1:Jet;Foreground=White;}";
+ //MouseLeave = "{Foreground=LightGrey;Background=Transparent;}";
SelectionBackground = "Transparent";
}
MessageBox {
<?xml version="1.0"?>
+<HorizontalStack>
<Popper Font="{./Font}" Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}"
Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}">
<CheckBox IsChecked="{²./IsPopped}" Caption="{./Caption}" Background="{./Background}" Foreground="{./Foreground}">
<Template>
<Border Name="border1"
- MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
- MouseLeave="{Foreground=Transparent}"
- MouseDown="{Foreground=vgradient|0:Black|0.05:Grey|0.85:Grey|1:White}"
- MouseUp="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
MinimumSize = "60,0"
Foreground="Transparent"
Background="{./Background}">
</Template>
</CheckBox>
</Template>
- <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="Jet">
+ <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="vgradient|0:DimGrey|1:Black">
<VerticalStack Name="ItemsContainer"/>
</Border>
</Popper>
+<GraphicObject Background="Green" Width="5" Height="5" Visible="{./AutomaticOpening}"/>
+</HorizontalStack>
using System.Runtime.InteropServices;
using Crow;
using System.Threading;
+using System.Collections.Generic;
+using System.Linq;
namespace tests
{
- class MainClass
+ class MainClass : Interface
{
- static Interface app;
+ static MainClass app;
+ public Command CMDTest;
+ public Measure TestWidth = 100;
+ IList<Color> testList = Color.ColorDic.Values.ToList();
+ public IList<Color> TestList {
+ set{
+ testList = value;
+ NotifyValueChanged ("TestList", testList);
+ }
+ get { return testList; }
+ }
+ public List<KeyValuePair<DbgEvtType, Color>> ColorsKVPList {
+ get {
+ return DbgLogViewer.colors.ToList();
+ }
+ }
+
+ protected override void InitBackend ()
+ {
+ base.InitBackend ();
+ Keyboard.KeyDown += App_KeyboardKeyDown;
+ }
public static void Main(string[] args)
{
- using (app = new Interface ()) {
+ using (app = new MainClass ()) {
// XWindow win = new XWindow (app);
// win.Show ();
//app.LoadIMLFragment (@"<SimpleGauge Level='40' Margin='5' Background='Jet' Foreground='Grey' Width='30' Height='50%'/>");
- app.Keyboard.KeyDown += App_KeyboardKeyDown;
-
+ app.CMDTest = new Command(new Action(() => Console.WriteLine("test cmd"))) { Caption = "Test", Icon = new SvgPicture("#Tests.image.blank-file.svg"), CanExecute = true};
+ //app.AddWidget (@"Interfaces/Divers/testFocus.crow").DataSource = app;
+ //app.AddWidget (@"Interfaces/Divers/testMenu.crow").DataSource = app;
//app.AddWidget (@"Interfaces/Divers/0.crow").DataSource = app;
//app.AddWidget (@"Interfaces/Splitter/1.crow").DataSource = app;
//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;
+
+ GraphicObject go = app.AddWidget ("#Tests.ui.dbgLogColors.crow");
+ go.DataSource = app;
+
+ (go.FindByName("combo") as ComboBox).SelectedItemChanged += combo_selectedItemChanged;
+ (go.FindByName("kvpList") as ListBox).SelectedItemChanged += kvpList_selectedItemChanged;*/
+
app.AddWidget (@"Interfaces/Experimental/testDock.crow").DataSource = app;
- app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock1'/>");
+ /*app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock1'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock2'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock3'/>");
- /*app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
+
+ app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");*/
-
+ long cpt = 0;
+ Measure testWidth = 100;
+ int increment = 1;
+
while (true) {
- #if MEASURE_TIME
+ cpt++;
+ /*
+ testWidth += increment;
+
+ if (increment > 0) {
+ if (testWidth > 500)
+ increment = -increment;
+ } else if (testWidth < 100)
+ increment = -increment;
+ app.NotifyValueChanged ("TestWidth", testWidth);
+*/
+
+ /*app.NotifyValueChanged ("CPT", cpt);
+
+ if (cpt % 2 == 0)
+ app.NotifyValueChanged ("TestColor", Color.Red);
+ else
+ app.NotifyValueChanged ("TestColor", Color.Blue);*/
+
+ /*#if MEASURE_TIME
foreach (PerformanceMeasure m in app.PerfMeasures)
m.NotifyChanges ();
- #endif
- Thread.Sleep(10);
+ #endif*/
+ app.ProcessEvents ();
+ //Thread.Sleep(1);
}
}
/*using (Display disp = new Display())
}*/
}
- static void App_KeyboardKeyDown (object sender, KeyEventArgs e)
+ void onColorUpdate (object sender, MouseButtonEventArgs e)
+ {
+ DbgLogViewer.colorsConf.Set (selectedEvtType.ToString (), newColor);
+ DbgLogViewer.colors [selectedEvtType] = newColor;
+ NotifyValueChanged ("ColorsKVPList", ColorsKVPList);
+ }
+ static DbgEvtType selectedEvtType;
+ static Color newColor;
+
+ static void kvpList_selectedItemChanged (object sender, SelectionChangeEventArgs e)
+ {
+ if (e.NewValue == null)
+ return;
+ selectedEvtType = ((KeyValuePair<DbgEvtType, Color>)e.NewValue).Key;
+ }
+ static void combo_selectedItemChanged (object sender, SelectionChangeEventArgs e)
+ {
+ newColor = (Color)e.NewValue;
+
+ }
+
+ void App_KeyboardKeyDown (object sender, KeyEventArgs e)
{
Console.WriteLine((byte)e.Key);
//#if DEBUG_LOG
- /*switch (e.Key) {
+ switch (e.Key) {
case Key.F2:
DebugLog.save (app);
break;
- }*/
+ case Key.F4:
+ app.NotifyValueChanged ("ColorsKVPList", app.ColorsKVPList);
+ break;
+ case Key.F6:
+ saveDocking ();
+ break;
+ case Key.F7:
+ reloadDocking ();
+ break;
+ case Key.F8:
+ app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
+ break;
+ }
//#endif
}
+
+ void saveDocking () {
+ DockStack ds = FindByName ("mainDock") as DockStack;
+ if (ds == null) {
+ Console.WriteLine ("main dock not found in graphic tree");
+ return;
+ }
+ string conf = ds.ExportConfig ();
+ Console.WriteLine ("docking conf = " + conf);
+ Configuration.Global.Set ("DockingTests", conf);
+ }
+ void reloadDocking () {
+ DockStack ds = FindByName ("mainDock") as DockStack;
+ if (ds == null) {
+ Console.WriteLine ("main dock not found in graphic tree");
+ return;
+ }
+
+ string conf = Configuration.Global.Get<string> ("DockingTests");
+ if (string.IsNullOrEmpty (conf))
+ return;
+
+
+ ds.ImportConfig (conf);
+ }
}
}
--- /dev/null
+//
+// SimpleGauge.cs
+//
+// Author:
+// jp <>
+//
+// 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.
+using System;
+using Crow;
+using System.ComponentModel;
+using Cairo;
+
+namespace Crow
+{
+ public class LaggingGraphicObject : GraphicObject
+ {
+ protected override void onDraw (Context gr)
+ {
+ base.onDraw (gr);
+
+
+ for (int i = 0; i < 100000; i++) {
+ gr.SetSourceColor (Color.Red);
+ gr.Rectangle (0, 0, 100, 100);
+ gr.Stroke ();
+
+ }
+
+ //System.Threading.Thread.Sleep (1000);
+
+ }
+
+ public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ {
+
+
+ RegisterForRedraw ();
+ }
+ }
+}
+
<?xml version="1.0"?>
-<Container Background="DimGrey" Margin="10" Width="90%" Height="90%">
- <GraphicObject Margin="10" Background="SeaGreen"
- MinimumSize="50,50"/>
-</Container>
\ No newline at end of file
+<VerticalStack Margin="10" Background="Jet" >
+ <Label Text="{CPT}" Background="Red" Font="mono, 60" Margin="0"/>
+ <LaggingGraphicObject Name="lagging" Margin="10" Background="{TestColor}"/>
+</VerticalStack>
+
+
</VerticalStack>
</HorizontalStack>
<HorizontalStack Height="Fit" Margin="5">
- <Label Text="MouseEvents" Width="50%" Margin="3"
+ <Label Text="MouseEvents" Width="50%" Margin="3" Focusable="true"
Background="Jet"
Foreground="DimGrey"
TextAlignment="Center"
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack>
+ <Menu>
+ <MenuItem Caption="File" Width="Fit">
+ <MenuItem Command="{CMDTest}"/>
+ <MenuItem Caption="Open"/>
+ <MenuItem Caption="Save"/>
+ <MenuItem Caption="Quit"/>
+ </MenuItem>
+ <MenuItem Caption="Edit" Name="edit" Width="Fit">
+ <MenuItem Caption="Cut"/>
+ <MenuItem Caption="Copy"/>
+ <MenuItem Caption="Paste"/>
+ <MenuItem Caption="Special" Name="special" Width="Fit">
+ <MenuItem Caption="Cut"/>
+ <MenuItem Caption="Copy"/>
+ <MenuItem Caption="Paste"/>
+ </MenuItem>
+ <MenuItem Caption="Special2" Name="special" Width="Fit">
+ <MenuItem Caption="Cut"/>
+ <MenuItem Caption="Copy"/>
+ <MenuItem Caption="Paste"/>
+ </MenuItem>
+ </MenuItem>
+ <MenuItem Caption="Help" Width="Fit">
+ <MenuItem Caption="About"/>
+ <MenuItem Caption="Help"/>
+ </MenuItem>
+ </Menu>
+ <HorizontalStack Height="Fit">
+ <Label Text="Hover:" Width="50" Foreground="Grey"/>
+ <Label Text="{HoverWidget}"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Focus:" Width="50" Foreground="Grey"/>
+ <Label Text="{FocusedWidget}"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Active:" Width="50" Foreground="Grey"/>
+ <Label Text="{ActiveWidget}"/>
+ </HorizontalStack>
+ <Container Fit="true" Margin="50" Background="SlateGrey">
+ <Label Text="MouseEvents" Margin="3" Focusable="true" Fit="true"
+ Background="Jet"
+ Foreground="DimGrey"
+ TextAlignment="Center"
+ MouseEnter="{Foreground=White}"
+ MouseLeave="{Foreground=DimGrey}"
+ MouseDown="{Background=DarkRed}"
+ MouseClick="{Foreground=Green}"
+ MouseDoubleClick="{Foreground=Yellow}"
+ MouseUp="{Background=Jet}"/>
+ </Container>
+ <TextBox Width="300" Margin="10"/>
+ <Slider Width="300" Height="12"/>
+ <ComboBox Data="{TestList}" Width="120">
+ <ItemTemplate DataType="Crow.Color">
+ <HorizontalStack
+ HorizontalAlignment="Left"
+ Height="Fit" Width="200" Margin="1" Focusable="true"
+ MouseEnter="{Background=hgradient|0:DarkRed|1:Transparent}"
+ MouseLeave="{Background=Transparent}">
+ <GraphicObject Height="12" Width="20" Background="{}" Margin="0" CornerRadius="3"/>
+ <Label Text="{}" Margin="0" Width="Stretched"/>
+ </HorizontalStack>
+ </ItemTemplate>
+ </ComboBox>
+ <HorizontalStack Height="Fit" Margin="1" Background="DimGrey" Width="200">
+ <VerticalStack Spacing="2" Width="50%">
+ <CheckBox Caption="test" MouseEnter="{Background=Blue}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox />
+ <CheckBox />
+ <CheckBox IsChecked="true"/>
+ </VerticalStack>
+ <VerticalStack Spacing="2" Width="50%">
+ <RadioButton Fit="true"/>
+ <RadioButton Fit="true" IsChecked="true"/>
+ <RadioButton Fit="true"/>
+ <RadioButton Fit="true"/>
+ </VerticalStack>
+ </HorizontalStack>
+</VerticalStack>
--- /dev/null
+<?xml version="1.0"?>
+<Menu>
+ <MenuItem Caption="File" Width="Fit">
+ <MenuItem Command="{CMDTest}"/>
+ </MenuItem>
+</Menu>
<Label Text="{./DockingPosition}" TextAlignment="Left" Width="Fit"
Foreground="White" />
</HorizontalStack>
+ <Label Text="{./Width}" TextAlignment="Left" Width="Fit"
+ Foreground="White" />
+ <Label Text="{./Height}" TextAlignment="Left" Width="Fit"
+ Foreground="White" />
+
<HorizontalStack Visible="{./IsDocked}" Height="Fit" Margin="1" Background="Grey">
<Label Text="{./Caption}" TextAlignment="Left" Width="Stretched"
Foreground="Jet" />
<?xml version="1.0"?>
-<Window Width="Stretched" Height="Stretched">
- <DockStack Background="#60101050" Margin="20">
+<Window Width="Stretched" Height="Stretched" Background="Jet">
+ <DockStack Name="mainDock" Background="DarkRed" Margin="20">
</DockStack>
</Window>
<!---
--- /dev/null
+<?xml version="1.0"?>
+<Border Foreground="Transparent" Focusable="true" HorizontalAlignment="Left" Height="Fit">
+ <HorizontalStack Margin="0"
+ MouseEnter="{Background=CornflowerBlue}"
+ MouseLeave="{Background=Transparent}">
+ <GraphicObject Height="8" Width="14" Background="{}" Margin="0" CornerRadius="2"/>
+ <Label Text="{}" Margin="0" Width="Stretched" Font="mono, 8"/>
+ </HorizontalStack>
+</Border>
+
<Compile Include="GraphicObjects\HexaContainer.cs" />
<Compile Include="GraphicObjects\TechBorder.cs" />
<Compile Include="keysyms.cs" />
+ <Compile Include="GraphicObjects\LaggingGraphicObject.cs" />
</ItemGroup>
<ItemGroup>
<None Include="image\u.svg">
<None Include="Interfaces\TemplatedContainer\testTabView2.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\Divers\testFocus.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Divers\testMenu.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
<EmbeddedResource Include="Interfaces\Experimental\DockWindow.template">
<LogicalName>Crow.DockWindow.template</LogicalName>
</EmbeddedResource>
+ <EmbeddedResource Include="ui\MenuItem.template">
+ <LogicalName>Crow.MenuItem.template</LogicalName>
+ </EmbeddedResource>
+ <EmbeddedResource Include="image\blank-file.svg" />
+ <EmbeddedResource Include="ui\dbgLogColors.crow" />
+ <EmbeddedResource Include="Interfaces\colorItem2.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Crow.csproj">
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M10 0h-8v16h12v-12l-4-4zM9 5h4v10h-10v-14h6v4zM10 4v-3l3 3h-3z"></path>
+</svg>
Foreground = "LightGrey";
Focusable = "true";
}
+DockWindow{
+ Background = "0.1,0.1,0.1,0.5";
+}
--- /dev/null
+<?xml version="1.0"?>
+<Popper Font="{./Font}" Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}"
+ Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
+ IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}" IsEnabled="{./IsEnabled}">
+ <Template>
+ <CheckBox IsChecked="{²./IsPopped}" Caption="{./Caption}" Background="{./Background}" Foreground="{./Foreground}">
+ <Template>
+ <Border Name="border1"
+ MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
+ MouseLeave="{Foreground=Transparent}"
+ MouseDown="{Foreground=vgradient|0:Black|0.05:Grey|0.85:Grey|1:White}"
+ MouseUp="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
+ MinimumSize = "40,0"
+ Foreground="Transparent"
+ Background="{./Background}">
+ <HorizontalStack HorizontalAlignment="Left" Margin="1">
+ <Image Width="10" Height="10" Picture="{../../../../../Icon}"/>
+ <Label Text="{./Caption}"
+ Foreground="{./Foreground}"
+ Font="{./Font}" />
+ </HorizontalStack>
+ </Border>
+ </Template>
+ </CheckBox>
+ </Template>
+ <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="Jet">
+ <VerticalStack Name="ItemsContainer"/>
+ </Border>
+</Popper>
<?xml version="1.0"?>
-<VerticalStack>
- <HorizontalStack Height="Fit">
- <Label Text="Scale X:"/>
- <Label Text="{../../view.XScale}"/>
- <Label Text="Scroll X:"/>
- <Label Text="{../../view.ScrollX}"/>
- <Label Text="Max Scroll X:"/>
- <Label Text="{../../view.MaxScrollX}"/>
- <Label Text="Scroll Y:"/>
- <Label Text="{../../view.ScrollY}"/>
- <Label Text="Visible Lines:"/>
- <Label Text="{../../view.VisibleLines}"/>
- <Label Text="Visible Ticks:"/>
- <Label Text="{../../view.VisibleTicks}"/>
- <Label Text="CurrentLine:"/>
- <Label Text="{../../view.CurrentLine}"/>
- </HorizontalStack>
- <HorizontalStack>
- <DbgLogViewer Margin="0" Name="view" LogFile="debug.log" MouseWheelSpeed="10"/>
- <ScrollBar Name="scrollbar1" Orientation="Vertical"
- Value="{²../view.ScrollY}" Maximum="{../view.MaxScrollY}"
- CursorSize="{../view.ChildHeightRatio}"
- LargeIncrement="{../view.PageHeight}" SmallIncrement="30"
- Width="14" />
- </HorizontalStack>
- <ScrollBar Style="HScrollBar" Name="scrollbarX" Orientation="Horizontal"
- Value="{²../view.ScrollX}" Maximum="{../view.MaxScrollX}"
- CursorSize="{../view.ChildWidthRatio}"
- LargeIncrement="{../view.PageWidth}" SmallIncrement="30"
- Height="14" />
-</VerticalStack>
+<Window Width="Stretched" Height="Stretched">
+ <VerticalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Scale X:"/>
+ <Label Text="{../../view.XScale}"/>
+ <Label Text="Scroll X:"/>
+ <Label Text="{../../view.ScrollX}"/>
+ <Label Text="Max Scroll X:"/>
+ <Label Text="{../../view.MaxScrollX}"/>
+ <Label Text="Scroll Y:"/>
+ <Label Text="{../../view.ScrollY}"/>
+ <Label Text="Visible Lines:"/>
+ <Label Text="{../../view.VisibleLines}"/>
+ <Label Text="Visible Ticks:"/>
+ <Label Text="{../../view.VisibleTicks}"/>
+ <Label Text="CurrentLine:"/>
+ <Label Text="{../../view.CurrentLine}"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <DbgLogViewer Margin="0" Name="view" LogFile="debug.log" MouseWheelSpeed="10"/>
+ <ScrollBar Name="scrollbar1" Orientation="Vertical"
+ Value="{²../view.ScrollY}" Maximum="{../view.MaxScrollY}"
+ CursorSize="{../view.ChildHeightRatio}"
+ LargeIncrement="{../view.PageHeight}" SmallIncrement="30"
+ Width="12" />
+ </HorizontalStack>
+ <ScrollBar Style="HScrollBar" Name="scrollbarX" Orientation="Horizontal"
+ Value="{²../view.ScrollX}" Maximum="{../view.MaxScrollX}"
+ CursorSize="{../view.ChildWidthRatio}"
+ LargeIncrement="{../view.PageWidth}" SmallIncrement="30"
+ Height="12" />
+ </VerticalStack>
+</Window>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Window Template="#Crow.ToolWindow.template" AlwaysOnTop="true" Width="400" Height="300"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom">
+ <VerticalStack>
+ <Button Caption="update" MouseClick="onColorUpdate"/>
+ <HorizontalStack Height="Fit" DataSource="{../kvpList.SelectedItem}" Margin="10">
+ <Label Text="{Key}" Margin="0" Width="Stretched" Font="mono, 8"/>
+ <ComboBox Data="{TestList}" ItemTemplate="#Tests.Interfaces.colorItem2.crow" Name="combo"
+ SelectedItem="{Value}">
+ <Template>
+ <Popper Caption="{./SelectedItem}" Name="popper" PopDirection="Bottom" Foreground="{./Foreground}" Background="{./Background}">
+ <Template>
+ <CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}" Foreground="{./Foreground}" Background="{./Background}">
+ <Template>
+ <Border CornerRadius="0" Foreground="LightGrey">
+ <HorizontalStack Margin="0" Spacing="1">
+ <!---<GraphicObject Height="8" Width="14" Background="{./Caption}" Margin="0" CornerRadius="2"/>-->
+ <Label MinimumSize="80,10" Text="{./Caption}" Margin="0" Width="Stretched" Font="mono, 8"/>
+ <Button Width="14" Height="14" Focusable="false"
+ Template="#Crow.Templates.ArrowBut.template">
+ <Image Margin="0" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
+ </Button>
+ </HorizontalStack>
+ </Border>
+ </Template>
+ </CheckBox>
+ </Template>
+ <Border Background="DimGrey" BorderWidth="1" Margin="1"
+ MinimumSize="{../../MinimumPopupSize}" Fit="true">
+ <Scroller Name="scroller1" Margin="2"
+ MaximumSize="0,200"
+ HorizontalAlignment="Left">
+ <VerticalStack
+ Height="Fit" Name="ItemsContainer" Margin="0"
+ HorizontalAlignment="Left"
+ VerticalAlignment="Top"/>
+ </Scroller>
+ </Border>
+ </Popper>
+ </Template>
+ </ComboBox>
+ <GraphicObject Height="8" Width="14" Background="{Value}" Margin="0" CornerRadius="2"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <ListBox Name="kvpList" Data="{ColorsKVPList}" Margin="0"
+ Template="#Crow.Templates.ScrollingListBox.template">
+ <ItemTemplate>
+ <Border Foreground="Transparent" Focusable="true" HorizontalAlignment="Left" Height="Fit">
+ <HorizontalStack Margin="0"
+ MouseEnter="{Background=CornflowerBlue}"
+ MouseLeave="{Background=Transparent}">
+ <GraphicObject Height="8" Width="14" Background="{Value}" Margin="0" CornerRadius="2"/>
+ <Label Text="{Key}" Margin="0" Width="Stretched" Font="mono, 8"/>
+ </HorizontalStack>
+ </Border>
+ </ItemTemplate>
+ </ListBox>
+ </HorizontalStack>
+ </VerticalStack>
+</Window>
\ No newline at end of file
/// load the image for rendering from the path given as argument
/// </summary>
/// <param name="path">image path, may be embedded</param>
- public override void Load (Interface iface, string path)
- {
- Path = path;
- if (sharedResources.ContainsKey (path)) {
- sharedPicture sp = sharedResources [path];
+ void Load ()
+ {
+ if (sharedResources.ContainsKey (Path)) {
+ sharedPicture sp = sharedResources [Path];
image = (byte[])sp.Data;
Dimensions = sp.Dims;
return;
}
- using (Stream stream = iface.GetStreamFromPath (path)) {
+ using (Stream stream = Interface.StaticGetStreamFromPath (Path)) {
loadBitmap (new System.Drawing.Bitmap (stream));
}
- sharedResources [path] = new sharedPicture (image, Dimensions);
+ sharedResources [Path] = new sharedPicture (image, Dimensions);
}
//load image via System.Drawing.Bitmap, cairo load png only
using System.IO;
using System.Collections.Generic;
using System.Threading;
+using System.Linq;
namespace Crow
{
}
startSavingThread ();
}
+
static Configuration ()
{
string configRoot =
}
globalConfig = new Configuration (globalConfigPath);
}
+
+ public string[] Names {
+ get {
+ return items.Keys.ToArray ();
+ }
+ }
+
void startSavingThread(){
Thread t = new Thread (savingThread);
t.IsBackground = true;
save ();
isDirty = false;
}
- Thread.Sleep (1000);
+ Thread.Sleep (100);
}
}
/// <summary>
using System;
using Crow.IML;
using System.Linq;
+using System.Text;
+using System.IO;
namespace Crow
{
if (dw != null)
dw.DockingPosition = (Orientation == Orientation.Horizontal ? Alignment.Right : Alignment.Bottom);
}
+
+ //read next value in config string until next ';'
+ string getConfAttrib (string conf, ref int i) {
+ int nextI = conf.Substring (i).IndexOf (';');
+ string tmp = conf.Substring (i, nextI);
+ i += nextI + 1;
+ return tmp;
+ }
+ /// <summary>
+ /// Imports the config.
+ /// </summary>
+ /// <param name="conf">Conf.</param>
+ /// <param name="dataSource">Data source for the docked windows</param>
+ public void ImportConfig (string conf, object dataSource = null) {
+ lock (IFace.UpdateMutex) {
+ ClearChildren ();
+ stretchedChild = null;
+ int i = 0;
+ Orientation = (Orientation)Enum.Parse (typeof(Orientation), getConfAttrib (conf, ref i));
+ importConfig (conf, ref i, dataSource);
+ }
+ }
+ public string ExportConfig () {
+ return Orientation.ToString() + ";" + exportConfig();
+ }
+ void importConfig (string conf, ref int i, object dataSource) {
+ if (conf [i++] != '(')
+ return;
+ while (i < conf.Length - 4) {
+ string sc = conf.Substring (i, 4);
+ i += 4;
+ switch (sc) {
+ case "WIN;":
+ DockWindow dw = null;
+ string wName = getConfAttrib (conf, ref i);
+ try {
+ dw = IFace.Load (wName) as DockWindow;
+ } catch {
+ dw = new DockWindow (IFace);
+ }
+
+ dw.Name = wName;
+ dw.Width = Measure.Parse (getConfAttrib (conf, ref i));
+ dw.Height = Measure.Parse (getConfAttrib (conf, ref i));
+ dw.DockingPosition = (Alignment)Enum.Parse (typeof(Alignment), getConfAttrib (conf, ref i));
+ dw.IsDocked = true;
+ dw.DataSource = dataSource;
+ this.AddChild (dw);
+
+ break;
+ case "STK;":
+ DockStack ds = new DockStack (IFace);
+ ds.Width = Measure.Parse (getConfAttrib (conf, ref i));
+ ds.Height = Measure.Parse (getConfAttrib (conf, ref i));
+ ds.Orientation = (Orientation)Enum.Parse (typeof(Orientation), getConfAttrib (conf, ref i));
+
+ this.AddChild (ds);
+
+ ds.importConfig (conf, ref i, dataSource);
+ break;
+ case "SPL;":
+ Splitter sp = new Splitter (IFace);
+ sp.Width = Measure.Parse (getConfAttrib (conf, ref i));
+ sp.Height = Measure.Parse (getConfAttrib (conf, ref i));
+ sp.Thickness = int.Parse (getConfAttrib (conf, ref i));
+ this.AddChild (sp);
+ break;
+ }
+ char nextC = conf [i++];
+ if (nextC == ')')
+ break;
+ }
+ }
+ string exportConfig () {
+ StringBuilder tmp = new StringBuilder("(");
+
+ for (int i = 0; i < Children.Count; i++) {
+ if (Children [i] is DockWindow) {
+ DockWindow dw = Children [i] as DockWindow;
+ tmp.Append (string.Format("WIN;{0};{1};{2};{3};",dw.Name, dw.Width, dw.Height, dw.DockingPosition));
+ } else if (Children [i] is DockStack) {
+ DockStack ds = Children [i] as DockStack;
+ tmp.Append (string.Format("STK;{0};{1};{2};{3}", ds.Width, ds.Height, ds.Orientation, ds.exportConfig()));
+ } else if (Children [i] is Splitter) {
+ Splitter sp = Children [i] as Splitter;
+ tmp.Append (string.Format("SPL;{0};{1};{2};", sp.Width, sp.Height, sp.Thickness));
+ }
+ if (i < Children.Count - 1)
+ tmp.Append ("|");
+ }
+
+ tmp.Append (")");
+ return tmp.ToString ();
+ }
}
}
public class DockWindow : Window
{
#region CTOR
- public DockWindow () : base ()
- {
- }
+ public DockWindow () {}
+ public DockWindow (Interface iface) : base (iface) {}
#endregion
- int undockThreshold = 4;
+ int undockThreshold = 10;
bool isDocked = false;
Alignment docking = Alignment.Undefined;
Undock ();
base.close ();
}
-
- public string ExportWinConfigs () {
- return string.Format ("{0};{1};{2}", this.Name, DockingPosition, savedSlot);
- }
}
}
else
adjustStretchedGo (LayoutingType.Height);
}
+
+ public override void ClearChildren ()
+ {
+ base.ClearChildren ();
+ stretchedGO = null;
+ }
}
}
if (value != null)
rootDataLevel = true;
-
+
+ #if DEBUG_LOG
+ DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GOLockLayouting, this);
+ #endif
lock (IFace.LayoutMutex) {
OnDataSourceChanged (this, dse);
NotifyValueChanged ("DataSource", DataSource);
}
+ #if DEBUG_LOG
+ dbgEvt.end = DebugLog.chrono.ElapsedTicks;
+ #endif
}
get {
return rootDataLevel ? dataSource : dataSource == null ?
public virtual void RegisterClip(Rectangle clip){
#if DEBUG_LOG
DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GORegisterClip, this);
- #endif
- Rectangle r = clip + ClientRectangle.Position;
+ #endif
+ Rectangle cb = ClientRectangle;
+ Rectangle r = clip + cb.Position;
+ if (r.Right > cb.Right)
+ r.Width -= r.Right - cb.Right;
+ if (r.Bottom > cb.Bottom)
+ r.Height -= r.Bottom - cb.Bottom;
if (CacheEnabled && !IsDirty)
Clipping.UnionRectangle (r);
if (Parent == null)
dbgEvt.end = DebugLog.chrono.ElapsedTicks;
#endif
}
- /// <summary> Full update, taking care of sizing policy </summary>
+ /// <summary> Full update, content and layouting, taking care of sizing policy </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RegisterForGraphicUpdate ()
{
else if (RegisteredLayoutings == LayoutingType.None)
IFace.EnqueueForRepaint (this);
}
- /// <summary> query an update of the content, a redraw </summary>
+ /// <summary> query an update of the content without layouting changes</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RegisterForRedraw ()
{
#if DEBUG_LOG
DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GORecreateCache, this);
#endif
- IsDirty = false;
+
+ /*if (bmp == null)
+ bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height);
+ else if (LastPaintedSlot.Width != Slot.Width || LastPaintedSlot.Height != Slot.Height)
+ bmp.SetSize (Slot.Width, Slot.Height);*/
bmp?.Dispose ();
- bmp = IFace.surf.CreateSimilar(Content.ColorAlpha, Slot.Width, Slot.Height);
+ bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
+
using (Context gr = new Context (bmp)) {
gr.Antialias = Interface.Antialias;
onDraw (gr);
}
- bmp.Flush ();
+
+ IsDirty = false;
+
#if DEBUG_LOG
dbgEvt.end = DebugLog.chrono.ElapsedTicks;
#endif
#if DEBUG_LOG
DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GOUpdateCacheAndPaintOnCTX, this);
#endif
+
Rectangle rb = Slot + Parent.ClientRectangle.Position;
if (clearBackground) {
ctx.Save ();
ctx.Fill ();
ctx.Restore ();
}
+
ctx.SetSourceSurface (bmp, rb.X, rb.Y);
ctx.Paint ();
Clipping.Dispose ();
childrenRWLock.ExitReadLock ();
#if DEBUG_CLIP_RECTANGLE
- Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
+ /*gr.LineWidth = 1;
+ gr.SetSourceColor(Color.DarkMagenta.AdjustAlpha (0.8));
+ for (int i = 0; i < Clipping.NumRectangles; i++)
+ gr.Rectangle(Clipping.GetRectangle(i));
+ gr.Stroke ();*/
#endif
}
gr.Dispose ();
else
pic = new BmpPicture (path);
- pic.Load (IFace, path);
+
pic.Scaled = scaled;
pic.KeepProportions = keepProps;
NotifyValueChanged ("Orientation", orientation);
}
}
- [XmlIgnore]public bool AutomaticOpenning
+ [XmlIgnore]public bool AutomaticOpening
{
get { return autoOpen; }
- set { autoOpen = value; }
+ set {
+ if (autoOpen == value)
+ return;
+ autoOpen = value;
+ NotifyValueChanged ("AutomaticOpening", autoOpen);
+ }
}
#endregion
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- AutomaticOpenning = false;
+ AutomaticOpening = false;
}
}
}
Measure popWidth, popHeight;
#region Public properties
- [XmlAttributeAttribute][DefaultValue(false)]
+ [DefaultValue(false)]
public bool IsOpened {
get { return isOpened; }
set {
if (isOpened) {
onOpen (this, null);
if (LogicalParent is Menu)
- (LogicalParent as Menu).AutomaticOpenning = true;
+ (LogicalParent as Menu).AutomaticOpening = true;
}else
onClose (this, null);
}
}
- [XmlAttributeAttribute][DefaultValue(null)]
+ [DefaultValue(null)]
public virtual Command Command {
get { return command; }
set {
closeMenu ();
}
if(!IsOpened)
- (LogicalParent as Menu).AutomaticOpenning = false;
+ (LogicalParent as Menu).AutomaticOpening = false;
}
protected virtual void onOpen (object sender, EventArgs e){
Open.Raise (this, null);
Menu menu = LogicalParent as Menu;
if (menu == null)
return;
- if (menu.AutomaticOpenning && items.Children.Count>0)
+ if (menu.AutomaticOpening && items.Children.Count>0)
IsOpened = true;
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
MenuItem tmp = LogicalParent as MenuItem;
while (tmp != null) {
tmp.IsOpened = false;
+ tmp.Background = Color.Transparent;
+ tmp.AutomaticOpening = false;
tmp = tmp.LogicalParent as MenuItem;
}
}
public override void onKeyDown (object sender, KeyEventArgs e)
{
base.onKeyDown (sender, e);
- /*
+
Key key = e.Key;
switch (key)
if (selectionIsEmpty) {
if (!MoveRight ())
return;
- }else if (e.Shift)
+ }else if (IFace.Keyboard.Shift)
IFace.Clipboard = this.SelectedText;
this.DeleteChar ();
break;
- case Key.ISO_Enter:
case Key.KP_Enter:
+ case Key.Return:
if (!selectionIsEmpty)
this.DeleteChar ();
if (Multiline)
SelRelease = -1;
break;
case Key.Home:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = new Point (CurrentColumn, CurrentLine);
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = 0;
CurrentColumn = 0;
SelRelease = new Point (CurrentColumn, CurrentLine);
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = 0;
CurrentColumn = 0;
break;
case Key.End:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = int.MaxValue;
CurrentColumn = int.MaxValue;
SelRelease = CurrentPosition;
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = int.MaxValue;
CurrentColumn = int.MaxValue;
break;
case Key.Insert:
- if (e.Shift)
+ if (IFace.Keyboard.Shift)
this.Insert (IFace.Clipboard);
- else if (e.Control && !selectionIsEmpty)
+ else if (IFace.Keyboard.Ctrl && !selectionIsEmpty)
IFace.Clipboard = this.SelectedText;
break;
case Key.Left:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = new Point(CurrentColumn, CurrentLine);
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordStart ();
else if (!MoveLeft ())
return;
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordStart ();
else
MoveLeft();
break;
case Key.Right:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordEnd ();
else if (!MoveRight ())
return;
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordEnd ();
else
MoveRight ();
break;
case Key.Up:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
CurrentLine--;
CurrentLine--;
break;
case Key.Down:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
CurrentLine++;
break;
case Key.Menu:
break;
- case Key.NumLock:
- break;
- case Key.PageDown:
+ case Key.Num_Lock:
break;
- case Key.PageUp:
+ case Key.Page_Down:
break;
- case Key.RWin:
+ case Key.Page_Up:
break;
case Key.Tab:
this.Insert ("\t");
default:
break;
}
- */
+
RegisterForGraphicUpdate();
}
public override void onKeyPress (object sender, KeyPressEventArgs e)
}
#endregion
+ protected bool running;
protected virtual void InitBackend () {
backend = new Crow.XCB.XCBBackend ();
//backend = new Crow.XLib.XLibBackend ();
Keyboard.KeyUp += Keyboard_KeyUp;
Keyboard.KeyPress += Keyboard_KeyPress;
- initTooltip ();
- initContextMenus ();
+ //initTooltip ();
+ //initContextMenus ();
+
+ running = true;
Thread t = new Thread (interfaceThread);
t.IsBackground = true;
void interfaceThread()
{
- while (true) {
+ while (running) {
Update ();
- backend.ProcessEvents ();
+ Thread.Sleep (1);
}
}
}
#endregion
+ public void ProcessEvents() {
+ backend.ProcessEvents ();
+ }
public void Init () {
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
_activeWidget = value;
+ #if DEBUG_FOCUS
+ NotifyValueChanged("ActiveWidget", _activeWidget);
+ #endif
+
if (_activeWidget != null)
{
_activeWidget.IsActive = true;
#if DEBUG_FOCUS
+ NotifyValueChanged("ActiveWidget", _activeWidget);
Debug.WriteLine("Active => " + _activeWidget.ToString());
}else
Debug.WriteLine("Active => null");
_hoverWidget.IsHover = false;
_hoverWidget = value;
+ #if DEBUG_FOCUS
+ NotifyValueChanged("HoverWidget", _hoverWidget);
+ #endif
if (_hoverWidget != null)
{
if (_focusedWidget != null)
_focusedWidget.HasFocus = false;
_focusedWidget = value;
+ #if DEBUG_FOCUS
+ NotifyValueChanged("FocusedWidget", _focusedWidget);
+ #endif
if (_focusedWidget != null)
_focusedWidget.HasFocus = true;
}
}
#if DEBUG_CLIP_RECTANGLE
- clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
+ ctx.LineWidth = 1;
+ ctx.SetSourceColor(Color.Magenta.AdjustAlpha (0.5));
+ for (int i = 0; i < clipping.NumRectangles; i++)
+ ctx.Rectangle(clipping.GetRectangle(i));
+ ctx.Stroke ();
#endif
clipping.Dispose ();
/// <summary>
/// Measurement unit
/// </summary>
- public enum Unit { Pixel, Percent, Inherit }
+ public enum Unit {Undefined, Pixel, Percent, Inherit }
/// <summary>
/// Measure class allow proportional sizes as well as stretched and fit on content.
/// </summary>
public static Measure Parse(string s){
if (string.IsNullOrEmpty (s))
- return Measure.Stretched;
+ return default(Measure);
string st = s.Trim ();
int tmp = 0;
IntPtr p = NativeMethods.cairo_surface_create_similar (
this.Handle, content, width, height);
- return new Cairo.Surface (p, true);
+ return Surface.Lookup(p, true);
}
~Surface ()
NativeMethods.cairo_surface_destroy (handle);
handle = IntPtr.Zero;
}
+ public virtual void SetSize (int width, int height) {
+ }
public Status Finish ()
{
IntPtr ptr = NativeMethods.cairo_xcb_surface_create_for_bitmap (connection, bitmap, screen, width, height);
return new XcbSurface (ptr, true);
}
-
- public void SetSize (int width, int height)
- {
+ public override void SetSize (int width, int height)
+ {
NativeMethods.cairo_xcb_surface_set_size (Handle, width, height);
+ Console.WriteLine ("new size ({0},{1})", width, height);
}
}
}
/// load the image for rendering from the stream given as argument
/// </summary>
/// <param name="stream">picture stream</param>
- public abstract void Load(Interface iface, string path);
+ //public abstract void Load(Interface iface, string path);
#endregion
/// <summary>
/// </summary>
/// <param name="path">image path, may be embedded</param>
public SvgPicture (string path) : base(path)
- {}
+ {
+ Load ();
+ }
#endregion
- public override void Load (Interface iface, string path)
- {
- Path = path;
- if (sharedResources.ContainsKey (path)) {
- sharedPicture sp = sharedResources [path];
+ void Load ()
+ {
+ if (sharedResources.ContainsKey (Path)) {
+ sharedPicture sp = sharedResources [Path];
hSVG = (Rsvg.Handle)sp.Data;
Dimensions = sp.Dims;
return;
}
- using (Stream stream = iface.GetStreamFromPath (path)) {
+ using (Stream stream = Interface.StaticGetStreamFromPath (Path)) {
using (MemoryStream ms = new MemoryStream ()) {
stream.CopyTo (ms);
Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
}
}
- sharedResources [path] = new sharedPicture (hSVG, Dimensions);
+ sharedResources [Path] = new sharedPicture (hSVG, Dimensions);
}
public void LoadSvgFragment (string fragment) {
--- /dev/null
+//
+// DbgEventTypeColors.cs
+//
+// 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.
+using System;
+using Cairo;
+using System.Linq;
+
+namespace Crow
+{
+ #if DEBUG_LOG
+ public class DbgEventTypeColors : GraphicObject
+ {
+ protected override void onDraw (Context gr)
+ {
+ base.onDraw (gr);
+
+ gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+ gr.SetFontSize (Font.Size);
+ gr.FontOptions = Interface.FontRenderingOptions;
+ gr.Antialias = Interface.Antialias;
+
+ DbgEvtType[] types = DbgLogViewer.colors.Keys.ToArray ();
+ Color[] colors = DbgLogViewer.colors.Values.ToArray ();
+
+ Rectangle r = ClientRectangle;
+ FontExtents fe = gr.FontExtents;
+
+ double penY = fe.Height + r.Top;
+ double penX = (double)r.Left;
+
+
+ for (int i = 0; i < types.Length; i++) {
+ string n = types [i].ToString();
+ Color c = colors[i];
+ Foreground.SetAsSource (gr);
+
+ gr.MoveTo (penX + 25.0, penY - fe.Descent);
+ gr.ShowText (n);
+
+ Rectangle rc = new Rectangle((int)penX, (int)(penY - fe.Height), 20, (int)fe.Height);
+ rc.Inflate (-2);
+ gr.Rectangle (rc);
+ gr.StrokePreserve ();
+
+ gr.SetSourceColor (c);
+ gr.Fill ();
+
+ penY += fe.Height;
+
+ }
+ }
+ }
+ #endif
+}
+
{
public class DbgLogViewer : ScrollingObject
{
+ public static Dictionary<DbgEvtType,Color> colors;
+
+ public static Configuration colorsConf = new Configuration("dbgcolor.conf");
+
#region debug viewer private classes
- class DbgData {
+ public class DbgData {
public int objInstanceNum;
public LayoutingType layout;
public LayoutingQueueItem.Result result;
objInstanceNum = _obj;
}
}
- class DbgEvent {
+ public class DbgEvent {
public long begin, end;
public DbgEvtType type;
public DbgData data = null;
}
#endregion
+ public static void reloadColors () {
+ colors = new Dictionary<DbgEvtType, Color>();
+ foreach (string n in colorsConf.Names) {
+ DbgEvtType t = (DbgEvtType)Enum.Parse (typeof(DbgEvtType), n);
+ Color c = colorsConf.Get<Color> (n);
+ colors.Add (t, c);
+ }
+
+ }
#region CTOR
+ static DbgLogViewer() {
+ reloadColors ();
+ }
protected DbgLogViewer () : base(){}
public DbgLogViewer (Interface iface) : base(iface){}
#endregion
void storeEvent (DbgEvent evt) {
if (evt.data == null)//global events
events.Add (evt);
- else
- objs.Where (o => o.instanceNum == evt.data.objInstanceNum).FirstOrDefault ().events.Add (evt);
+ else {
+ DbgGo go = objs.Where (o => o.instanceNum == evt.data.objInstanceNum).FirstOrDefault ();
+ if (go == null)
+ Console.WriteLine ("Unknown instance: " + evt.data.objInstanceNum);
+ else
+ go.events.Add (evt);
+ }
}
void loadDebugFile() {
}
}
- Crow.Color getObjEventColor (DbgEvent evt) {
- if (evt.type.HasFlag (DbgEvtType.GOLayouting)) {
- if (evt.type == DbgEvtType.GOProcessLayouting) {
- switch (evt.data.result) {
- case LayoutingQueueItem.Result.Success:
- return Crow.Color.Green;
- case LayoutingQueueItem.Result.Deleted:
- return Crow.Color.Red;
- case LayoutingQueueItem.Result.Discarded:
- return Crow.Color.DarkRed;
- case LayoutingQueueItem.Result.Requeued:
- return Crow.Color.Orange;
- }
- } else if (evt.type == DbgEvtType.GOProcessLayoutingWithNoParent)
- return Color.IndianRed;
- else
- return Crow.Color.Blue;
- }
- switch (evt.type) {
- case DbgEvtType.GOClassCreation:
- return Color.GhostWhite;
- case DbgEvtType.GOInitialization:
- return Color.Cyan;
- case DbgEvtType.GOClippingRegistration:
- return Color.Cyan;
- case DbgEvtType.GORegisterClip:
- return Color.Cyan;
- case DbgEvtType.GORegisterForGraphicUpdate:
- return Color.Cyan;
- case DbgEvtType.GOEnqueueForRepaint:
- return Color.Cyan;
- case DbgEvtType.GODraw:
- return Color.Cyan;
- case DbgEvtType.GORecreateCache:
- return Color.Cyan;
- case DbgEvtType.GOUpdateCacheAndPaintOnCTX:
- return Color.Cyan;
- case DbgEvtType.GOPaint:
- return Color.Cyan;
- case DbgEvtType.GONewDataSource:
- return Color.Cyan;
- }
- return Crow.Color.RebeccaPurple;
- }
+
protected override void onDraw (Cairo.Context gr)
{
gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
gr.SetFontSize (Font.Size);
gr.FontOptions = Interface.FontRenderingOptions;
- gr.Antialias = Interface.Antialias;
+ gr.Antialias = Cairo.Antialias.None;
if (objs == null)
return;
double penY = topMargin + ClientRectangle.Top;
for (int i = 0; i < visibleLines; i++) {
+ if (i + ScrollY >= objs.Count)
+ break;
DbgGo g = objs [i + ScrollY];
+
foreach (DbgEvent evt in g.events) {
+
+
if (evt.end - minTicks <= ScrollX)
continue;
if (evt.begin - minTicks > ScrollX + visibleTicks)
break;
+
double x = xScale * (evt.begin - minTicks - ScrollX) ;
double w = Math.Max (Math.Max(2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale);
if (x < 0.0) {
//if (x + w > cb.Right)
// continue;
- gr.SetSourceColor (getObjEventColor (evt));
+ Color c = Color.Black;
+
+ if (evt.type == DbgEvtType.GOProcessLayouting) {
+ switch (evt.data.result) {
+ case LayoutingQueueItem.Result.Success:
+ c = Crow.Color.Green;
+ break;
+ case LayoutingQueueItem.Result.Deleted:
+ c = Crow.Color.Red;
+ break;
+ case LayoutingQueueItem.Result.Discarded:
+ c = Crow.Color.OrangeRed;
+ break;
+ case LayoutingQueueItem.Result.Requeued:
+ c = Crow.Color.Orange;
+ break;
+ }
+ } else if (colors.ContainsKey (evt.type))
+ c = colors [evt.type];
+ else
+ System.Diagnostics.Debugger.Break ();
+
+ gr.SetSourceColor (c);
gr.Rectangle (x, penY, w, fe.Height);
gr.Fill ();
-
}
penY += fe.Height;
gr.MoveTo (x- 0.5 * te.Width, penY - gr.FontExtents.Descent);
gr.SetSourceColor (Crow.Color.Jet);
gr.ShowText (s);
+
}
+
}
public override void Paint (ref Cairo.Context ctx)
{
if (selStart >= 0 && IFace.Mouse.IsButtonDown(MouseButton.Left))
selEnd = currentTick;
- RegisterForRedraw ();
+ if (RegisteredLayoutings == LayoutingType.None && !IsDirty)
+ IFace.EnqueueForRepaint (this);
+
}
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
GOUpdateCacheAndPaintOnCTX = 0x020c,
GOPaint = 0x020d,
GONewDataSource = 0x020e,
+ GOLock = 0x0800,
+ GOLockUpdate = 0x0a01,
+ GOLockClipping = 0x0a02,
+ GOLockRender = 0x0a03,
+ GOLockLayouting = 0x0a04,
}
/// <summary>
s.WriteLine ("[Events]");
foreach (DbgEvent e in events)
- s.WriteLine (e.ToString ());
+ if (e != null)
+ s.WriteLine (e.ToString ());
}
}
}