Add some documentation
This commit is contained in:
parent
dff80a6942
commit
2fd060184e
1 changed files with 156 additions and 1 deletions
157
README.md
157
README.md
|
@ -1,6 +1,7 @@
|
||||||
# QUICKIE
|
# QUICKIE
|
||||||
|
|
||||||
Quickie is an [immediate mode gui][IMGUI] library for [LÖVE][LOVE]
|
Quickie is an [immediate mode gui][IMGUI] library for [LÖVE][LOVE]. Initial inspiration came from the article [Sol on Immediate Mode GUIs (IMGUI)][Sol]. You should check it out to understand how Quickie works.
|
||||||
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
@ -49,8 +50,162 @@ Quickie is an [immediate mode gui][IMGUI] library for [LÖVE][LOVE]
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
### Modules
|
||||||
|
|
||||||
|
`gui = require 'quickie'`
|
||||||
|
|
||||||
|
* Main module. Includes all other modules.
|
||||||
|
|
||||||
|
`gui.core = require 'quickie.core'`
|
||||||
|
|
||||||
|
* Core functionality: Input, display, widget internals, ...
|
||||||
|
|
||||||
|
`gui.style = require 'quickie.style-default'`
|
||||||
|
|
||||||
|
* Default widget style. May be replaced by custom style.
|
||||||
|
|
||||||
|
`gui.Button = require 'quickie.button'`
|
||||||
|
|
||||||
|
* Button widget.
|
||||||
|
|
||||||
|
`gui.Slider = require 'quickie.slider'`
|
||||||
|
|
||||||
|
* Slider widget.
|
||||||
|
|
||||||
|
`gui.Slider2D = require 'quickie.slider2d'`
|
||||||
|
|
||||||
|
* 2D slider widget.
|
||||||
|
|
||||||
|
`gui.Label = require 'quickie.label'`
|
||||||
|
|
||||||
|
* Label widget.
|
||||||
|
|
||||||
|
`gui.Input = require 'quickie.input'`
|
||||||
|
|
||||||
|
* Input box widget.
|
||||||
|
|
||||||
|
`gui.Checkbox = require 'quickie.checkbox'`
|
||||||
|
|
||||||
|
* Check box widget.
|
||||||
|
|
||||||
|
### Widgets
|
||||||
|
|
||||||
|
* Widgets are functions; they should return `true` if the state has changed.
|
||||||
|
* Widgets don't manage state. That's your job.
|
||||||
|
* Calling a widget function creates the widget for the current frame only.
|
||||||
|
* Widgets will be shown using `gui.core.draw()`. See the example above.
|
||||||
|
|
||||||
|
#### Button
|
||||||
|
|
||||||
|
```lua
|
||||||
|
function gui.Button(label, x,y,w,h, widgetHit, draw)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
|
||||||
|
* *string* `label`: Button label.
|
||||||
|
* *numbers* `x,y,w,h`: Hit box.
|
||||||
|
* *function* `widgetHit`: Custom mouse hit function *(optional)*.
|
||||||
|
* *function* `draw`: Custom widget style *(optional)*.
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
* `true` if button was activated.
|
||||||
|
|
||||||
|
**Hit test function prototype:**
|
||||||
|
|
||||||
|
```lua
|
||||||
|
function widgetHit(mouse_x, mouse_y, x,y,w,h)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Style function prototype:**
|
||||||
|
|
||||||
|
```lua
|
||||||
|
function draw(state, title, x,y,w,h)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Slider
|
||||||
|
|
||||||
|
```lua
|
||||||
|
function gui.Slider(info, x,y,w,h, widgetHit, draw)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
|
||||||
|
* *table* `info`: Widget info table. Fields:
|
||||||
|
* *number* `info.value`: The slider value *(required)*.
|
||||||
|
* *number* `info.min`: Minimum value *(optional, default = 0)*.
|
||||||
|
* *number* `info.max`: Maximum value *(optional, default = max(value, 1))*.
|
||||||
|
* *number* `info.step`: Step for keyboard input *(optional, default = (max-min)/50)*.
|
||||||
|
* *boolean* `info.vertical`: Flags slider as vertical *(optional, default = false)*.
|
||||||
|
* *numbers* `x,y,w,h`: Hit box.
|
||||||
|
* *function* `widgetHit`: Custom mouse hit function *(optional)*.
|
||||||
|
* *function* `draw`: Custom widget style *(optional)*.
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
* `true` if slider value changed.
|
||||||
|
|
||||||
|
**Hit test function prototype:**
|
||||||
|
|
||||||
|
```lua
|
||||||
|
function widgetHit(mouse_x, mouse_y, x,y,w,h)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Style function prototype:**
|
||||||
|
|
||||||
|
```lua
|
||||||
|
function draw(state, fraction, x,y,w,h, vertical)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Slider2D
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
#### Label
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
#### Input
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
#### Checkbox
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
### Core functions
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright (c) 2012 Matthias Richter
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name(s) of the above copyright holders
|
||||||
|
shall not be used in advertising or otherwise to promote the sale, use or
|
||||||
|
other dealings in this Software without prior written authorization.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
[LOVE]: http://love2d.org
|
[LOVE]: http://love2d.org
|
||||||
[IMGUI]: http://www.mollyrocket.com/forums/viewforum.php?f=10
|
[IMGUI]: http://www.mollyrocket.com/forums/viewforum.php?f=10
|
||||||
|
[Sol]: http://sol.gfxile.net/imgui/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue