Commit Graph

46 Commits

Author SHA1 Message Date
David Capello a6a7519178 [lua] Add possibility to modify the mouseCursor of a canvas 2022-12-26 15:33:14 -03:00
David Capello d4cefb8ba6 Fix crash double clicking a Dialog:canvas()
There were missing some setRecipient() when some messages are
converted to other kind of message (e.g. DoubleClick -> MouseDown)
2022-12-15 19:29:28 -03:00
David Capello 8b390d56fd [lua] Fix mouse position to client coordinates on mouse events 2022-12-15 16:21:24 -03:00
David Capello 0aaa9fdddf [lua] Add onmousemove/down/up events to canvas widget
At the moment very basic properties were added to the received event:
x, y, and button.
2022-12-14 22:13:49 -03:00
David Capello 25682a44d8 [lua] Add Dialog:repaint() function 2022-12-14 21:17:51 -03:00
David Capello 2cb526a19b [lua] Add new GraphicsContext type for Canvas onpaint event
We include a simple initial API for the GraphicsContext (like
stroking/filling rectangles and images).
2022-12-14 18:59:44 -03:00
David Capello 6e13e59aff [lua] Add initial version Dialog:canvas() (aseprite/api#87)
Right now it just creates a plain widget, but now we can specify
hexpand/vexpand arguments too so we can create a canvas with a fixed
size or with dynamic size (e.g. to use the whole dialog client area).

The onpaint event is not functional yet.
2022-12-14 17:33:29 -03:00
David Capello 16ca5a55db Merge branch 'main' into beta 2022-04-05 23:16:55 -03:00
David Capello 2a908f79df lua: Dialog() must return nil if there is no UI available
This avoids some crashes when running in --batch mode and some script
tries to create a Dialog().
2022-04-05 20:45:34 -03:00
David Capello 2b57fcaa6c Merge branch 'main' into beta 2021-12-01 18:14:53 -03:00
Omar Abdul Aziz b30e64648e [lua] Dialog:modify() now supports combobox options
References:
* https://github.com/aseprite/aseprite/issues/2965#issuecomment-939556356
* https://github.com/aseprite/api/issues/61
2021-11-30 18:59:57 -03:00
David Capello 06a387fd45 [lua] Fix using Dialog.bounds property with multiple windows
Fixes for:
https://community.aseprite.org/t/9277
https://steamcommunity.com/app/431730/discussions/0/3091137796288948505/
2021-06-07 17:39:12 -03:00
David Capello 35bb3af6e2 Replace all base::Bind() with lambda functions 2021-03-05 20:09:42 -03:00
David Capello 3623720dd4 Merge branch 'master' into beta 2020-08-18 11:05:37 -03:00
David Capello f44aad06db [lua] Fix Dialog:file{ save=true } so 'save' field must be =true
Before this change if we used Dialog:file{ save=false } it would show
the save version of the dialog, which didn't make sense.
2020-08-18 08:55:04 -03:00
David Capello 20d763ca4b Merge branch 'master' into beta 2020-07-30 16:48:43 -03:00
David Capello c4ed8c1450 [lua] We cannot detect existent keys with nil in a table (they aren't added to the table)
All non-existent keys return nil (and nil keys are not added when the
table is created, so we cannot even iterate the table to search for
keys like "always" or "sRGB"). The only solution is assigning a
non-nil value, e.g. { always=true }, { sRGB=true }, etc.
2020-07-28 17:40:19 -03:00
David Capello 7656627605 [lua] Fix calling onclose Dialog event when we close the app (fix https://github.com/aseprite/api/issues/28) 2020-07-28 10:35:38 -03:00
David Capello 8a3f32b47f Replace all base::Bind() with lambda functions 2020-07-03 21:51:46 -03:00
David Capello a2cdde8ec8 [lua] Add "enabled" and "visible" properties when creating new widgets
Fixed https://github.com/aseprite/api/issues/29
2020-05-15 19:03:46 -03:00
David Capello 68720424c0 [lua] Dialog:modify{} now can modify the text of a separator
Fixes https://github.com/aseprite/api/issues/27
2020-05-11 12:26:43 -03:00
Laurens Holst b3681fdbb0 [lua] Implement Dialog:modify for more properties
Support modifying the following properties:

Dialog:number { decimals }
Dialog:slider { min, max, value }
Dialog:combobox { option }
Dialog:color { color }
Dialog:shades { colors }
Dialog:file { filename }
2020-04-30 22:47:00 +02:00
Laurens Holst 1311173d97 [lua] Add missing Dialog onchange and onrelease events
Adding the following events:

Dialog:entry { onchange }
Dialog:number { onchange }
Dialog:slider { onchange, onrelease }
Dialog:combobox { onchange }
2020-04-29 23:38:15 +02:00
David Capello 48e941cb2f [lua] Add Dialog:newrow{ always } 2020-04-16 11:48:44 -03:00
David Capello ed5deb9ca3 [lua] Add Dialog:color{ onchange } event 2020-04-07 11:25:58 -03:00
David Capello 4eefb84cf3 [lua] Add possibility to change dialog title with Dialog:modify{ title=... } 2020-04-07 11:14:06 -03:00
David Capello bb8d0e7a6a [lua] Add possibility to modify a widget label and focus it 2020-04-07 11:13:30 -03:00
David Capello 8fe01b43f6 Fix typo in dialog_class.cpp 2020-04-07 11:01:46 -03:00
David Capello 8d8c116fa8 [lua] Fix some Dialog functions to convert to string implicitly 2020-04-06 14:54:11 -03:00
David Capello 55a1fa8b81 [lua] Add Dialog:modify{} method to change widget properties 2020-04-04 19:42:44 -03:00
David Capello 2c3fd2171b [lua] Fix Dialog.data for checkboxes if the last pressed button was a checkbox 2020-04-04 19:41:30 -03:00
David Capello 150ca293ef [lua] Fix checking for missing fields on tables in Dialog methods
We've to use LUA_TNIL instead of LUA_TNONE.
2020-04-04 19:40:52 -03:00
David Capello 32fd67e187 [lua] Add ev.button property onclick of shades widget 2020-03-27 16:14:00 -03:00
David Capello c9b330ab65 lua: Added Dialog:shades{} widget
Also ColorShades is a little more generic now (doesn't depends so much
on the ColorBar).
2019-12-16 21:17:12 -03:00
David Capello 2b1903ee02 lua: Add Dialog{ title, onclose } constructor 2019-12-13 10:23:22 -03:00
David Capello 484de6bd3a lua: Fix memory leak of dialogs with callbacks pointing to itself
Now we store the callbacks in a table that depends of the lifetime of
the dialog (instead of the global registry), so when the dialog is not
used anymore/closed, the whole "island" of objects (dialog +
callbacks) is GC'd.
2019-12-12 09:13:21 -03:00
David Capello ad1a39714e [lua] Add Image:resize() function
Closes: https://community.aseprite.org/t/3633
2019-08-13 18:16:30 -03:00
David Capello 6c7f1ff05b lua: Add "bounds" parameter to Dialog:show() function 2019-07-12 16:44:54 -03:00
David Capello 568aadbfc8 lua: invalidate Dialog() after changing its bounds 2019-07-12 16:42:43 -03:00
David Capello e0e83f0d40 Add Dialog:file() (#1997, fix aseprite/api#7) 2019-02-13 16:15:04 -03:00
David Capello 74b2423070 lua: Add "focus" property for Dialog widgets (mainly button and entry) 2019-01-10 16:20:11 -03:00
David Capello 4fb260d265 lua: Add Dialog.bounds property 2018-11-29 09:46:37 -03:00
David Capello f7a07b5a09 lua: Call Dialog button onclick callback with protected lua_pcall() 2018-11-21 17:42:12 -03:00
David Capello 7029e05dc4 lua: Avoid crashes executing transactions without an active sprite
This is true even for background Dialogs with buttons that will
try to create a transaction for a nil app.activeSprite.

With this change we introduced a new way to handle the app::Console window,
it'll be alive almost the entire execution of the program (so if we
close it, it's hidden, but then will appear in the same location if
it's open again, and the text is cleared).
2018-11-20 19:42:53 -03:00
David Capello 254a866b9f Fix compilation when ENABLE_UI is not defined 2018-10-26 08:50:13 -03:00
David Capello bccd3f1bf8 lua: add Dialog() 2018-10-11 12:01:21 -03:00