|
@@ -8,24 +8,18 @@ using Gee;
|
|
|
|
|
|
|
|
namespace Crown
|
|
namespace Crown
|
|
|
{
|
|
{
|
|
|
-public class PropertyRow : Gtk.Bin
|
|
|
|
|
-{
|
|
|
|
|
- public PropertyRow(Gtk.Widget child)
|
|
|
|
|
- {
|
|
|
|
|
- this.hexpand = true;
|
|
|
|
|
- add(child);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-public class ComponentView : Gtk.Grid
|
|
|
|
|
|
|
+public class PropertyGrid : Gtk.Grid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
public Guid _id;
|
|
public Guid _id;
|
|
|
public Guid _component_id;
|
|
public Guid _component_id;
|
|
|
public int _rows;
|
|
public int _rows;
|
|
|
|
|
|
|
|
- public ComponentView()
|
|
|
|
|
|
|
+ public PropertyGrid()
|
|
|
{
|
|
{
|
|
|
|
|
+ this.row_spacing = 4;
|
|
|
|
|
+ this.column_spacing = 12;
|
|
|
|
|
+
|
|
|
// Data
|
|
// Data
|
|
|
_id = GUID_ZERO;
|
|
_id = GUID_ZERO;
|
|
|
_component_id = GUID_ZERO;
|
|
_component_id = GUID_ZERO;
|
|
@@ -34,17 +28,14 @@ public class ComponentView : Gtk.Grid
|
|
|
|
|
|
|
|
public void add_row(string label, Gtk.Widget w)
|
|
public void add_row(string label, Gtk.Widget w)
|
|
|
{
|
|
{
|
|
|
- this.row_spacing = 6;
|
|
|
|
|
- this.column_spacing = 12;
|
|
|
|
|
-
|
|
|
|
|
Gtk.Label l = new Label(label);
|
|
Gtk.Label l = new Label(label);
|
|
|
l.width_chars = 13;
|
|
l.width_chars = 13;
|
|
|
l.set_alignment(1.0f, 0.5f);
|
|
l.set_alignment(1.0f, 0.5f);
|
|
|
|
|
|
|
|
- PropertyRow r = new PropertyRow(w);
|
|
|
|
|
|
|
+ w.hexpand = true;
|
|
|
|
|
|
|
|
this.attach(l, 0, (int)_rows);
|
|
this.attach(l, 0, (int)_rows);
|
|
|
- this.attach(r, 1, (int)_rows);
|
|
|
|
|
|
|
+ this.attach(w, 1, (int)_rows);
|
|
|
++_rows;
|
|
++_rows;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -53,7 +44,30 @@ public class ComponentView : Gtk.Grid
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class TransformComponentView : ComponentView
|
|
|
|
|
|
|
+public class PropertyGridSet : Gtk.Box
|
|
|
|
|
+{
|
|
|
|
|
+ public PropertyGridSet()
|
|
|
|
|
+ {
|
|
|
|
|
+ Object(orientation: Gtk.Orientation.VERTICAL, spacing: 0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Gtk.Expander add_property_grid(PropertyGrid cv, string label)
|
|
|
|
|
+ {
|
|
|
|
|
+ Gtk.Label lb = new Gtk.Label(null);
|
|
|
|
|
+ lb.set_markup("<b>%s</b>".printf(label));
|
|
|
|
|
+ lb.set_alignment(0.0f, 0.5f);
|
|
|
|
|
+
|
|
|
|
|
+ Gtk.Expander expander = new Gtk.Expander("");
|
|
|
|
|
+ expander.label_widget = lb;
|
|
|
|
|
+ expander.child = cv;
|
|
|
|
|
+ expander.expanded = true;
|
|
|
|
|
+ this.pack_start(expander, false, true, 0);
|
|
|
|
|
+
|
|
|
|
|
+ return expander;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+public class TransformPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -63,7 +77,7 @@ public class TransformComponentView : ComponentView
|
|
|
private EntryRotation _rotation;
|
|
private EntryRotation _rotation;
|
|
|
private EntryScale _scale;
|
|
private EntryScale _scale;
|
|
|
|
|
|
|
|
- public TransformComponentView(Level level)
|
|
|
|
|
|
|
+ public TransformPropertyGrid(Level level)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -100,7 +114,7 @@ public class TransformComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class MeshRendererComponentView : ComponentView
|
|
|
|
|
|
|
+public class MeshRendererPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -111,7 +125,7 @@ public class MeshRendererComponentView : ComponentView
|
|
|
private ResourceChooserButton _material;
|
|
private ResourceChooserButton _material;
|
|
|
private CheckBox _visible;
|
|
private CheckBox _visible;
|
|
|
|
|
|
|
|
- public MeshRendererComponentView(Level level, ProjectStore store)
|
|
|
|
|
|
|
+ public MeshRendererPropertyGrid(Level level, ProjectStore store)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -153,7 +167,7 @@ public class MeshRendererComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class SpriteRendererComponentView : ComponentView
|
|
|
|
|
|
|
+public class SpriteRendererPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -165,7 +179,7 @@ public class SpriteRendererComponentView : ComponentView
|
|
|
private EntryDouble _depth;
|
|
private EntryDouble _depth;
|
|
|
private CheckBox _visible;
|
|
private CheckBox _visible;
|
|
|
|
|
|
|
|
- public SpriteRendererComponentView(Level level, ProjectStore store)
|
|
|
|
|
|
|
+ public SpriteRendererPropertyGrid(Level level, ProjectStore store)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -212,7 +226,7 @@ public class SpriteRendererComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class LightComponentView : ComponentView
|
|
|
|
|
|
|
+public class LightPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -224,7 +238,7 @@ public class LightComponentView : ComponentView
|
|
|
private EntryDouble _spot_angle;
|
|
private EntryDouble _spot_angle;
|
|
|
private ColorButtonVector3 _color;
|
|
private ColorButtonVector3 _color;
|
|
|
|
|
|
|
|
- public LightComponentView(Level level)
|
|
|
|
|
|
|
+ public LightPropertyGrid(Level level)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -280,7 +294,7 @@ public class LightComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class CameraComponentView : ComponentView
|
|
|
|
|
|
|
+public class CameraPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -291,7 +305,7 @@ public class CameraComponentView : ComponentView
|
|
|
private EntryDouble _near_range;
|
|
private EntryDouble _near_range;
|
|
|
private EntryDouble _far_range;
|
|
private EntryDouble _far_range;
|
|
|
|
|
|
|
|
- public CameraComponentView(Level level)
|
|
|
|
|
|
|
+ public CameraPropertyGrid(Level level)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -336,7 +350,7 @@ public class CameraComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class ColliderComponentView : ComponentView
|
|
|
|
|
|
|
+public class ColliderPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -347,7 +361,7 @@ public class ColliderComponentView : ComponentView
|
|
|
private ResourceChooserButton _scene;
|
|
private ResourceChooserButton _scene;
|
|
|
private EntryText _name;
|
|
private EntryText _name;
|
|
|
|
|
|
|
|
- public ColliderComponentView(Level level, ProjectStore store)
|
|
|
|
|
|
|
+ public ColliderPropertyGrid(Level level, ProjectStore store)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -415,7 +429,7 @@ public class ColliderComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class ActorComponentView : ComponentView
|
|
|
|
|
|
|
+public class ActorPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -426,7 +440,7 @@ public class ActorComponentView : ComponentView
|
|
|
private EntryDouble _mass;
|
|
private EntryDouble _mass;
|
|
|
private EntryText _material;
|
|
private EntryText _material;
|
|
|
|
|
|
|
|
- public ActorComponentView(Level level)
|
|
|
|
|
|
|
+ public ActorPropertyGrid(Level level)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -472,7 +486,7 @@ public class ActorComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class ScriptComponentView : ComponentView
|
|
|
|
|
|
|
+public class ScriptPropertyGrid : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -480,7 +494,7 @@ public class ScriptComponentView : ComponentView
|
|
|
// Widgets
|
|
// Widgets
|
|
|
private ResourceChooserButton _script_resource;
|
|
private ResourceChooserButton _script_resource;
|
|
|
|
|
|
|
|
- public ScriptComponentView(Level level, ProjectStore store)
|
|
|
|
|
|
|
+ public ScriptPropertyGrid(Level level, ProjectStore store)
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
_level = level;
|
|
_level = level;
|
|
@@ -507,7 +521,7 @@ public class ScriptComponentView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class AnimationStateMachine : ComponentView
|
|
|
|
|
|
|
+public class AnimationStateMachine : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -542,7 +556,7 @@ public class AnimationStateMachine : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class UnitView : ComponentView
|
|
|
|
|
|
|
+public class UnitView : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -571,7 +585,7 @@ public class UnitView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class SoundTransformView : ComponentView
|
|
|
|
|
|
|
+public class SoundTransformView : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -615,7 +629,7 @@ public class SoundTransformView : ComponentView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public class SoundView : ComponentView
|
|
|
|
|
|
|
+public class SoundView : PropertyGrid
|
|
|
{
|
|
{
|
|
|
// Data
|
|
// Data
|
|
|
Level _level;
|
|
Level _level;
|
|
@@ -677,15 +691,15 @@ public class PropertiesView : Gtk.Bin
|
|
|
// Data
|
|
// Data
|
|
|
private Level _level;
|
|
private Level _level;
|
|
|
private HashMap<string, Gtk.Expander> _expanders;
|
|
private HashMap<string, Gtk.Expander> _expanders;
|
|
|
- private HashMap<string, ComponentView> _components;
|
|
|
|
|
|
|
+ private HashMap<string, PropertyGrid> _objects;
|
|
|
private ArrayList<ComponentEntry?> _entries;
|
|
private ArrayList<ComponentEntry?> _entries;
|
|
|
|
|
|
|
|
// Widgets
|
|
// Widgets
|
|
|
private Gtk.Label _nothing_to_show;
|
|
private Gtk.Label _nothing_to_show;
|
|
|
private Gtk.Viewport _viewport;
|
|
private Gtk.Viewport _viewport;
|
|
|
private Gtk.ScrolledWindow _scrolled_window;
|
|
private Gtk.ScrolledWindow _scrolled_window;
|
|
|
- private Gtk.Box _components_vbox;
|
|
|
|
|
private Gtk.Widget _current_widget;
|
|
private Gtk.Widget _current_widget;
|
|
|
|
|
+ private PropertyGridSet _object_view;
|
|
|
|
|
|
|
|
public PropertiesView(Level level, ProjectStore store)
|
|
public PropertiesView(Level level, ProjectStore store)
|
|
|
{
|
|
{
|
|
@@ -694,37 +708,33 @@ public class PropertiesView : Gtk.Bin
|
|
|
_level.selection_changed.connect(on_selection_changed);
|
|
_level.selection_changed.connect(on_selection_changed);
|
|
|
|
|
|
|
|
_expanders = new HashMap<string, Gtk.Expander>();
|
|
_expanders = new HashMap<string, Gtk.Expander>();
|
|
|
- _components = new HashMap<string, ComponentView>();
|
|
|
|
|
|
|
+ _objects = new HashMap<string, PropertyGrid>();
|
|
|
_entries = new ArrayList<ComponentEntry?>();
|
|
_entries = new ArrayList<ComponentEntry?>();
|
|
|
|
|
|
|
|
// Widgets
|
|
// Widgets
|
|
|
- _components_vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
|
|
|
|
|
- _components_vbox.margin_bottom = 18;
|
|
|
|
|
|
|
+ _object_view = new PropertyGridSet();
|
|
|
|
|
+ _object_view.border_width = 6;
|
|
|
|
|
|
|
|
// Unit
|
|
// Unit
|
|
|
- add_component_view("Unit", "name", 0, new UnitView(_level, store));
|
|
|
|
|
- add_component_view("Transform", "transform", 0, new TransformComponentView(_level));
|
|
|
|
|
- add_component_view("Light", "light", 1, new LightComponentView(_level));
|
|
|
|
|
- add_component_view("Camera", "camera", 2, new CameraComponentView(_level));
|
|
|
|
|
- add_component_view("Mesh Renderer", "mesh_renderer", 3, new MeshRendererComponentView(_level, store));
|
|
|
|
|
- add_component_view("Sprite Renderer", "sprite_renderer", 3, new SpriteRendererComponentView(_level, store));
|
|
|
|
|
- add_component_view("Collider", "collider", 3, new ColliderComponentView(_level, store));
|
|
|
|
|
- add_component_view("Actor", "actor", 3, new ActorComponentView(_level));
|
|
|
|
|
- add_component_view("Script", "script", 3, new ScriptComponentView(_level, store));
|
|
|
|
|
- add_component_view("Animation State Machine", "animation_state_machine", 3, new AnimationStateMachine(_level, store));
|
|
|
|
|
|
|
+ register_object_type("Unit", "name", 0, new UnitView(_level, store));
|
|
|
|
|
+ register_object_type("Transform", "transform", 0, new TransformPropertyGrid(_level));
|
|
|
|
|
+ register_object_type("Light", "light", 1, new LightPropertyGrid(_level));
|
|
|
|
|
+ register_object_type("Camera", "camera", 2, new CameraPropertyGrid(_level));
|
|
|
|
|
+ register_object_type("Mesh Renderer", "mesh_renderer", 3, new MeshRendererPropertyGrid(_level, store));
|
|
|
|
|
+ register_object_type("Sprite Renderer", "sprite_renderer", 3, new SpriteRendererPropertyGrid(_level, store));
|
|
|
|
|
+ register_object_type("Collider", "collider", 3, new ColliderPropertyGrid(_level, store));
|
|
|
|
|
+ register_object_type("Actor", "actor", 3, new ActorPropertyGrid(_level));
|
|
|
|
|
+ register_object_type("Script", "script", 3, new ScriptPropertyGrid(_level, store));
|
|
|
|
|
+ register_object_type("Animation State Machine", "animation_state_machine", 3, new AnimationStateMachine(_level, store));
|
|
|
|
|
|
|
|
// Sound
|
|
// Sound
|
|
|
- add_component_view("Transform", "sound_transform", 0, new SoundTransformView(_level));
|
|
|
|
|
- add_component_view("Sound", "sound_properties", 1, new SoundView(_level, store));
|
|
|
|
|
-
|
|
|
|
|
- _entries.sort((a, b) => { return (a.position < b.position ? -1 : 1); });
|
|
|
|
|
- foreach (var entry in _entries)
|
|
|
|
|
- _components_vbox.pack_start(_expanders[entry.type], false, true, 0);
|
|
|
|
|
|
|
+ register_object_type("Transform", "sound_transform", 0, new SoundTransformView(_level));
|
|
|
|
|
+ register_object_type("Sound", "sound_properties", 1, new SoundView(_level, store));
|
|
|
|
|
|
|
|
_nothing_to_show = new Gtk.Label("Nothing to show");
|
|
_nothing_to_show = new Gtk.Label("Nothing to show");
|
|
|
|
|
|
|
|
_viewport = new Gtk.Viewport(null, null);
|
|
_viewport = new Gtk.Viewport(null, null);
|
|
|
- _viewport.add(_components_vbox);
|
|
|
|
|
|
|
+ _viewport.add(_object_view);
|
|
|
|
|
|
|
|
_scrolled_window = new Gtk.ScrolledWindow(null, null);
|
|
_scrolled_window = new Gtk.ScrolledWindow(null, null);
|
|
|
_scrolled_window.add(_viewport);
|
|
_scrolled_window.add(_viewport);
|
|
@@ -735,22 +745,12 @@ public class PropertiesView : Gtk.Bin
|
|
|
this.set_current_widget(_nothing_to_show);
|
|
this.set_current_widget(_nothing_to_show);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void add_component_view(string label, string component_type, int position, ComponentView cv)
|
|
|
|
|
|
|
+ private void register_object_type(string label, string object_type, int position, PropertyGrid cv)
|
|
|
{
|
|
{
|
|
|
- Gtk.Label lb = new Gtk.Label(null);
|
|
|
|
|
- lb.set_markup("<b>%s</b>".printf(label));
|
|
|
|
|
- lb.set_alignment(0.0f, 0.5f);
|
|
|
|
|
-
|
|
|
|
|
- Gtk.Expander expander = new Gtk.Expander("");
|
|
|
|
|
- expander.label_widget = lb;
|
|
|
|
|
- expander.child = cv;
|
|
|
|
|
- expander.expanded = true;
|
|
|
|
|
- expander.margin_end = 12;
|
|
|
|
|
-
|
|
|
|
|
- _components[component_type] = cv;
|
|
|
|
|
- _expanders[component_type] = expander;
|
|
|
|
|
-
|
|
|
|
|
- _entries.add({ component_type, position });
|
|
|
|
|
|
|
+ Gtk.Expander expander = _object_view.add_property_grid(cv, label);
|
|
|
|
|
+ _objects[object_type] = cv;
|
|
|
|
|
+ _expanders[object_type] = expander;
|
|
|
|
|
+ _entries.add({ object_type, position });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void set_current_widget(Gtk.Widget w)
|
|
private void set_current_widget(Gtk.Widget w)
|
|
@@ -791,7 +791,7 @@ public class PropertiesView : Gtk.Bin
|
|
|
Guid component_id;
|
|
Guid component_id;
|
|
|
if (unit.has_component(out component_id, entry.type) || entry.type == "name")
|
|
if (unit.has_component(out component_id, entry.type) || entry.type == "name")
|
|
|
{
|
|
{
|
|
|
- ComponentView cv = _components[entry.type];
|
|
|
|
|
|
|
+ PropertyGrid cv = _objects[entry.type];
|
|
|
cv._id = id;
|
|
cv._id = id;
|
|
|
cv._component_id = component_id;
|
|
cv._component_id = component_id;
|
|
|
cv.update();
|
|
cv.update();
|
|
@@ -813,7 +813,7 @@ public class PropertiesView : Gtk.Bin
|
|
|
|
|
|
|
|
if (entry.type == "sound_transform" || entry.type == "sound_properties")
|
|
if (entry.type == "sound_transform" || entry.type == "sound_properties")
|
|
|
{
|
|
{
|
|
|
- ComponentView cv = _components[entry.type];
|
|
|
|
|
|
|
+ PropertyGrid cv = _objects[entry.type];
|
|
|
cv._id = id;
|
|
cv._id = id;
|
|
|
cv.update();
|
|
cv.update();
|
|
|
expander.show_all();
|
|
expander.show_all();
|