Canvas GUI API: Difference between revisions

Jump to navigation Jump to search
add widgets
mNo edit summary
(add widgets)
Line 10: Line 10:
Container class. Stores widgets and the focused window (if any).
Container class. Stores widgets and the focused window (if any).


== style ==
== gui.Widget ==
canvas.style is initialized in gui.nas as
Template class that implements common methods, used by widget classes Button, CheckBox, Lable, LineEdit, ScrollArea


var style = DefaultStyle.new("AmbianceClassic", "Humanity");
=== new: func(derived) ===
'''derived''' class, e.g. gui.widgets.Button
 
=== setFixedSize: func(x, y) ===
 
=== setEnabled: func(enabled) ===
 
=== move: func(x, y) ===
 
=== setSize: func(w, h) ===
 
=== setGeometry: func(geom) ===
 
=== setFocus: func ===
 
=== clearFocus: func ===
 
=== listen: func(type, cb) ===
 
=== onRemove: func ===
 
=== _onStateChange: func ===
 
=== visibilityChanged: func(visible) ===
 
=== _setView: func(view) ===
 
=== _trigger: func(type, data = nil) ===
 
=== _windowFocus: func ===
'''returns:''' bool, focused
 
== DefaultStyle ==
This class stors widget factories
 
=== new: func(name, name_icon_theme) ===
parameters are forwarded to gui.Style.new constructor
 
'''returns:'''' object
 
=== createWidget: func(parent, type, cfg) ===
 
== DefaultStyle.widgets ==
At the time of writing there are the following widgets:
 
button, checkbox, lable, line-edit, scroll-area
 
They have the following common methods:
=== new: func(parent, cfg) ===
'''parent:''' parent canvas element (e.g. group)
'''cfg: ''' a config object
 
=== update: func(model) ===
'''model''' canvas.Window - strange name... no idea why somebody named it model
 
Aparently this method is called on events like mouse move/click so each widget can show an appropriate reaction.
 
== DefaultStyle.widgets.button  ==
 
=== setSize: func(model, w, h) ===
 
=== setText: func(model, text) ===
 
== DefaultStyle.widgets.checkbox  ==
 
=== setSize: func(model, w, h) ===
 
=== setText: func(model, text) ===
 
== DefaultStyle.widgets.label  ==
 
=== setSize: func(model, w, h) ===
 
=== setText: func(model, text) ===
 
=== setImage: func(model, img) ===
 
=== setBackground: func(model, bg) ===
 
=== heightForWidth: func(w) ===
 
=== _createElement: func(name, type) ===
 
=== _deleteElement: func(name) ===
 
== DefaultStyle.widgets.line-edit  ==
A one line text input field
 
=== setSize: func(model, w, h) ===
 
=== setText: func(model, text) ===
 
 
== DefaultStyle.widgets.scroll-area  ==
 
=== setColorBackground: func ===
 
=== _newScroll: func(el, orient) ===
private
 
=== _updateScrollMetrics: func(model, dir) ===
private


== WindowButton ==
== WindowButton ==
252

edits

Navigation menu