aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-08-12 03:37:29 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-08-12 03:37:29 +0200
commit80ceca9f199f37928f8c3068d07732b77d45156f (patch)
tree23cc31124f141dfc7919581d8cfab381a4ebc977 /src/GraphicObjects
parent2b62c4b6eefdeaf3ddb4247b6241e87ee2345a6a (diff)
* Crow.csproj, Default.style, button.svg, buttest.svg, buttest2.svg, buttest4.svg, 0.crow:
test and divers * DirectoryView.cs: SelectedItem property * GraphicObject.cs: Style class, EventInfo in styles * Group.cs: lock children * Popper.cs: alignment = top left, simple unpop on mouse leave, no additional tests * Spinner.cs: ctor order * TabView.cs: code clean * Window.cs: movable * Style.cs, Interface.cs: Style class * StyleReader.cs: parser exception, debug expression parsing * Button.crow, Popper.goml, TabItem.crow, CheckBox.goml, Expandable.goml, MessageBox.goml, RadioButton.goml, ScrollingListBox.goml: templating * TreeView.crow: scrollbar * 1.crow: showcase * test.style, Tests.csproj, CheckBox2.imlt: tests
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/DirectoryView.cs13
-rw-r--r--src/GraphicObjects/GraphicObject.cs26
-rw-r--r--src/GraphicObjects/Group.cs13
-rw-r--r--src/GraphicObjects/Popper.cs10
-rw-r--r--src/GraphicObjects/Spinner.cs8
-rw-r--r--src/GraphicObjects/TabView.cs13
-rw-r--r--src/GraphicObjects/Window.cs14
7 files changed, 67 insertions, 30 deletions
diff --git a/src/GraphicObjects/DirectoryView.cs b/src/GraphicObjects/DirectoryView.cs
index e9a9ef9b..ac53ee8b 100644
--- a/src/GraphicObjects/DirectoryView.cs
+++ b/src/GraphicObjects/DirectoryView.cs
@@ -41,6 +41,18 @@ namespace Crow
string _root = "/";
bool _showFiles;
+ object _selectedItem;
+ [XmlIgnore]public object SelectedItem {
+ get {
+ return _selectedItem;
+ }
+ set {
+ if (value == _selectedItem)
+ return;
+ _selectedItem = value;
+ NotifyValueChanged ("SelectedItem", _selectedItem);
+ }
+ }
[XmlAttributeAttribute()][DefaultValue(true)]
public virtual bool ShowFiles {
get { return _showFiles; }
@@ -66,6 +78,7 @@ namespace Crow
get { return new DirectoryInfo (Root).GetFileSystemInfos (); }
}
public void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
+ SelectedItem = e.NewValue;
SelectedItemChanged.Raise (this, e);
}
}
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 88166fe6..925f69df 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -538,7 +538,7 @@ namespace Crow
}
}
- List<Dictionary<string, object>> styling = new List<Dictionary<string, object>>();
+ List<Style> styling = new List<Style>();
//Search for a style mathing :
//1: Full class name, with full namespace
@@ -587,7 +587,14 @@ namespace Crow
il.Emit (OpCodes.Ldarg_0);
il.Emit (OpCodes.Stloc_0);
- foreach (PropertyInfo pi in thisType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
+ foreach (EventInfo ei in thisType.GetEvents(BindingFlags.Public | BindingFlags.Instance)) {
+ string expression;
+ if (!getDefaultEvent(ei, styling, out expression))
+ continue;
+ CompilerServices.emitBindingCreation (il, ei.Name, expression);
+ }
+
+ foreach (PropertyInfo pi in thisType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
if (pi.GetSetMethod () == null)
continue;
object defaultValue;
@@ -606,7 +613,20 @@ namespace Crow
throw new Exception ("Error applying style <" + styleKey + ">:", ex);
}
}
- bool getDefaultValue(PropertyInfo pi, List<Dictionary<string, object>> styling,
+ bool getDefaultEvent(EventInfo ei, List<Style> styling,
+ out string expression){
+ expression = "";
+ if (styling.Count > 0){
+ for (int i = 0; i < styling.Count; i++) {
+ if (styling[i].ContainsKey (ei.Name)){
+ expression = (string)styling[i] [ei.Name];
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ bool getDefaultValue(PropertyInfo pi, List<Style> styling,
out object defaultValue){
defaultValue = null;
string name = "";
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 4c8d0537..e87ca41c 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -39,7 +39,8 @@ namespace Crow
set { _multiSelect = value; }
}
public virtual void AddChild(GraphicObject g){
- Children.Add(g);
+ lock (children)
+ Children.Add(g);
g.Parent = this;
g.ResolveBindings ();
g.RegisteredLayoutings = LayoutingType.None;
@@ -51,7 +52,8 @@ namespace Crow
child.LayoutChanged -= OnChildLayoutChanges;
child.ClearBinding ();
//child.Parent = null;
- Children.Remove(child);
+ lock (children)
+ Children.Remove(child);
if (child == largestChild && Width == Measure.Fit)
searchLargestChild ();
@@ -241,9 +243,10 @@ namespace Crow
//clip to client zone
CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
gr.Clip ();
-
- foreach (GraphicObject g in Children) {
- g.Paint (ref gr);
+ lock (children) {
+ foreach (GraphicObject g in Children) {
+ g.Paint (ref gr);
+ }
}
gr.Restore ();
}
diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs
index 0a013ae1..ea11435a 100644
--- a/src/GraphicObjects/Popper.cs
+++ b/src/GraphicObjects/Popper.cs
@@ -100,6 +100,8 @@ namespace Crow
return;
_content.LogicalParent = this;
+ _content.HorizontalAlignment = HorizontalAlignment.Left;
+ _content.VerticalAlignment = VerticalAlignment.Top;
_content.LayoutChanged += _content_LayoutChanged;
_content.MouseLeave += onMouseLeave;
}
@@ -187,14 +189,6 @@ namespace Crow
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- if (MouseIsIn (e.Position))
- return;
- if (_content == null)
- return;
- try {
- if (_content.MouseIsIn (e.Position))
- return;
- } catch {}
IsPopped = false;
}
#endregion
diff --git a/src/GraphicObjects/Spinner.cs b/src/GraphicObjects/Spinner.cs
index 1a8674d0..0806d4d3 100644
--- a/src/GraphicObjects/Spinner.cs
+++ b/src/GraphicObjects/Spinner.cs
@@ -25,14 +25,16 @@ namespace Crow
[DefaultTemplate("#Crow.Templates.Spinner.goml")]
public class Spinner : NumericControl
{
+ #region CTOR
+ public Spinner () : base()
+ {
+ }
public Spinner (double minimum, double maximum, double step) :
base (minimum, maximum, step)
{
}
- public Spinner () : base()
- {
- }
+ #endregion
void onUp (object sender, MouseButtonEventArgs e)
{
diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs
index 015f5f4f..e140191b 100644
--- a/src/GraphicObjects/TabView.cs
+++ b/src/GraphicObjects/TabView.cs
@@ -39,6 +39,7 @@ namespace Crow
{
}
+ #region public properties
[XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
public virtual Orientation Orientation
{
@@ -54,7 +55,7 @@ namespace Crow
NotifyValueChanged ("TabOrientation", Orientation.Horizontal);
}
}
- [XmlAttributeAttribute()][DefaultValue(2)]
+ [XmlAttributeAttribute()][DefaultValue(20)]
public int Spacing
{
get { return _spacing; }
@@ -81,7 +82,7 @@ namespace Crow
RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue(22)]
+ [XmlAttributeAttribute()][DefaultValue("15")]
public virtual Measure TabThickness {
get { return tabThickness; }
set {
@@ -92,13 +93,7 @@ namespace Crow
RegisterForGraphicUpdate ();
}
}
-
- //prevent caching, because drawing order is different depending on selected tab
- [XmlAttributeAttribute()][DefaultValue(false)]
- public override bool CacheEnabled {
- get {return false;}
- set { }
- }
+ #endregion
public override void AddChild (GraphicObject child)
{
diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs
index cbdbbb2c..be482e43 100644
--- a/src/GraphicObjects/Window.cs
+++ b/src/GraphicObjects/Window.cs
@@ -45,6 +45,7 @@ namespace Crow
string _title;
string _icon;
bool _resizable;
+ bool _movable;
bool hoverBorder = false;
Container _contentContainer;
@@ -100,7 +101,16 @@ namespace Crow
NotifyValueChanged ("Resizable", _resizable);
}
}
-
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public bool Movable {
+ get {
+ return _movable;
+ }
+ set {
+ _movable = value;
+ NotifyValueChanged ("Movable", _movable);
+ }
+ }
#region GraphicObject Overrides
public override void ResolveBindings ()
{
@@ -120,7 +130,7 @@ namespace Crow
return;
}
- if (this.HasFocus) {
+ if (this.HasFocus && _movable) {
if (e.Mouse.IsButtonDown (MouseButton.Left)) {
int currentLeft = this.Left;
int currentTop = this.Top;