input_color3.vala 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2012-2025 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: GPL-3.0-or-later
  4. */
  5. namespace Crown
  6. {
  7. public class InputColor3 : Gtk.Box, InputField
  8. {
  9. private Gtk.ColorButton _color_button;
  10. public void set_inconsistent(bool inconsistent)
  11. {
  12. }
  13. public bool is_inconsistent()
  14. {
  15. return false;
  16. }
  17. public GLib.Value union_value()
  18. {
  19. return this.value;
  20. }
  21. public void set_union_value(GLib.Value v)
  22. {
  23. this.value = (Vector3)v;
  24. }
  25. public Vector3 value
  26. {
  27. get
  28. {
  29. Gdk.RGBA rgba = _color_button.get_rgba();
  30. return Vector3(rgba.red, rgba.green, rgba.blue);
  31. }
  32. set
  33. {
  34. Vector3 rgb = (Vector3)value;
  35. _color_button.set_rgba({ rgb.x, rgb.y, rgb.z, 1.0 });
  36. }
  37. }
  38. public InputColor3()
  39. {
  40. Object(orientation: Gtk.Orientation.HORIZONTAL);
  41. _color_button = new Gtk.ColorButton();
  42. _color_button.color_set.connect(on_color_set);
  43. this.pack_start(_color_button);
  44. }
  45. private void on_color_set()
  46. {
  47. value_changed(this);
  48. }
  49. }
  50. } /* namespace Crown */