BoolConst.hx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package hrt.shgraph.nodes;
  2. using hxsl.Ast;
  3. @name("Bool")
  4. @description("Boolean input (static)")
  5. @group("Property")
  6. @width(100)
  7. @noheader()
  8. class BoolConst extends ShaderConst {
  9. @output() var fakeOutput = SType.Bool;
  10. @prop() var value : Bool = true;
  11. override public function getOutputTExpr(key : String) : TExpr {
  12. return {
  13. e: TConst(CBool(value)),
  14. p: null,
  15. t: TBool
  16. };
  17. }
  18. override public function build(key : String) : TExpr {
  19. return null;
  20. }
  21. #if editor
  22. override public function getPropertiesHTML(width : Float) : Array<hide.Element> {
  23. var elements = super.getPropertiesHTML(width);
  24. var element = new hide.Element('<div style="width: 15px; height: 30px"></div>');
  25. element.append(new hide.Element('<input type="checkbox" id="value" />'));
  26. var input = element.children("input");
  27. input.on("change", function(e) {
  28. value = (input.is(":checked")) ? true : false;
  29. });
  30. if (this.value) {
  31. input.prop("checked", true);
  32. }
  33. elements.push(element);
  34. return elements;
  35. }
  36. #end
  37. }