aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-09-13 14:44:26 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-09-13 14:44:26 +0200
commit2616e6ee7a1a34036cc002d28543d0d7a657fdb2 (patch)
treee48dacb4209e95cb963de76cb6fe1ffca07e77c1 /src/GraphicObjects
parentb7786bbd327699b0a8dd30d5ca86fc20f28f5617 (diff)
Merge improvements from CrowIDE
modifié : Templates/DirectoryView.template modifié : Templates/Menu.template modifié : Templates/MenuItem.template modifié : Templates/Window.template modifié : Tests/Interfaces/Divers/0.crow modifié : src/CompilerServices/CompilerServices.cs modifié : src/ExtensionsMethods.cs modifié : src/GraphicObjects/DirectoryView.cs modifié : src/GraphicObjects/GraphicObject.cs modifié : src/GraphicObjects/Group.cs modifié : src/GraphicObjects/TreeView.cs modifié : src/GraphicObjects/Wrapper.cs modifié : src/IMLReader.cs modifié : src/Interface.cs modifié : src/ItemTemplate.cs modifié : src/LayoutingQueueItem.cs modifié : src/Measure.cs modifié : src/Point.cs
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/DirectoryView.cs36
-rw-r--r--src/GraphicObjects/GraphicObject.cs87
-rw-r--r--src/GraphicObjects/Group.cs16
-rw-r--r--src/GraphicObjects/TreeView.cs2
-rw-r--r--src/GraphicObjects/Wrapper.cs4
5 files changed, 83 insertions, 62 deletions
diff --git a/src/GraphicObjects/DirectoryView.cs b/src/GraphicObjects/DirectoryView.cs
index 586b1b26..4e29621e 100644
--- a/src/GraphicObjects/DirectoryView.cs
+++ b/src/GraphicObjects/DirectoryView.cs
@@ -37,8 +37,8 @@ namespace Crow
public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
#endregion
- string _root = "/";
- bool _showFiles;
+ string currentDirectory = "/";
+ bool showFiles;
object _selectedItem;
[XmlIgnore]public object SelectedItem {
@@ -52,31 +52,37 @@ namespace Crow
NotifyValueChanged ("SelectedItem", _selectedItem);
}
}
- [XmlAttributeAttribute()][DefaultValue(true)]
+ [XmlAttributeAttribute()][DefaultValue(false)]
public virtual bool ShowFiles {
- get { return _showFiles; }
+ get { return showFiles; }
set {
- if (_showFiles == value)
+ if (showFiles == value)
return;
- _showFiles = value;
- NotifyValueChanged ("ShowFiles", _showFiles);
+ showFiles = value;
+ NotifyValueChanged ("ShowFiles", showFiles);
+ NotifyValueChanged ("FileSystemEntries", FileSystemEntries);
}
}
[XmlAttributeAttribute][DefaultValue("/")]
- public virtual string Root {
- get { return _root; }
+ public virtual string CurrentDirectory {
+ get { return currentDirectory; }
set {
- if (_root == value)
+ if (currentDirectory == value)
return;
- _root = value;
- NotifyValueChanged ("Root", _root);
- NotifyValueChanged ("CurrentDirectory", CurrentDirectory);
+ currentDirectory = value;
+ NotifyValueChanged ("CurrentDirectory", currentDirectory);
+ NotifyValueChanged ("FileSystemEntries", FileSystemEntries);
}
}
- [XmlIgnore]public FileSystemInfo[] CurrentDirectory {
- get { return new DirectoryInfo (Root).GetFileSystemInfos (); }
+ [XmlIgnore]public FileSystemInfo[] FileSystemEntries {
+ get {
+ return showFiles ? new DirectoryInfo (CurrentDirectory).GetFileSystemInfos ():
+ new DirectoryInfo(currentDirectory).GetDirectories();
+ }
}
public void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
+ if (e.NewValue == SelectedItem)
+ return;
SelectedItem = e.NewValue;
SelectedItemChanged.Raise (this, e);
}
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 6572ba52..093664d1 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -54,8 +54,10 @@ namespace Crow
#region CTOR
public GraphicObject ()
{
+ #if DEBUG
uid = currentUid;
currentUid++;
+ #endif
}
#endregion
internal protected virtual void initialize(){
@@ -65,7 +67,7 @@ namespace Crow
LayoutingType registeredLayoutings = LayoutingType.All;
ILayoutable logicalParent;
ILayoutable parent;
- string name = "unamed";
+ string name;
Fill background = Color.Transparent;
Fill foreground = Color.White;
Font font = "droid, 10";
@@ -199,14 +201,20 @@ namespace Crow
this.RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue("unamed")]
+ [XmlAttributeAttribute()][DefaultValue(null)]
public virtual string Name {
- get { return name; }
+ get {
+ #if DEBUG
+ return string.IsNullOrEmpty(name) ? this.GetType().Name + uid.ToString () : name;
+ #else
+ return name;
+ #endif
+ }
set {
if (name == value)
return;
name = value;
- NotifyValueChanged("Name", verticalAlignment);
+ NotifyValueChanged("Name", name);
}
}
[XmlAttributeAttribute ()][DefaultValue(VerticalAlignment.Center)]
@@ -333,15 +341,13 @@ namespace Crow
/// Fit or Stretched
/// </summary>
[XmlIgnore]public virtual Measure WidthPolicy { get {
- return Width.Units == Unit.Percent || Width.IsFixed ?
- Measure.Stretched : Measure.Fit; } }
+ return Width.IsFit ? Measure.Fit : Measure.Stretched; } }
/// <summary>
/// Used for binding on dimensions, this property will never hold fixed size, but instead only
/// Fit or Stretched
/// </summary>
[XmlIgnore]public virtual Measure HeightPolicy { get {
- return Height.Units == Unit.Percent || Height.IsFixed ?
- Measure.Stretched : Measure.Fit; } }
+ return Height.IsFit ? Measure.Fit : Measure.Stretched; } }
[XmlAttributeAttribute()][DefaultValue(false)]
public virtual bool Focusable {
get { return focusable; }
@@ -450,14 +456,17 @@ namespace Crow
if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
CurrentInterface.HoverWidget = null;
- if (Parent is GraphicObject)
- (Parent as GraphicObject).RegisterForLayouting (LayoutingType.Sizing);
- if (Parent is GenericStack)
- (Parent as GraphicObject).RegisterForLayouting (LayoutingType.ArrangeChildren);
-
if (isVisible)
RegisterForLayouting (LayoutingType.Sizing);
- CurrentInterface.EnqueueForRepaint (this);
+ else {
+ Slot.Width = 0;
+ LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Width));
+ Slot.Height = 0;
+ LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Height));
+ CurrentInterface.EnqueueForRepaint (this);
+ LastSlots.Width = LastSlots.Height = 0;
+ }
+
NotifyValueChanged ("Visible", isVisible);
}
@@ -720,7 +729,7 @@ namespace Crow
public void RegisterForGraphicUpdate ()
{
bmp = null;
- if (Width == Measure.Fit || Height == Measure.Fit)
+ if (Width.IsFit || Height.IsFit)
RegisterForLayouting (LayoutingType.Sizing);
else if (RegisteredLayoutings == LayoutingType.None)
CurrentInterface.EnqueueForRepaint (this);
@@ -737,10 +746,6 @@ namespace Crow
#region Layouting
- #if DEBUG_LAYOUTING
- public List<LayoutingQueueItem> CurrentDrawLQIs = null;
- public List<List<LayoutingQueueItem>> LQIs = new List<List<LayoutingQueueItem>>();
- #endif
/// <summary> return size of content + margins </summary>
protected virtual int measureRawSize (LayoutingType lt) {
return lt == LayoutingType.Width ?
@@ -754,6 +759,11 @@ namespace Crow
if (Parent == null)
return;
lock (CurrentInterface.LayoutMutex) {
+ //prevent queueing same LayoutingType for this
+ layoutType &= (~RegisteredLayoutings);
+
+ if (layoutType == LayoutingType.None)
+ return;
//dont set position for stretched item
if (Width == Measure.Stretched)
layoutType &= (~LayoutingType.X);
@@ -767,8 +777,8 @@ namespace Crow
if (Parent is GraphicObject)
(Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
- //prevent queueing same LayoutingType for this
- layoutType &= (~RegisteredLayoutings);
+// //prevent queueing same LayoutingType for this
+// layoutType &= (~RegisteredLayoutings);
if (layoutType == LayoutingType.None)
return;
@@ -791,8 +801,8 @@ namespace Crow
public virtual void OnLayoutChanges(LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- LayoutingQueueItem.currentLQI.Slot = LastSlots;
- LayoutingQueueItem.currentLQI.Slot = Slot;
+ CurrentInterface.currentLQI.Slot = LastSlots;
+ CurrentInterface.currentLQI.NewSlot = Slot;
#endif
switch (layoutType) {
@@ -1020,12 +1030,6 @@ namespace Crow
return;
LastPaintedSlot = Slot;
- #if DEBUG_LAYOUTING
- if (CurrentDrawLQIs != null){
- LQIs.Add (CurrentDrawLQIs);
- CurrentDrawLQIs = null;
- }
- #endif
if (cacheEnabled) {
if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
@@ -1200,18 +1204,6 @@ namespace Crow
public virtual void onDisable(object sender, EventArgs e){
Disabled.Raise (this, e);
}
- public override string ToString ()
- {
- string tmp ="";
-
- if (Parent != null)
- tmp = Parent.ToString () + tmp;
- #if DEBUG_LAYOUTING
- return Name == "unamed" ? tmp + "." + this.GetType ().Name + uid.ToString(): tmp + "." + Name;
- #else
- return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
- #endif
- }
#region Binding
public void BindMember(string _member, string _expression){
@@ -1489,5 +1481,18 @@ namespace Crow
tmp.Bindings.Add (new Binding (new MemberReference (tmp, b.Source.Member), b.Expression));
return tmp;
}
+
+ public override string ToString ()
+ {
+ string tmp ="";
+
+ if (Parent != null)
+ tmp = Parent.ToString () + tmp;
+ #if DEBUG_LAYOUTING
+ return Name == "unamed" ? tmp + "." + this.GetType ().Name + uid.ToString(): tmp + "." + Name;
+ #else
+ return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
+ #endif
+ }
}
}
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 402128b0..efe02d95 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -153,12 +153,20 @@ namespace Crow
//position smaller objects in group when group size is fit
switch (layoutType) {
case LayoutingType.Width:
- foreach (GraphicObject c in Children)
- c.RegisterForLayouting (LayoutingType.X | LayoutingType.Width);
+ foreach (GraphicObject c in Children){
+ if (c.Width.Units == Unit.Percent)
+ c.RegisterForLayouting (LayoutingType.Width);
+ else
+ c.RegisterForLayouting (LayoutingType.X);
+ }
break;
case LayoutingType.Height:
- foreach (GraphicObject c in Children)
- c.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height);
+ foreach (GraphicObject c in Children) {
+ if (c.Height.Units == Unit.Percent)
+ c.RegisterForLayouting (LayoutingType.Height);
+ else
+ c.RegisterForLayouting (LayoutingType.Y);
+ }
break;
}
}
diff --git a/src/GraphicObjects/TreeView.cs b/src/GraphicObjects/TreeView.cs
index b9ab20b6..4fa881b4 100644
--- a/src/GraphicObjects/TreeView.cs
+++ b/src/GraphicObjects/TreeView.cs
@@ -72,6 +72,8 @@ namespace Crow
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;
diff --git a/src/GraphicObjects/Wrapper.cs b/src/GraphicObjects/Wrapper.cs
index 03251af9..1bfcd92a 100644
--- a/src/GraphicObjects/Wrapper.cs
+++ b/src/GraphicObjects/Wrapper.cs
@@ -191,8 +191,8 @@ namespace Crow
public override void OnLayoutChanges (LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- LayoutingQueueItem.currentLQI.Slot = LastSlots;
- LayoutingQueueItem.currentLQI.Slot = Slot;
+ CurrentInterface.currentLQI.Slot = LastSlots;
+ CurrentInterface.currentLQI.Slot = Slot;
#endif
switch (layoutType) {