mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
added ReadMe and getChildren/addChild methods
This commit is contained in:
parent
bbca9b5a3e
commit
43fddb5869
46
README.md
Normal file
46
README.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Pop.Box
|
||||||
|
|
||||||
|
*Do not mix with [Cola][1].*
|
||||||
|
|
||||||
|
Pop.Box is a GUI library for use in the [LÖVE][2] engine, designed to be easy to
|
||||||
|
use and require as little code as possible to set up. It is primarily designed
|
||||||
|
to make it easy to experiment with GUIs during development.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Quickly set up and align GUI elements.
|
||||||
|
- Fully customizable alignment / styling.
|
||||||
|
- Moving/resizing elements takes alignment into account.
|
||||||
|
- Extensible: Make your own elements, skins, extensions, and everything is
|
||||||
|
automatically loaded.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The basics:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local pop = require "pop"
|
||||||
|
-- define LÖVE callbacks here (update, draw, textinput, mouse/key events)
|
||||||
|
local window = pop.window():align("center"):setTitle("Welcome!")
|
||||||
|
window:addChild(pop.text("Welcome to Pop.Box()!"))
|
||||||
|
```
|
||||||
|
|
||||||
|
For more examples, see the code in `demo`. For documentation, see `docs`.
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
|
||||||
|
**Note**: Docs not written just yet. Will be soon.
|
||||||
|
|
||||||
|
- [Pop Module][3] (The main module/interface.)
|
||||||
|
- [Elements][4] (Basic features of elements/types of elements.)
|
||||||
|
- [Skins][5] (A basic system for quickly applying settings to many elements.)
|
||||||
|
- [Extensions][7] (A way to load custom code in.)
|
||||||
|
- [Drawables][6] (Reference for what can be used as a background/color.)
|
||||||
|
|
||||||
|
[1]: https://en.wikipedia.org/wiki/Cola_(programming_language)
|
||||||
|
[2]: https://love2d.org/
|
||||||
|
[3]: ./docs/Pop.md
|
||||||
|
[4]: ./docs/Elements.md
|
||||||
|
[5]: ./docs/Skins.md
|
||||||
|
[6]: ./docs/Drawables.md
|
||||||
|
[7]: ./docs/Extensions.md
|
@ -43,6 +43,9 @@ class element
|
|||||||
|
|
||||||
return @
|
return @
|
||||||
|
|
||||||
|
getChildren: =>
|
||||||
|
return @child
|
||||||
|
|
||||||
move: (x, y) =>
|
move: (x, y) =>
|
||||||
if x
|
if x
|
||||||
@x = @x + x
|
@x = @x + x
|
||||||
|
@ -47,6 +47,7 @@ class window extends element
|
|||||||
@setSize 100, 80
|
@setSize 100, 80
|
||||||
|
|
||||||
-- our child elements are still child elements
|
-- our child elements are still child elements
|
||||||
|
--TODO change title to be a child of head ?
|
||||||
@child = {
|
@child = {
|
||||||
@head, @title, @window
|
@head, @title, @window
|
||||||
}
|
}
|
||||||
@ -108,6 +109,15 @@ class window extends element
|
|||||||
|
|
||||||
return @
|
return @
|
||||||
|
|
||||||
|
addChild: (child) =>
|
||||||
|
@window.child[#@window.child+1] = child
|
||||||
|
child.parent = @window
|
||||||
|
|
||||||
|
return @
|
||||||
|
|
||||||
|
getChildren: =>
|
||||||
|
return @window.child
|
||||||
|
|
||||||
--update: =>
|
--update: =>
|
||||||
-- if selected, set position based on current mouse position relative to position it was when mousepressed
|
-- if selected, set position based on current mouse position relative to position it was when mousepressed
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user