Canvas Nasal API: Difference between revisions

Jump to navigation Jump to search
2,986 bytes removed ,  14 January 2017
no edit summary
(Add methods of class Window)
No edit summary
Line 4: Line 4:


See inside the current (Git) API {{fgdata source|Nasal/canvas/api.nas|text=here}}.
See inside the current (Git) API {{fgdata source|Nasal/canvas/api.nas|text=here}}.
For the Canvas GUI API see [[Canvas GUI API]]


== Canvas ==
== Canvas ==
Line 501: Line 503:
=== addSegment ===
=== addSegment ===
?
?
== Window ==
=== new: func(size, type = nil, id = nil) ===
'''size:''' vector [x,y], initial size of the window
'''type:''' ? set property "type"
'''id:''' ? used in var ghost = _newWindowGhost(id);
Constructor to create a new instance of canvas.Window
'''returns:''' Window object
=== del: func ===
Destructor to clean up. Canvas will not be deleted if it has other "placements"
=== setTitle: func(title) ===
'''title:''' string
Set property "title" (e.g. text on the titlebar)
'''returns:''' Window object (me)
=== createCanvas: func() ===
Create the canvas to be used for this Window, add placement and mousedown listener.
'''returns:''' The new canvas
=== setCanvas: func(canvas_) ===
'''canvas_''': canvas object
Replace canvas of this window with '''canvas_''' and remove onRezize method so window cannot be resized anymore.
=== getCanvas: func(create = 0) ===
'''create:''' bool, create canvas for this window if it does not exist
'''returns:''' canvas object of this window
=== getCanvasDecoration: func() ===
'''returns:''' canvas object of the window decoration (?)
=== setLayout: func(l) ===
'''l''' (?)
Call me._ghost.setLayout(l);
'''returns:''' Window object (me)
=== setFocus: func ===
Set this window focused and tell gui class about it.
'''returns:''' Window object (me)
=== clearFocus: func ===
Clear focus from this window and tell gui class about it.
'''returns:''' Window object (me)
=== setPosition: func (arg...) ===
'''arg:''' either a vector [x, y] or two parameters x,y
Set window position to (x,y) where (0,0) is (left, top)
'''returns:''' Window object (me)
=== setSize: func(arg...) ===
'''arg:''' either a vector [width, height] or two parameters width, height
Set content-size to width, height and call me.onResize if exists.
'''returns:''' Window object (me)
=== move: func ===
'''arg:''' either a vector [x, y] or two parameters x,y
Moves window by x to the right and y down.
'''returns:''' Window object (me)
=== raise: func() ===
Update z-index and call setFocus()
'''returns:''' Window object (me)
=== onResize: func() ===
Update canvas size and view to Window.content-size
'''returns:''' Window object (me) or nil if window has no canvas.
'''Private methods'''
The following methods should NOT be called directly, they shall be used ONLY by the methods above.
=== _onStateChange: func ===
Used in setFocus(), clearFocus() and _updateDecoration().
=== _propCallback: func(child, mode) ===
Used in Window.new (m is the window object under creation):
arg is a vector [child, listener_node, mode, is_child_event]
setlistener(m._node, func m._propCallback(arg[0], arg[2]), 0, 2);
=== _handlePositionAbsolute: func(child, mode, name, index) ===
used only in _propCallback
=== _updatePos: func(index, name) ===
used only in _handlePositionAbsolute
=== _handleResize: func(child, name) ===
used only in _propCallback
=== _updateDecoration: func() ===
used only in _propCallback
=== _resizeDecoration: func() ===
used by _propCallback and _updateDecoration




250

edits

Navigation menu