Skip to content

Instantly share code, notes, and snippets.

@MrSmith33
Last active August 29, 2015 13:56
Show Gist options
  • Save MrSmith33/8902067 to your computer and use it in GitHub Desktop.
Save MrSmith33/8902067 to your computer and use it in GitHub Desktop.
application {
window width=1280 height=800 caption="Example project" layout="docking" {
widget dock="fill" layout="absolute" {
-- This 'caption' property will be assigned to 'text' property of frame.header.caption widget as stated in frame template.
-- Also layout will not affect frame widget itself. It will be applied to frame.contentArea, because
-- later is marked as 'children-container' inside frame template.
frame pos="0 0" caption="Test frame. Uses template!" layout="docking" {
text-button dock="top" text="Click me"
line-edit dock="top" text="Edit me"
text-check dock="top" text="check me" check-group=0
text-check dock="top" text="check me" check-group=0
text-check dock="top" text="check me" check-group=0
radiobox
}
}
}
}
template:text-check {
properties {
text location="text.text"
is-checked location="check.isChecked"
}
tree layout="docking" {
check dock="left" name="check" clickTransparent=true
label dock="fill" name="text" clickTransparent=true
}
}
template:text-button extends="button" {
properties {
text location="text.text"
}
tree layout="docking" {
label dock="fill" name="text" clickTransparent=true
}
}
template:icon-button extends="button" {
properties {
icon location="image.image"
}
tree layout="docking" {
image name="image" clickTransparent=true
}
}
template:scroll-bar-vert {
tree layout="docking" {
button name="up-button" dock="up"
button name="down-button" dock="down"
widget name="body" dock="fill" {
widget name="slider"
}
}
}
# We are creating complex widget to be used as simple one.
template:frame {
-- 'properties' are needed to access properties of deeply nested subwidgets.
-- They (properties) will be added to resulting widget (frame) as a proxy to real property
-- You also can assign values to these properties inside layout file.
properties {
-- Missing properties will be automatically created.
-- Here, header.caption widget has no 'text' property, so it will be created.
caption location="header.caption.text"
}
-- subwidgets are used at widget construction time. Widget creator can add some event handlers to these parts
subwidgets {
close-button location="header.close"
}
-- 'tree' represents resulting widget. It will have a name of this template (frame).
tree layout="docking" {
widget name="header" dock="top" layout="docking" {
icon-button name="close" dock="right" icon="close"
label name="caption" dock="fill"
}
-- this widget will automatically retreive any child widgets defined in layout file.
-- also it will affected by layout specified in layout.
children-container:widget name="content-area" dock="fill"
}
}
/*
Construction order of the widget:
-n. widget creators are registered
-3. property types are registered? #parsers of Rect, size, pos, offset etc.
-2. Widget templates are parsed at application init
-1. Application layout is parsed
0. User calls createWidget("frame" [, parent]);
1. Find appropriate widget template and make instance of widget
2. Widget template will then create needed widget types using GuiContext
3. Parent gets attached if passed.
4. After widget is created from template, some additional properties will get assigned to it.
5. Find widget behavior and call attachTo.Behavior may use some subwidget info
of the widget to build complex behavior.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment