aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/GuiLua.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-19 12:39:35 +1000
committerDavid Walter Seikel2014-03-19 12:39:35 +1000
commit524473f881d6b89bf85f7d5e2bd7b19a5a8ab18a (patch)
tree659efe693807166b7ed774f3b7a7e476b6617efd /ClientHamr/GuiLua/GuiLua.c
parentMore design notes. (diff)
downloadSledjHamr-524473f881d6b89bf85f7d5e2bd7b19a5a8ab18a.zip
SledjHamr-524473f881d6b89bf85f7d5e2bd7b19a5a8ab18a.tar.gz
SledjHamr-524473f881d6b89bf85f7d5e2bd7b19a5a8ab18a.tar.bz2
SledjHamr-524473f881d6b89bf85f7d5e2bd7b19a5a8ab18a.tar.xz
Added some GuiLua test source files, and lots of comments in GuiLua.c.
Diffstat (limited to 'ClientHamr/GuiLua/GuiLua.c')
-rw-r--r--ClientHamr/GuiLua/GuiLua.c272
1 files changed, 272 insertions, 0 deletions
diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c
new file mode 100644
index 0000000..3086889
--- /dev/null
+++ b/ClientHamr/GuiLua/GuiLua.c
@@ -0,0 +1,272 @@
1/* GuiLua - a GUI library that implements matrix-RAD style stuff.
2
3Provides the skang and widget Lua packages.
4
5This should be a library in the end, but for now it's just an
6application that is a test bed for what goes into the library. In the
7initial intended use case, several applications will be using this all at
8once, with one central app hosting all the GUIs.
9
10Basically this should deal with "windows" and their contents. A
11"window" in this case is hosted in the central app as some sort of
12internal window, but the user can "tear off" those windows, then they
13get their own OS hosted window. This could be done by the hosting app
14sending the current window contents to the original app as a skang file.
15
16Between the actual GUI and the app might be a socket, or a stdin/out
17pipe. Just like matrix-RAD, this should be transparent to the app.
18Also just like matrix-RAD, widgets can be connected to variable /
19functions (C or Lua), and any twiddlings with those widgets runs the
20function / changes the variable, again transparent to the app, except
21for any registered get/set methods.
22
23This interface between the GUI and the app is "skang" files, which are
24basically Lua scripts. The GUI and the app can send skang files back
25and forth, usually the app sends actual GUI stuff, and usually the GUI
26sends variable twiddles or action calls. Usually.
27
28To start with, this will be used to support multiple apps hosting their
29windows in extantz, allowing the big viewer blob to be split up into
30modules. At some point converting LL XML based UI shit into skang could
31be done. Also, this should be an exntension to LuaSL, so in-world
32scripts can have a poper GUI for a change.
33
34
35NOTES and TODOs -
36
37See if I can use LuaJIT FFI here. Since this will be a library, and
38skang apps could be writte nin C or Lua, perhaps writing this library to
39be FFI friendly instead of the usual Lua C binding might be the way to
40go?
41
42For the "GUI hosted in another app" case, we will need some sort of
43internal window manager running in that other app.
44
45This might end up running dozens of Lua scripts, and could use the LuaSL
46Lua script running system. Moving that into this library might be a
47sane idea I think? Or prehaps a separate library that both LuaSL and
48GuiLua use?
49
50Raster wants a method of sending Lua tables around as edje messages.
51Between C, Edje, Edje Lua, and Lua. Sending between threads, and across
52sockets. Using a new edje message type, or eet for sockets, was
53suggested, but perhaps Lua skang is a better choice?
54
55Somehow access to the edje_lua2.c bindings should be provided. And
56bindings to the rest of EFL when they are done. Assuming the other EFL
57developers do proper introspection stuff, or let me do it.
58
59The generic Lua binding helper functions I wrote for edje?lua2.c could
60be used here as well, and expanded as discussed on the E devs mailing
61list. This would include the thread safe Lua function stuff copied
62into the README.
63
64There will eventually be a built in editor, like the zen editor from
65matrix-RAD. It might be a separate app.
66
67NAWS should probably live in here to. If I ever get around to writing
68it. lol
69
70The pre tokenized widget structure thingy I had planned in the
71matrix-RAD TODO just wont work, as it uses symbols. On the other hand,
72we will be using Lua tables anyway. B-)
73
74*/
75
76
77/* coordinates and sizes
78
79Originally skang differentiated between pixels and character cells,
80using plain integers to represent pixels, and _123 to represent
81character cells. The skang TODO wanted to expand that to percentages
82and relative numbers. We can't use _123 in Lua, so some other method
83needs to be used. Should include those TODO items in this new design.
84
85Specifying character cells should be done as strings - "123"
86
87Percentages can be done as small floating point numbers between 0 and 1,
88which is similar to Edje. Since Lua only has a floating point number
89type, both 0 and 1 should still represent pixels / character cells -
90
910.1, 0.5, "0.2", "0.9"
92
93Relative numbers could be done as strings, with the widget to be
94relative to, a + or -, then the number. This still leaves the problem
95of telling if the number is pixels or character cells. Also, relative
96to what part of the other widget? Some more thought needs to be put
97into this.
98
99*/
100
101
102/* thing package
103
104matrix-RAD had Thing as the base class of everything. Lua doesn't have
105inheritance as such, but an inheritance structure can be built using
106Lua's meta language capabilities. I think we still need this sort of
107thing. Java inheritance and interfaces where used. There's quite a few
108variations of OO support has been written for Lua, maybe some of that
109could be used? http://lua-users.org/wiki/ObjectOrientedProgramming
110
111Each "users session" (matrix-RAD term that came from Java
112applets/servlets) has a ThingSpace, which is a tree that holds
113everything else. It holds the class cache, commands, loaded modules,
114variables and their values, widgets and their states. In matrix-RAD I
115built BonsiaTree and LeafLike, for the old FDO system I built dumbtrees.
116Perhaps some combination of the two will work here?
117
118Get/set variables would be done here, though the widget package, for
119instance, would override this to deal with the UI side, and call the
120parents function to deal with the variable side -
121
122foo:set('stuff')
123bar = foo:get()
124
125Also, since skang Lua scripts should be defined as modules, we can use
126module semantics -
127
128local other = require('otherPackageName')
129other.foo = 'stuff'
130bar = other.foo
131
132*/
133
134
135/* stuff & squeal packages
136
137In matrix-RAD Stuff took care of multi value Things, like database rows.
138I'm not sure this is needed here, since Lua has nice tables. B-)
139
140Squeal was the database driver interface for SquealStuff, the database
141version of Stuff. Maybe we could wrap esskyuehl? Not really in need of
142database stuff for now, but should keep it in mind.
143
144*/
145
146
147/* skang package
148
149In here should live all the internals of matrix-RAD that don't
150specifically relate to widgets. This would include the "window" though.
151
152skang.module(Evas)
153skang.module(Elementary)
154skang.load('some/skang/file.skang')
155
156This package is also what "apps" that use the system should "inherit"
157from, in the same way matrix-RAD apps did. Skang "apps" could be Lua
158modules. They could also be C code, like the extantz modules are likely
159to be. Skang "apps" would automatically be associated with skang files
160of the same name. So a Lua skang "app" could look like this -
161
162local skang = require('skang')
163local result = {};
164result.author = 'onefang'
165result.version = '0.72 alpha 2004-11-19 16:28:00'
166local bar
167-- The first argument would be the name of a local variable / method. Which could be accessed via _G?
168-- Not sure if we could use a global bar, AND use it directly.
169result.bar = skang.newParam('bar', "Required", "Shortcut", "Default", "Help text")
170result.func = skang.newCommand('arg1_type,arg2_type', 'Help Text', function (arg1, arg2)
171... do something here ...
172end)
173
174... do something here ...
175
176return result;
177
178
179A basic skang file could look like this -
180
181#!skang myApp.skang
182-- There's an implied local this = require('myApp')
183-- There's an implied local skang = require('skang')
184local widget = require('EvasWidgets')
185local other = require('otherPackageName')
186skang.clear
187skang.window(200, 200, "G'day planet.")
188quitter = widget.button('Quit', 0.5, 0.5, 0.5, 0.5)
189quitter:action('quit') -- 'quit' is looked up in ThingSpcae.commands, and translated into the Lua 'skang.quit()'.
190other.foo = 'stuff'
191this.bar = other.foo
192this.func(1, 'two')
193
194The skang command (written in C) would strip off the first line, add the
195two implied lines, then run it as Lua. The skang.load() command would
196do the same. So that skang C comand would just pass the file name to
197skang.load() in this library. B-)
198
199
200The old skang argument types are -
201
202 {"name", "java.lang.String"},
203 {"action", "java.lang.String"},
204 {"type", "java.lang.String"},
205 {"data", "java.lang.String"},
206 {"URL", "java.lang.String"},
207 {"file", "java.lang.String"},
208 {"method", "java.lang.String"},
209 {"lx", "java.lang.String"},
210 {"ly", "java.lang.String"},
211 {"lw", "java.lang.String"},
212 {"lh", "java.lang.String"},
213 {"normal", "java.lang.String"},
214 {"ghost", "java.lang.String"},
215 {"active", "java.lang.String"},
216 {"toggle", "java.lang.String"},
217 {"boolean","java.lang.Boolean"},
218 {"number", "java.lang.Integer"},
219 {"int", "java.lang.Integer"},
220 {"x", "java.lang.Integer"},
221 {"y", "java.lang.Integer"},
222 {"w", "java.lang.Integer"},
223 {"h", "java.lang.Integer"},
224 {"r", "java.lang.Integer"},
225 {"g", "java.lang.Integer"},
226 {"b", "java.lang.Integer"},
227 {"alpha", "java.lang.Integer"},
228 {"acl", "net.matrix_rad.security.ACL"},
229
230*/
231
232
233/* widget package
234
235Should include functions for actually dealing with widgets, plus a way
236of creating widgets via introspection. Should also allow access to
237widget internals via table access. Lua code could look like this -
238
239foo = widget.label(0, "0.1", 0.5, 0, 'Text goes here :")
240-- Method style.
241foo:colour(255, 255, 255, 0, 0, 100, 255, 0)
242foo:hide()
243foo:action("skang.load(some/skang/file.skang)")
244-- Table style.
245foo.action = "skang.load('some/skang/file.skang')"
246foo.colour.r = 123
247foo.look('some/edje/file/somewhere.edj')
248foo.help = 'This is a widget for labelling some foo.'
249
250For widgets with "rows", which was handled by Stuff in skang, we could
251maybe use the Lua concat operator via metatable. I think that works by
252having the widget (a table) on one side of the concat or the other, and
253the metatable function gets passed left and right sides, then must
254return the result. Needs some experimentation, but this might look like
255this -
256
257this.bar = this.bar .. 'new choice'
258this.bar = 'new first choice' .. this.bar
259
260*/
261
262
263
264/* introspection
265
266As detailed in README, EFL introspection doesn't seem to really be on
267the radar, but I might get lucky, or I might have to write it myself.
268For quick and dirty early testing, I'll probably write a widget package
269that has hard coded mappings between some basic "label", "button", etc.
270and ordinary elementary widgets. Proper introspection can come later.
271
272*/