Author: fejj
Date: 2007-06-29 14:55:30 -0400 (Fri, 29 Jun 2007)
New Revision: 81063
Modified:
trunk/lunareclipse/Controller/MoonlightController.cs
trunk/lunareclipse/Properties/Properties.cs
trunk/lunareclipse/Properties/PropertyGroup.cs
trunk/lunareclipse/Properties/PropertyGroupAppearance.cs
trunk/lunareclipse/Properties/PropertyGroupLayout.cs
trunk/lunareclipse/View/MainWindow.cs
Log:
made things work
Modified: trunk/lunareclipse/Controller/MoonlightController.cs
===================================================================
--- trunk/lunareclipse/Controller/MoonlightController.cs 2007-06-29
18:48:26 UTC (rev 81062)
+++ trunk/lunareclipse/Controller/MoonlightController.cs 2007-06-29
18:55:30 UTC (rev 81063)
@@ -19,6 +19,7 @@
{
public class MoonlightController
{
+ IPropertyGroup properties;
private UndoEngine undo;
private GtkSilver moonlight;
private DrawBase current;
@@ -40,9 +41,10 @@
get { return undo; }
}
- public MoonlightController(GtkSilver moonlight)
+ public MoonlightController(GtkSilver moonlight, IPropertyGroup
properties)
{
this.moonlight = moonlight;
+ this.properties = properties;
moonlight.Canvas.MouseLeftButtonDown += new
MouseEventHandler(MouseLeftDown);
moonlight.Canvas.MouseMove += new MouseEventHandler(MouseMove);
moonlight.Canvas.MouseLeftButtonUp += new
MouseEventHandler(MouseLeftUp);
@@ -83,6 +85,12 @@
current.DrawEnd(e);
active = false;
+
+ if (current is SelectionDraw) {
+ SelectionDraw selection = (SelectionDraw)
current;
+ if (selection.SelectedObjects.Count == 1)
+ properties.DependencyObject =
selection.SelectedObjects[0];
+ }
}
Modified: trunk/lunareclipse/Properties/Properties.cs
===================================================================
--- trunk/lunareclipse/Properties/Properties.cs 2007-06-29 18:48:26 UTC (rev
81062)
+++ trunk/lunareclipse/Properties/Properties.cs 2007-06-29 18:55:30 UTC (rev
81063)
@@ -27,7 +27,7 @@
{
this.Build ();
- ObjectName.Text = "<No Name>";
+ ObjectName.Text = "<No Object Selected>";
ObjectName.Sensitive = false;
ObjectName.Changed += new EventHandler (OnNameChanged);
ObjectType.Text = "";
@@ -63,7 +63,7 @@
item = value;
if (item != null) {
- ObjectName.Text = item.Name == null ||
item.Name == String.Empty ? "<No Name>" : item.Name;
+ ObjectName.Text = item.Name != null ?
item.Name : "";
ObjectName.Sensitive = true;
ObjectType.Text = item.GetType ().Name;
@@ -77,7 +77,7 @@
}
}
} else {
- ObjectName.Text = "<No Name>";
+ ObjectName.Text = "<No Object
Selected>";
ObjectName.Sensitive = false;
ObjectType.Text = "";
}
@@ -112,15 +112,8 @@
{
Entry entry = (Entry) o;
- if (entry.Text == String.Empty)
- entry.Text = "<No Name>";
-
- if (entry.Text == "<No Name>") {
- entry.SelectRegion (0, -1);
- item.SetValue<string> (nameProp, null);
- } else {
+ if (nameProp != null)
item.SetValue<string> (nameProp, entry.Text);
- }
}
}
}
Modified: trunk/lunareclipse/Properties/PropertyGroup.cs
===================================================================
--- trunk/lunareclipse/Properties/PropertyGroup.cs 2007-06-29 18:48:26 UTC
(rev 81062)
+++ trunk/lunareclipse/Properties/PropertyGroup.cs 2007-06-29 18:55:30 UTC
(rev 81063)
@@ -27,7 +27,7 @@
if (properties != null)
properties.Destroy ();
properties = value;
- Add (value);
+ expander.Add (value);
}
}
Modified: trunk/lunareclipse/Properties/PropertyGroupAppearance.cs
===================================================================
--- trunk/lunareclipse/Properties/PropertyGroupAppearance.cs 2007-06-29
18:48:26 UTC (rev 81062)
+++ trunk/lunareclipse/Properties/PropertyGroupAppearance.cs 2007-06-29
18:55:30 UTC (rev 81063)
@@ -120,65 +120,75 @@
if (field.Name == info[i].Name) {
string propName =
info[i].Name.Substring (0, info[i].Name.Length - 8);
DependencyProperty prop =
(DependencyProperty) field.GetValue (item);
+ object value = item.GetValue
(prop);
+ Adjustment adj;
+
Widget label = new Label
(propName);
label.Show ();
- Widget value = null;
+ Widget widget = null;
switch (info[i].Type) {
case PropType.Cap:
- value = new ComboBox
(capEntries);
- ((ComboBox)
value).Changed += new EventHandler (OnComboChanged);
+ widget = new ComboBox
(capEntries);
+ ((ComboBox)
widget).Changed += new EventHandler (OnComboChanged);
break;
case PropType.Data:
- value = new Entry ();
- ((Entry) value).Changed
+= new EventHandler (OnDataChanged);
+ widget = new Entry ();
+ ((Entry)
widget).Changed += new EventHandler (OnDataChanged);
break;
case PropType.Double:
- value = new SpinButton
(null, 1.0, 2);
- ((SpinButton)
value).Numeric = true;
- ((SpinButton)
value).SetRange (0.0, Double.MaxValue);
- ((SpinButton)
value).Changed += new EventHandler (OnDoubleChanged);
+ adj = new Adjustment
(0.0, 0.0, Double.MaxValue, 1.0, 10.0, 100.0);
+ widget = new SpinButton
(adj, 1.0, 2);
+ ((SpinButton)
widget).Numeric = true;
+ if (value != null)
+ ((SpinButton)
widget).Value = (double) value;
+ ((SpinButton)
widget).Changed += new EventHandler (OnDoubleChanged);
break;
case PropType.Integer:
- value = new SpinButton
(null, 1.0, 0);
- ((SpinButton)
value).Numeric = true;
- ((SpinButton)
value).SetRange (0.0, Int32.MaxValue);
- ((SpinButton)
value).Changed += new EventHandler (OnIntegerChanged);
+ adj = new Adjustment
(0.0, 0.0, Int32.MaxValue, 1.0, 10.0, 100.0);
+ widget = new SpinButton
(adj, 1.0, 0);
+ ((SpinButton)
widget).Numeric = true;
+ if (value != null)
+ ((SpinButton)
widget).Value = (double) value;
+ ((SpinButton)
widget).Changed += new EventHandler (OnIntegerChanged);
break;
case PropType.Percent:
- value = new SpinButton
(null, 0.01, 2);
- ((SpinButton)
value).Numeric = true;
- ((SpinButton)
value).SetRange (0.0, 1.0);
- ((SpinButton)
value).Changed += new EventHandler (OnDoubleChanged);
+ adj = new Adjustment
(0.0, 0.0, 1.0, 0.01, 0.1, 1.0);
+ widget = new SpinButton
(adj, 0.01, 2);
+ ((SpinButton)
widget).Numeric = true;
+ ((SpinButton)
widget).SetRange (0.0, 1.0);
+ if (value != null)
+ ((SpinButton)
widget).Value = (double) value;
+ ((SpinButton)
widget).Changed += new EventHandler (OnDoubleChanged);
break;
case PropType.Stretch:
- value = new ComboBox
(stretchEntries);
- ((ComboBox)
value).Changed += new EventHandler (OnComboChanged);
+ widget = new ComboBox
(stretchEntries);
+ ((ComboBox)
widget).Changed += new EventHandler (OnComboChanged);
break;
case PropType.LineJoin:
- value = new ComboBox
(lineJoinEntries);
- ((ComboBox)
value).Changed += new EventHandler (OnComboChanged);
+ widget = new ComboBox
(lineJoinEntries);
+ ((ComboBox)
widget).Changed += new EventHandler (OnComboChanged);
break;
case PropType.DashArray:
- value = new Button
("...");
+ widget = new Button
("...");
break;
case PropType.Visibility:
- value = new ComboBox
(visibilityEntries);
- ((ComboBox)
value).Changed += new EventHandler (OnComboChanged);
+ widget = new ComboBox
(visibilityEntries);
+ ((ComboBox)
widget).Changed += new EventHandler (OnComboChanged);
break;
}
- propTable.Add (value, prop);
- value.Show ();
+ propTable.Add (widget, prop);
+ widget.Show ();
if (info[i].Extended) {
((Table)
extended).Attach (label, 0, 1, etop, etop + 1);
- ((Table)
extended).Attach (value, 1, 2, etop, etop + 1);
+ ((Table)
extended).Attach (widget, 1, 2, etop, etop + 1);
etop++;
} else {
((Table) main).Attach
(label, 0, 1, top, top + 1);
- ((Table) main).Attach
(value, 1, 2, top, top + 1);
+ ((Table) main).Attach
(widget, 1, 2, top, top + 1);
top++;
}
}
@@ -191,7 +201,7 @@
((Box) properties).PackStart (main);
if (erows > 0) {
- Widget expander = new Expander ("");
+ Widget expander = new Expander ("More...");
((Expander) expander).Expanded = false;
extended.Show ();
Modified: trunk/lunareclipse/Properties/PropertyGroupLayout.cs
===================================================================
--- trunk/lunareclipse/Properties/PropertyGroupLayout.cs 2007-06-29
18:48:26 UTC (rev 81062)
+++ trunk/lunareclipse/Properties/PropertyGroupLayout.cs 2007-06-29
18:55:30 UTC (rev 81063)
@@ -13,25 +13,32 @@
namespace LunarEclipse {
public class PropertyGroupLayout : PropertyGroup {
+ enum PropType {
+ Double,
+ Integer
+ }
+
struct PropInfo {
public string Name;
+ public PropType Type;
public bool Attached;
public bool CanAuto;
- public PropInfo (string name, bool attached, bool
canAuto)
+ public PropInfo (string name, PropType type, bool
attached, bool canAuto)
{
Name = name;
+ Type = type;
Attached = attached;
CanAuto = canAuto;
}
}
static PropInfo [] info = new PropInfo [5] {
- new PropInfo ("WidthProperty", false, true),
- new PropInfo ("HeightProperty", false, true),
- new PropInfo ("LeftProperty", true, false),
- new PropInfo ("TopProperty", true, false),
- new PropInfo ("ZIndexProperty", false, false),
+ new PropInfo ("WidthProperty", PropType.Double,
false, true),
+ new PropInfo ("HeightProperty", PropType.Double,
false, true),
+ new PropInfo ("LeftProperty", PropType.Double, true,
false),
+ new PropInfo ("TopProperty", PropType.Double, true,
false),
+ new PropInfo ("ZIndexProperty", PropType.Integer,
false, false),
};
DependencyObject item;
@@ -53,7 +60,7 @@
return;
}
- List<FieldInfo> props = new List<FieldInfo> ();
+ Hashtable props = new Hashtable ();
for (Type type = item.GetType (); type != null; type =
type.BaseType) {
FieldInfo[] fields = type.GetFields ();
foreach (FieldInfo field in fields) {
@@ -62,7 +69,7 @@
for (i = 0; i < info.Length; i++) {
if (field.Name == info[i].Name)
{
- props.Add (field);
+ props.Add (field.Name,
field);
break;
}
}
@@ -80,39 +87,55 @@
uint top = 0;
for (i = 0; i < info.Length; i++) {
- foreach (FieldInfo field in props) {
- if (field.Name == info[i].Name) {
- string propName =
info[i].Name.Substring (0, info[i].Name.Length - 8);
- DependencyProperty prop =
(DependencyProperty) field.GetValue (item);
- Widget label = new Label
(propName);
- label.Show ();
-
- Widget value = new SpinButton
(null, 1.0, 0);
- ((SpinButton) value).Changed +=
new EventHandler (OnIntegerChanged);
- ((SpinButton) value).SetRange
(0.0, Int32.MaxValue);
- ((SpinButton) value).Numeric =
true;
-
- propTable.Add (value, prop);
- value.Show ();
-
- if (info[i].CanAuto) {
- Box hbox = new HBox
(false, 6);
- hbox.PackStart (value,
true, true, 0);
- Button button = new
Button ("Auto");
- button.Clicked += new
EventHandler (OnAutoClicked);
- spinTable.Add (button,
value);
- button.Show ();
- hbox.PackStart (button,
false, false, 0);
- hbox.Show ();
-
- value = hbox;
- }
-
- table.Attach (label, 0, 1, top,
top + 1);
- table.Attach (value, 1, 2, top,
top + 1);
- top++;
+ FieldInfo field = (FieldInfo)
props[info[i].Name];
+ if (field == null)
+ continue;
+
+ string propName = info[i].Name.Substring (0,
info[i].Name.Length - 8);
+ DependencyProperty prop = (DependencyProperty)
field.GetValue (item);
+ object value = item.GetValue (prop);
+ Widget label = new Label (propName);
+ label.Show ();
+
+ Adjustment adj = new Adjustment (0.0, 0.0,
Int32.MaxValue, 1.0, 10.0, 100.0);
+ Widget widget = new SpinButton (adj, 1.0, 0);
+ ((SpinButton) widget).SetRange (0.0, (double)
Int32.MaxValue);
+ ((SpinButton) widget).Numeric = true;
+
+ Console.WriteLine ("Layout: {0} = {1} ({2})",
propName, value, value.GetType ());
+ if (value != null) {
+ switch (value.GetType ().Name) {
+ case "Double":
+ ((SpinButton) widget).Value =
(double) value;
+ break;
+ case "Int32":
+ ((SpinButton) widget).Value =
(int) value;
+ break;
}
}
+
+ ((SpinButton) widget).Changed += new
EventHandler (OnIntegerChanged);
+ ((SpinButton) widget).ValueChanged += new
EventHandler (OnIntegerChanged);
+
+ propTable.Add (widget, prop);
+ widget.Show ();
+
+ if (info[i].CanAuto) {
+ Box hbox = new HBox (false, 6);
+ hbox.PackStart (widget, true, true, 0);
+ Button button = new Button ("Auto");
+ button.Clicked += new EventHandler
(OnAutoClicked);
+ spinTable.Add (button, widget);
+ button.Show ();
+ hbox.PackStart (button, false, false,
0);
+ hbox.Show ();
+
+ widget = hbox;
+ }
+
+ table.Attach (label, 0, 1, top, top + 1);
+ table.Attach (widget, 1, 2, top, top + 1);
+ top++;
}
table.Show ();
@@ -139,10 +162,10 @@
SpinButton spin = (SpinButton) o;
if (((Entry) spin).Text == "Auto") {
- item.SetValue<int> (prop, 0);
+ item.SetValue<double> (prop, 0.0);
} else {
- int v = (int) spin.Value;
- item.SetValue<int> (prop, v);
+ double v = spin.Value;
+ item.SetValue<double> (prop, v);
}
}
Modified: trunk/lunareclipse/View/MainWindow.cs
===================================================================
--- trunk/lunareclipse/View/MainWindow.cs 2007-06-29 18:48:26 UTC (rev
81062)
+++ trunk/lunareclipse/View/MainWindow.cs 2007-06-29 18:55:30 UTC (rev
81063)
@@ -22,10 +22,12 @@
Box mainContainer;
MoonlightController controller;
TextBuffer buffer = new Gtk.TextBuffer(new TextTagTable());
+ IPropertyGroup properties;
Button undo;
Button redo;
Notebook book;
- public MainWindow (): base (Gtk.WindowType.Toplevel)
+
+ public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Build ();
@@ -44,10 +46,12 @@
mainContainer.Add (moonlight);
- Widget properties = new Properties ();
- properties.Show ();
- mainContainer.Add (properties);
+ Widget propertyPane = new Properties ();
+ propertyPane.Show ();
+ mainContainer.Add (propertyPane);
+ properties = (IPropertyGroup) propertyPane;
+
TextView view = new Gtk.TextView(buffer);
view.Show ();
@@ -66,7 +70,7 @@
book.Show ();
Add (book);
- controller = new MoonlightController(moonlight);
+ controller = new MoonlightController (moonlight, properties);
HookEvents(true);
Show ();
}
@@ -99,7 +103,7 @@
};
}
- else
+ else
{
//FIXME Unhook events ;)
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches