Skip to content

Commit

Permalink
Big update, but still work in progress: rework class system and gener…
Browse files Browse the repository at this point in the history
…ated documentation
  • Loading branch information
osch committed Dec 10, 2023
1 parent 10e6b4c commit 80b0675
Show file tree
Hide file tree
Showing 198 changed files with 9,963 additions and 1,273 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- name: setup common
run: |
luarocks install lpath
luarocks install oocairo
luarocks --server=https://luarocks.org/dev install lpugl
luarocks --server=https://luarocks.org/dev install lpugl_cairo
Expand All @@ -49,7 +50,9 @@ jobs:
run: |
set -e
lua -v
lua src/alltests.lua src/tests
cd src
lua alltests.lua
lua doctest.lua ../doc/*md
export LUA_PATH='./?.lua;./?/init.lua;'$LUA_PATH
echo "LUA_PATH=$LUA_PATH"
lua doctest.lua
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/.files
*.trace

52 changes: 6 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ of standard widgets. So far only very simple standard widgets are provided, e.g.

## First Example

* The first example demonstrates a simple dialog using the `lwtk.TextInput` widget.
* The first example demonstrates a simple "Hello World" dialog.
The appearance of the widgets is configured in [lwtk.DefaultStyle](src/lwtk/DefaultStyle.lua).
The key bindings are configured in [lwtk.DefaultKeyBinding](src/lwtk/DefaultKeyBinding.lua).

![Screenshot example01](./example/screenshot01.png)
![Screenshot example01](./example/screenshot00.png)

```lua
local lwtk = require("lwtk")
Expand All @@ -45,67 +45,27 @@ of standard widgets. So far only very simple standard widgets are provided, e.g.
local Column = lwtk.Column
local Row = lwtk.Row
local PushButton = lwtk.PushButton
local TextInput = lwtk.TextInput
local TitleText = lwtk.TitleText
local Space = lwtk.Space

local app = Application("example01.lua")
local app = Application("example")

local function quit()
app:close()
end

local win = app:newWindow {
title = "example01",
title = "example",
Column {
id = "c1",
TitleText { text = "What's your name?" },
TextInput { id = "i1", focus = true, style = { Columns = 40 } },
TitleText { text = "Hello World!", style = { textSize = 35 } },
Row {
Space {},
PushButton { id = "b1", text = "&OK", disabled = true,
default = true },

PushButton { id = "b2", text = "&Quit", onClicked = quit },
PushButton { text = "&OK", onClicked = quit },
Space {}
}
},
Column {
id = "c2",
visible = false,
Space {},
TitleText { id = "t2", style = { TextAlign = "center" } },
Space {},
Row {
Space {},
PushButton { id = "b3", text = "&Again" },

PushButton { id = "b4", text = "&Quit", default = true,
onClicked = quit },
Space {}
}
}
}

win:childById("c1"):setOnInputChanged(function(widget, input)
widget:childById("b1"):setDisabled(input.text == "")
end)

win:childById("b1"):setOnClicked(function(widget)
win:childById("t2"):setText("Hello "..win:childById("i1").text.."!")
win:childById("c1"):setVisible(false)
win:childById("c2"):setVisible(true)
end)

win:childById("b3"):setOnClicked(function(widget)
win:childById("i1"):setText("")
win:childById("i1"):setFocus()
win:childById("c1"):setVisible(true)
win:childById("c2"):setVisible(false)
end)

win:show()

app:runEventLoop()
```

Expand Down
49 changes: 6 additions & 43 deletions doc/Application.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,16 @@
# lwtk.Application
# lwtk.Application Usage

TODO

<!-- ---------------------------------------------------------------------------------------- -->
## Contents
<!-- ---------------------------------------------------------------------------------------- -->

* [Application Methods](#application-methods)
* [Application:runEventLoop()](#Application_runEventLoop)
* [Application:update()](#Application_update)

<!-- ---------------------------------------------------------------------------------------- -->
[lwtk.Application] objects are needed to control lwtk event processing and window
management for desktop applications.

[lwtk.Application]: ./gen/lwtk/Application.md

<!-- ---------------------------------------------------------------------------------------- -->
## Application Methods
<!-- ---------------------------------------------------------------------------------------- -->

* <a id="Application_runEventLoop">**`Application:runEventLoop(timeout)
`**</a>

Update by processing events from the window system.

* *timeout* - optional float, timeout in seconds

If *timeout* is given, this function will process events from the window system until
the time period in seconds has elapsed or until all window objects have been closed.

If *timeout* is `nil` or not given, this function will process events from the window system
until all window objects have been closed.

## Contents
<!-- ---------------------------------------------------------------------------------------- -->

* <a id="Application_update">**`Application:update(timeout)
`**</a>
TODO

Update by processing events from the window system.

* *timeout* - optional float, timeout in seconds

If *timeout* is given, this function will wait for *timeout* seconds until
events from the window system become available. If *timeout* is `nil` or not
given, this function will block indefinitely until an event occurs.

As soon as events are available, all events in the queue are processed and this function
returns `true`.

If *timeout* is given and there are no events available after *timeout*
seconds, this function will return `false`.

<!-- ---------------------------------------------------------------------------------------- -->

Expand Down
Loading

0 comments on commit 80b0675

Please sign in to comment.