<Compile Include="src\GraphicObjects\RadioButton.cs" />\r
<Compile Include="src\GraphicObjects\Expandable.cs" />\r
<Compile Include="src\GraphicObjects\PrivateContainer.cs" />\r
+ <Compile Include="src\GraphicObjects\TemplatedContainer.cs" />\r
+ <Compile Include="src\GraphicObjects\Popper.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
<EmbeddedResource Include="Templates\Expandable.goml" />\r
<EmbeddedResource Include="Images\Icons\expandable.svg" />\r
<EmbeddedResource Include="Templates\Checkbox2.goml" />\r
+ <EmbeddedResource Include="Templates\Popper.goml" />\r
</ItemGroup>\r
</Project>\r
- Monodevelop addin
- improve inline delegates to handle all conversion and graphic tree parsing with directory navigation syntax
- Make an easyly compilable example of complete application (3d mesh editor for example)
+ - inlined SVG with binding and c# scripting for animation
+ - simplified Image subElement.
--- /dev/null
+<?xml version="1.0"?>\r
+<Border BorderWidth="1" BorderColor="LightGray" Height="50" Width="100" MouseClick="onMouseClick">\r
+ <HorizontalStack Name="hsTemplateExpander" Spacing="1" Focusable="false" Height="-1" Width="0">\r
+ <Image Name="Image" Margin="3" Width="16" Height="16" Path="#go.Images.Icons.expandable.svg"/>\r
+ <Label Name="Caption"/>\r
+ </HorizontalStack>\r
+</Border>
\ No newline at end of file
fps = (int)RenderFrequency;\r
\r
//labFps.Text = fps.ToString();\r
- labUpdate.Text = this.updateTime.ElapsedMilliseconds.ToString() + " ms";\r
+ //labUpdate.Text = this.updateTime.ElapsedMilliseconds.ToString() + " ms";\r
\r
if (frameCpt > 200) {\r
// labFpsMin.Text = fpsMin.ToString();\r
<?xml version="1.0"?>\r
<Container Name="MainGrp"\r
- HorizontalAlignment="Right" VerticalAlignment="Bottom"\r
+ \r
Margin="10" Focusable="True" Fit="True">\r
-\r
- <VerticalStack Fit="True" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
- <HorizontalStack>\r
+ <Expandable Width="150" Background="Green" Margin="2">\r
+<!-- HorizontalAlignment="Right" VerticalAlignment="Bottom"-->\r
+<!-- <VerticalStack Fit="True" BorderWidth="1" Margin="5" WidgetSpacing="4">-->\r
+<!-- <HorizontalStack>\r
<Label Text="Update:" FontColor="White" VerticalAlignment="Center" />\r
<Label Name="labUpdate" Text="xxxx" FontSize="12" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
- </HorizontalStack>\r
+ </HorizontalStack>-->\r
<HorizontalStack>\r
<Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>\r
<Label Name="labFps" Text="{fps}" Font="droid bold, 12"\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
- <HorizontalStack>\r
+<!-- <HorizontalStack>\r
<Label Text="Min:" Width = "30" />\r
<Label Name="labFpsMin" Text="{fpsMin}" Font="droid bold, 12"\r
TextAlignment="Center" Background="AoEnglish"/>\r
<Label Text="Max:" Width = "30"/>\r
<Label Name="labFpsMax" Text="{fpsMax}" Font="droid bold, 12"\r
TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- </VerticalStack> \r
+ </HorizontalStack>-->\r
+<!-- </VerticalStack>-->\r
+ </Expandable>\r
</Container>
\ No newline at end of file
</GroupBox>\r
<Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
<GraduatedSlider Name="slider" Height="30" Width="300" Foreground="BlueBell"/>\r
- \r
</VerticalStack>\r
<VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
<Button Margin="1" Width="150" Height="100">\r
- <Image Path="#Tests.image.tetra.png"/>\r
+ <Image Path="#Tests.image.tetra.png"/>\r
</Button>\r
+ <Popper>\r
+ <Image Fit="true" Path="#Tests.image.tetra.png"/>\r
+ </Popper>\r
+ <HorizontalStack>\r
+ <Label Text="Update" FontColor="White"/>\r
+ <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Fps:" Width = "30"/>\r
+ <Label Name="labFps" Text="{fps}" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Min:" Width = "30"/>\r
+ <Label Name="labFpsMin" Text="{fpsMin}" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Max:" Width = "30"/>\r
+ <Label Name="labFpsMax" Text="{fpsMax}" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
<Expandable Name="expander" Width="150" Height="-1">\r
<VerticalStack Name="vsExpanded" Width="100">\r
<Checkbox Name="chk1"/>\r
<Checkbox Name="chk2"/>\r
</VerticalStack> \r
</Expandable>\r
-\r
- <HorizontalStack>\r
- <Label Text="Update" FontColor="White"/>\r
- <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Fps:" Width = "30"/>\r
- <Label Name="labFps" Text="{fps}" Font="droid bold, 14"\r
- TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Min:" Width = "30"/>\r
- <Label Name="labFpsMin" Text="{fpsMin}" Font="droid bold, 14"\r
- TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Max:" Width = "30"/>\r
- <Label Name="labFpsMax" Text="{fpsMax}" Font="droid bold, 14"\r
- TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
</VerticalStack>\r
\r
<Scroller Background="DimGray" Height="350" Width="150" \r
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_4</StartupObject>
+ <StartupObject>test.GOLIBTest_fps</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
namespace go\r
{\r
[DefaultTemplate("#go.Templates.Expandable.goml")]\r
- public class Expandable : TemplatedControl\r
+ public class Expandable : TemplatedContainer\r
{ \r
bool _isExpanded;\r
Label _caption;\r
Image _image;\r
-\r
- public Container Content;\r
+ Container _contentContainer;\r
\r
public event EventHandler Expand;\r
public event EventHandler Collapse;\r
\r
+ public override GraphicObject Content {\r
+ get {\r
+ return _contentContainer == null ? null : _contentContainer.Child;\r
+ }\r
+ set {\r
+ _contentContainer.SetChild(value);\r
+ }\r
+ }\r
+\r
public Expandable() : base()\r
{\r
} \r
{\r
base.loadTemplate (template);\r
\r
+ _contentContainer = this.child.FindByName ("Content") as Container;\r
_caption = this.child.FindByName ("Caption") as Label;\r
- Content = this.child.FindByName ("Content") as Container;\r
_image = this.child.FindByName ("Image") as Image;\r
\r
if (_image == null)\r
\r
public virtual void onExpand(object sender, EventArgs e)\r
{\r
- Content.Visible = true;\r
+ _contentContainer.Visible = true;\r
Expand.Raise (this, e);\r
}\r
public virtual void onCollapse(object sender, EventArgs e)\r
{\r
- Content.Visible = false;\r
+ _contentContainer.Visible = false;\r
Collapse.Raise (this, e);\r
}\r
\r
base.onMouseClick (sender, e);\r
}\r
\r
- public override void ReadXml(System.Xml.XmlReader reader)\r
- {\r
- using (System.Xml.XmlReader subTree = reader.ReadSubtree ()) {\r
- subTree.Read ();\r
- string tmp = subTree.ReadOuterXml ();\r
-\r
- //seek for template tag\r
- using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {\r
- xr.Read ();\r
- base.ReadXml (xr); \r
- }\r
- //process content\r
- using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {\r
- xr.Read (); //skip current node\r
-\r
- while (!xr.EOF) {\r
- xr.Read (); //read first child\r
-\r
- if (!xr.IsStartElement ())\r
- continue;\r
- if (xr.Name == "Template")\r
- continue;\r
-\r
- Type t = Type.GetType ("go." + xr.Name);\r
- GraphicObject go = (GraphicObject)Activator.CreateInstance (t); \r
-\r
- (go as IXmlSerializable).ReadXml (xr);\r
-\r
- Content.SetChild (go);\r
-\r
- xr.Read (); //closing tag\r
- }\r
- \r
- }\r
- }\r
- }\r
- public override void WriteXml(System.Xml.XmlWriter writer)\r
- {\r
- base.WriteXml(writer);\r
-\r
- if (Content == null)\r
- return;\r
- if (Content.Child == null)\r
- return;\r
- //TODO: if template is not the default one, we have to save it\r
- writer.WriteStartElement(Content.Child.GetType().Name);\r
- (Content.Child as IXmlSerializable).WriteXml(writer);\r
- writer.WriteEndElement();\r
- }\r
}\r
}\r
}\r
} \r
ComputeChildrenPositions ();\r
+ //if no layouting remains in queue for item, registre for redraw\r
+ if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0)\r
+ this.RegisterForRedraw ();\r
}else\r
base.UpdateLayout(layoutType);\r
}\r
--- /dev/null
+using System;\r
+\r
+\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+//using OpenTK.Graphics.OpenGL;\r
+\r
+using Cairo;\r
+\r
+using winColors = System.Drawing.Color;\r
+using System.Diagnostics;\r
+using System.Xml.Serialization;\r
+using OpenTK.Input;\r
+using System.ComponentModel;\r
+using System.Xml;\r
+using System.IO;\r
+\r
+namespace go\r
+{\r
+ [DefaultTemplate("#go.Templates.Popper.goml")]\r
+ public class Popper : TemplatedContainer\r
+ { \r
+ bool _isPopped;\r
+ Label _caption;\r
+ Image _image;\r
+ GraphicObject _content;\r
+\r
+ public event EventHandler Pop;\r
+ public event EventHandler Unpop;\r
+\r
+ public override GraphicObject Content {\r
+ get { return _content; }\r
+ set { _content = value; }\r
+ }\r
+ public Popper() : base()\r
+ {\r
+ } \r
+\r
+ protected override void loadTemplate(GraphicObject template = null)\r
+ {\r
+ base.loadTemplate (template);\r
+\r
+ _caption = this.child.FindByName ("Caption") as Label;\r
+ _image = this.child.FindByName ("Image") as Image;\r
+\r
+ if (_image == null)\r
+ return;\r
+ _image.SvgSub = "collapsed";\r
+\r
+ this.Pop += (object sender, EventArgs e) => {_image.SvgSub = "expanded";};\r
+ this.Unpop += (object sender, EventArgs e) => {_image.SvgSub = "collapsed";};\r
+\r
+ }\r
+ \r
+\r
+ [XmlAttributeAttribute()][DefaultValue("Popper")]\r
+ public string Title {\r
+ get { return _caption.Text; } \r
+ set {\r
+ if (_caption == null)\r
+ return;\r
+ _caption.Text = value; \r
+ }\r
+ } \r
+ \r
+ [XmlAttributeAttribute()][DefaultValue(false)]\r
+ public bool IsPopped\r
+ {\r
+ get { return _isPopped; }\r
+ set\r
+ {\r
+ if (value == _isPopped)\r
+ return;\r
+\r
+ _isPopped = value;\r
+\r
+ if (_isPopped)\r
+ onPop (this, null);\r
+ else\r
+ onUnpop (this, null);\r
+\r
+ registerForGraphicUpdate();\r
+ }\r
+ }\r
+\r
+ public virtual void onPop(object sender, EventArgs e)\r
+ {\r
+ if (Content != null) {\r
+ Rectangle r = this.ScreenCoordinates (this.Slot);\r
+ Content.Visible = true;\r
+ Content.Left = r.Left;\r
+ Content.Top = r.Bottom;\r
+ TopContainer.AddWidget (Content);\r
+ }\r
+ Pop.Raise (this, e);\r
+ }\r
+ public virtual void onUnpop(object sender, EventArgs e)\r
+ {\r
+ TopContainer.DeleteWidget (Content);\r
+ Unpop.Raise (this, e);\r
+ }\r
+ \r
+ public override void onMouseClick (object sender, MouseButtonEventArgs e)\r
+ {\r
+ IsPopped = !IsPopped;\r
+ base.onMouseClick (sender, e);\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+//
+// TemplatedContainer.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2015 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace go
+{
+ public abstract class TemplatedContainer : TemplatedControl
+ {
+ [XmlIgnore]
+ public abstract GraphicObject Content{ get; set;}
+
+ protected override void loadTemplate (GraphicObject template)
+ {
+ base.loadTemplate (template);
+ }
+ public TemplatedContainer () : base()
+ {
+ }
+ public override GraphicObject FindByName (string nameToFind)
+ {
+ if (Name == nameToFind)
+ return this;
+
+ return Content == null ? null : Content.FindByName (nameToFind);
+ }
+ public override void ReadXml(System.Xml.XmlReader reader)
+ {
+ using (System.Xml.XmlReader subTree = reader.ReadSubtree ()) {
+ subTree.Read ();
+ string tmp = subTree.ReadOuterXml ();
+
+ //seek for template tag
+ using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
+ xr.Read ();
+ base.ReadXml (xr);
+ }
+ //process content
+ using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
+ xr.Read (); //skip current node
+
+ while (!xr.EOF) {
+ xr.Read (); //read first child
+
+ if (!xr.IsStartElement ())
+ continue;
+ if (xr.Name == "Template")
+ continue;
+
+ Type t = Type.GetType ("go." + xr.Name);
+ GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
+
+ (go as IXmlSerializable).ReadXml (xr);
+
+ Content = go;
+
+ xr.Read (); //closing tag
+ }
+
+ }
+ }
+ }
+ public override void WriteXml(System.Xml.XmlWriter writer)
+ {
+ base.WriteXml(writer);
+
+ if (Content == null)
+ return;
+ //TODO: if template is not the default one, we have to save it
+ writer.WriteStartElement(Content.GetType().Name);
+ (Content as IXmlSerializable).WriteXml(writer);
+ writer.WriteEndElement();
+ }
+ }
+}
+
public void AddWidget(GraphicObject g)\r
{\r
g.Parent = this;\r
- GraphicObjects.Add (g);\r
+ GraphicObjects.Insert (0, g);\r
\r
g.RegisterForLayouting ((int)LayoutingType.Sizing);\r
}\r
lock (redrawClip) {\r
if (redrawClip.count > 0) { \r
// #if DEBUG_CLIP_RECTANGLE\r
-// redrawClip.stroke (ctx, new Color(1.0,0,0,0.3));\r
+ redrawClip.stroke (ctx, new Color(1.0,0,0,0.3));\r
// #endif\r
redrawClip.clearAndClip (ctx);//rajouté après, tester si utile \r
\r