Sfoglia il codice sorgente

tools: drop labels for vector inputs

Daniele Bartolini 8 mesi fa
parent
commit
155697bb25

+ 4 - 6
tools/level_editor/resources/ui/style.css

@@ -47,24 +47,22 @@ notebook > header tab {
 
 .axis {
 	min-width: 22px;
-	font-weight: bold;
-	border-radius: 4px 0px 0px 4px;
 }
 
 .axis.x {
-	background: rgba(120, 0, 0, 0.8);
+	background: rgba(180, 0, 0, 0.2);
 }
 
 .axis.y {
-	background: rgba(0, 120, 0, 0.8);
+	background: rgba(0, 180, 0, 0.2);
 }
 
 .axis.z {
-	background: rgba(0, 0, 120, 0.8);
+	background: rgba(0, 0, 180, 0.2);
 }
 
 .axis.w {
-	background: rgba(120, 120, 120, 0.8);
+	background: rgba(180, 180, 180, 0.2);
 }
 
 .counter-label {

+ 9 - 31
tools/widgets/input_quaternion.vala

@@ -11,12 +11,6 @@ public class InputQuaternion : InputField, Gtk.Box
 	public InputDouble _x;
 	public InputDouble _y;
 	public InputDouble _z;
-	public Gtk.Label _x_label;
-	public Gtk.Label _y_label;
-	public Gtk.Label _z_label;
-	public Gtk.Box _x_box;
-	public Gtk.Box _y_box;
-	public Gtk.Box _z_box;
 
 	public void set_inconsistent(bool inconsistent)
 	{
@@ -69,38 +63,22 @@ public class InputQuaternion : InputField, Gtk.Box
 
 		_rotation = QUATERNION_IDENTITY;
 		_x = new InputDouble(0.0, -180.0, 180.0, "%.4g");
+		_x.get_style_context().add_class("axis");
+		_x.get_style_context().add_class("x");
 		_y = new InputDouble(0.0, -180.0, 180.0, "%.4g");
+		_y.get_style_context().add_class("axis");
+		_y.get_style_context().add_class("y");
 		_z = new InputDouble(0.0, -180.0, 180.0, "%.4g");
+		_z.get_style_context().add_class("axis");
+		_z.get_style_context().add_class("z");
 
 		_x.value_changed.connect(on_value_changed);
 		_y.value_changed.connect(on_value_changed);
 		_z.value_changed.connect(on_value_changed);
 
-		_x_label = new Gtk.Label("X");
-		_x_label.get_style_context().add_class("axis");
-		_x_label.get_style_context().add_class("x");
-		_y_label = new Gtk.Label("Y");
-		_y_label.get_style_context().add_class("axis");
-		_y_label.get_style_context().add_class("y");
-		_z_label = new Gtk.Label("Z");
-		_z_label.get_style_context().add_class("axis");
-		_z_label.get_style_context().add_class("z");
-
-		_x_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_x_box.pack_start(_x_label, false);
-		_x_box.pack_start(_x, true);
-
-		_y_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_y_box.pack_start(_y_label, false);
-		_y_box.pack_start(_y, true);
-
-		_z_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_z_box.pack_start(_z_label, false);
-		_z_box.pack_start(_z, true);
-
-		this.pack_start(_x_box, true);
-		this.pack_start(_y_box, true);
-		this.pack_start(_z_box, true);
+		this.pack_start(_x, true);
+		this.pack_start(_y, true);
+		this.pack_start(_z, true);
 	}
 
 	private void on_value_changed(InputField p)

+ 6 - 24
tools/widgets/input_vector2.vala

@@ -7,16 +7,9 @@ namespace Crown
 {
 public class InputVector2 : Gtk.Box
 {
-	// Data
 	public bool _stop_emit;
-
-	// Widgets
 	public InputDouble _x;
 	public InputDouble _y;
-	public Gtk.Label _x_label;
-	public Gtk.Label _y_label;
-	public Gtk.Box _x_box;
-	public Gtk.Box _y_box;
 
 	public Vector2 value
 	{
@@ -46,28 +39,17 @@ public class InputVector2 : Gtk.Box
 
 		// Widgets
 		_x = new InputDouble(xyz.x, min.x, max.x, preview_fmt);
+		_x.get_style_context().add_class("axis");
+		_x.get_style_context().add_class("x");
 		_y = new InputDouble(xyz.y, min.y, max.y, preview_fmt);
+		_y.get_style_context().add_class("axis");
+		_y.get_style_context().add_class("y");
 
 		_x.value_changed.connect(on_value_changed);
 		_y.value_changed.connect(on_value_changed);
 
-		_x_label = new Gtk.Label("X");
-		_x_label.get_style_context().add_class("axis");
-		_x_label.get_style_context().add_class("x");
-		_y_label = new Gtk.Label("Y");
-		_y_label.get_style_context().add_class("axis");
-		_y_label.get_style_context().add_class("y");
-
-		_x_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_x_box.pack_start(_x_label, false);
-		_x_box.pack_start(_x, true);
-
-		_y_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_y_box.pack_start(_y_label, false);
-		_y_box.pack_start(_y, true);
-
-		this.pack_start(_x_box, true);
-		this.pack_start(_y_box, true);
+		this.pack_start(_x, true);
+		this.pack_start(_y, true);
 	}
 
 	private void on_value_changed()

+ 9 - 31
tools/widgets/input_vector3.vala

@@ -10,12 +10,6 @@ public class InputVector3 : InputField, Gtk.Box
 	public InputDouble _x;
 	public InputDouble _y;
 	public InputDouble _z;
-	public Gtk.Label _x_label;
-	public Gtk.Label _y_label;
-	public Gtk.Label _z_label;
-	public Gtk.Box _x_box;
-	public Gtk.Box _y_box;
-	public Gtk.Box _z_box;
 
 	public void set_inconsistent(bool inconsistent)
 	{
@@ -63,38 +57,22 @@ public class InputVector3 : InputField, Gtk.Box
 		Object(orientation: Gtk.Orientation.HORIZONTAL, spacing: 4);
 
 		_x = new InputDouble(xyz.x, min.x, max.x, preview_fmt);
+		_x.get_style_context().add_class("axis");
+		_x.get_style_context().add_class("x");
 		_y = new InputDouble(xyz.y, min.y, max.y, preview_fmt);
+		_y.get_style_context().add_class("axis");
+		_y.get_style_context().add_class("y");
 		_z = new InputDouble(xyz.z, min.z, max.z, preview_fmt);
+		_z.get_style_context().add_class("axis");
+		_z.get_style_context().add_class("z");
 
 		_x.value_changed.connect(on_value_changed);
 		_y.value_changed.connect(on_value_changed);
 		_z.value_changed.connect(on_value_changed);
 
-		_x_label = new Gtk.Label("X");
-		_x_label.get_style_context().add_class("axis");
-		_x_label.get_style_context().add_class("x");
-		_y_label = new Gtk.Label("Y");
-		_y_label.get_style_context().add_class("axis");
-		_y_label.get_style_context().add_class("y");
-		_z_label = new Gtk.Label("Z");
-		_z_label.get_style_context().add_class("axis");
-		_z_label.get_style_context().add_class("z");
-
-		_x_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_x_box.pack_start(_x_label, false);
-		_x_box.pack_start(_x, true);
-
-		_y_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_y_box.pack_start(_y_label, false);
-		_y_box.pack_start(_y, true);
-
-		_z_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_z_box.pack_start(_z_label, false);
-		_z_box.pack_start(_z, true);
-
-		this.pack_start(_x_box, true);
-		this.pack_start(_y_box, true);
-		this.pack_start(_z_box, true);
+		this.pack_start(_x, true);
+		this.pack_start(_y, true);
+		this.pack_start(_z, true);
 	}
 
 	private void on_value_changed()

+ 12 - 44
tools/widgets/input_vector4.vala

@@ -7,22 +7,11 @@ namespace Crown
 {
 public class InputVector4 : InputField, Gtk.Box
 {
-	// Data
 	public bool _stop_emit;
-
-	// Widgets
 	public InputDouble _x;
 	public InputDouble _y;
 	public InputDouble _z;
 	public InputDouble _w;
-	public Gtk.Label _x_label;
-	public Gtk.Label _y_label;
-	public Gtk.Label _z_label;
-	public Gtk.Label _w_label;
-	public Gtk.Box _x_box;
-	public Gtk.Box _y_box;
-	public Gtk.Box _z_box;
-	public Gtk.Box _w_box;
 
 	public void set_inconsistent(bool inconsistent)
 	{
@@ -70,48 +59,27 @@ public class InputVector4 : InputField, Gtk.Box
 
 		// Widgets
 		_x = new InputDouble(xyz.x, min.x, max.x, preview_fmt);
+		_x.get_style_context().add_class("axis");
+		_x.get_style_context().add_class("x");
 		_y = new InputDouble(xyz.y, min.y, max.y, preview_fmt);
+		_y.get_style_context().add_class("axis");
+		_y.get_style_context().add_class("y");
 		_z = new InputDouble(xyz.z, min.z, max.z, preview_fmt);
+		_z.get_style_context().add_class("axis");
+		_z.get_style_context().add_class("z");
 		_w = new InputDouble(xyz.w, min.w, max.w, preview_fmt);
+		_w.get_style_context().add_class("axis");
+		_w.get_style_context().add_class("w");
 
 		_x.value_changed.connect(on_value_changed);
 		_y.value_changed.connect(on_value_changed);
 		_z.value_changed.connect(on_value_changed);
 		_w.value_changed.connect(on_value_changed);
 
-		_x_label = new Gtk.Label("X");
-		_x_label.get_style_context().add_class("axis");
-		_x_label.get_style_context().add_class("x");
-		_y_label = new Gtk.Label("Y");
-		_y_label.get_style_context().add_class("axis");
-		_y_label.get_style_context().add_class("y");
-		_z_label = new Gtk.Label("Z");
-		_z_label.get_style_context().add_class("axis");
-		_z_label.get_style_context().add_class("z");
-		_w_label = new Gtk.Label("Z");
-		_w_label.get_style_context().add_class("axis");
-		_w_label.get_style_context().add_class("w");
-
-		_x_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_x_box.pack_start(_x_label, false);
-		_x_box.pack_start(_x, true);
-
-		_y_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_y_box.pack_start(_y_label, false);
-		_y_box.pack_start(_y, true);
-
-		_z_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_z_box.pack_start(_z_label, false);
-		_z_box.pack_start(_z, true);
-
-		_w_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
-		_w_box.pack_start(_w_label, false);
-		_w_box.pack_start(_w, true);
-
-		this.pack_start(_x_box, true);
-		this.pack_start(_y_box, true);
-		this.pack_start(_z_box, true);
-		this.pack_start(_w_box, true);
+		this.pack_start(_x, true);
+		this.pack_start(_y, true);
+		this.pack_start(_z, true);
+		this.pack_start(_w, true);
 	}
 
 	private void on_value_changed()