Advertisement
hnOsmium0001

JsonUI Example

Oct 9th, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 2.68 KB | None | 0 0
  1. {
  2.   "start": [
  3.     { "window": "Primary" },
  4.     { "window": "WindowDock" }
  5.   ],
  6.   "windows": {
  7.     "Primary": {
  8.       "parent": "default:fixed_window",
  9.       "body": [
  10.         {
  11.           // Either "type" or "def"
  12.           // "type" loads a registered template
  13.           // "def" loads a widget definition from "widgetDefinition"
  14.           // All other properties must begin with 'p:' and are defined by templates
  15.           "type": "default:window_root",
  16.           "prop:children": [
  17.             { "def": "Editor" },
  18.             { "def": "Toolbox" }
  19.           ],
  20.           "prop:layout": "ShareWidths"
  21.         }
  22.       ],
  23.       "properties": {
  24.         // Calls functions
  25.        "position": ["default:centralize_x", "default:centralize_y"],
  26.        "dimensions": ["C2/3Width", "C3/5Height"]
  27.       }
  28.     },
  29.     "WindowDock": {
  30.       "parent": "default:window_dock",
  31.       "properties": {
  32.         "position": ["default:centralize_x", "default:align_bottom_y"],
  33.         "dimensions": "inherit"
  34.       }
  35.     }
  36.   },
  37.   // Function name must start with a Capital letter
  38.   "functions": {
  39.     "C2/3Width": {
  40.       // This function template returns double by defualt
  41.       "function": "default:calculate",
  42.       // Poland expression
  43.       // $XXX are environmental variables filled in when constructing the GUI
  44.       "param:expr": ["*", "$SCREEN_WIDTH", ["/", 2, 3]],
  45.       // Force casting function result
  46.       "param:return": "int"
  47.     },
  48.     "C3/5Height": {
  49.       "function": "default:calculate",
  50.       "param:expr": ["*", "$SCREEN_HEIGHT", ["/", 3, 5]],
  51.       "param:return": "int"
  52.     },
  53.     "ShareWidths": {
  54.       "function": "default:grid",
  55.       "param:layout": [
  56.         [1, 2]
  57.       ],
  58.       "param:wportions": [0.8, 0.2],
  59.       "param:hportions": [1]
  60.     },
  61.     "CheckRegistry": {
  62.       "function:": "default:call_method",
  63.       "param:method": "jsonui.exmaple.registry.RegistryHandler.getInstance"
  64.     }
  65.   },
  66.   // Widget definition must start with a Capital letter
  67.   "widgetDefinitions": {
  68.     "Editor": {
  69.       "type": "default:class_definition",
  70.       "prop:class": "jsonui.example.cad.CADEditor"
  71.     },
  72.     "Toolbox": {
  73.       "type": "default:box/strict_table",
  74.       "event": {
  75.         "onInitialAttach": [
  76.           // Supports both reference and inline functions
  77.           "CheckRegistry",
  78.           {
  79.             "function:": "default:call_method",
  80.             "param:method": "jsonui.example.cad.CADToolbox.addToolboxOptions"
  81.           }
  82.         ]
  83.       },
  84.       "prop:growDir": "down",
  85.       "prop:overflowDir": "right",
  86.       "prop:margin": {
  87.         "top": 4,
  88.         "right": 4,
  89.         "bottom": 4,
  90.         "left": 4
  91.       }
  92.     }
  93.   }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement