Skip to content

Commit

Permalink
make: add sync flag
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Jul 18, 2012
1 parent 9ad2713 commit ad7e0b0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 37 deletions.
4 changes: 3 additions & 1 deletion examples/minimal.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"fmt"
"github.com/visualfc/go-ui/ui"
)

func main() {
func main() {
fmt.Println(ui.Version())
ui.Main(func() {
w := ui.NewWidget()
w.SetWindowTitle(ui.Version())
Expand Down
38 changes: 22 additions & 16 deletions examples/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,27 @@ func main() {
}

func ui_main() {
fmt.Println("vfc/ui")
ui.OnInsertObject(func(v interface{}) {
fmt.Println("add item", v)
})
ui.OnRemoveObject(func(v interface{}) {
fmt.Println("remove item", v)
})
w := new(MainWindow).Init()
defer w.Close()

w.SetSizev(400, 300)
w.OnCloseEvent(func(e *ui.CloseEvent) {
fmt.Println("close", e)
})
w.Show()
exit := make(chan bool)
go func() {
fmt.Println("vfc/ui")
ui.OnInsertObject(func(v interface{}) {
fmt.Println("add item", v)
})
ui.OnRemoveObject(func(v interface{}) {
fmt.Println("remove item", v)
})
w := new(MainWindow).Init()
defer w.Close()

w.SetSizev(400, 300)
w.OnCloseEvent(func(e *ui.CloseEvent) {
fmt.Println("close", e)
})
w.Show()
<- exit
}()
ui.Run()
exit <- true
}

type MyWidget struct {
Expand All @@ -213,6 +218,7 @@ func (p *MyWidget) Init() *MyWidget {
return nil
}
p.font = ui.NewFontWith("Timer", 16, 87)
p.font.SetItalic(true)
p.Widget.OnPaintEvent(func(e *ui.PaintEvent) {
p.paintEvent(e)
})
Expand Down Expand Up @@ -242,7 +248,7 @@ func (p *MyWidget) paintEvent(e *ui.PaintEvent) {
paint.SetFont(p.font)
paint.DrawLines(p.line)
paint.SetFont(p.font)
paint.DrawText(ui.Pt(100, 100), "this is a test")
paint.DrawText(ui.Pt(100, 100), "draw test")
for _, v := range p.lines {
//paint.DrawLines(v)
paint.DrawPolyline(v)
Expand Down
2 changes: 2 additions & 0 deletions make/make.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ function make()
cdrv:write("\n")
cdrv:write(table.concat(c_def.drvfunc,"\n"))
cdrv:write("\n")
cdrv:write(table.concat(c_def._drvfunc,"\n"))
cdrv:write("\n")
cdrv:close()
end

Expand Down
42 changes: 23 additions & 19 deletions make/makelib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function begin_def()
c_def.include = {}
c_def.drvenum = {}
c_def.drvfunc = {}
c_def._drvfunc = {}
c_def.enums = {}
c_def.funcs = {}

Expand Down Expand Up @@ -166,7 +167,6 @@ func registerAllClass() {
c_def.drvenum[#c_def.drvenum+1] = " DRVCLASS_NONE = 0,"

c_def.include[#c_def.include+1] = [[#include "cdrv.h"]]

c_def.drvfunc[#c_def.drvfunc+1] = [[
typedef int (*DRV_CALLBACK)(void* fn, void *a1,void* a2,void* a3,void* a4);
typedef int (*DRV_RESULT)(void* ch,int r);
Expand Down Expand Up @@ -212,9 +212,20 @@ int drv(int drvcls, int drvid, void *exp, void *a0, void* a1, void* a2, void* a3
return 1;
case -4:
pfn_drv_appmain = (DRV_APPMAIN)exp;
return 1;
case _CLASSID_APP:
return drv_app(drvid,a0,a1,a2,a3,a4,a5,a6);
return 1;]]
c_def._drvfunc[#c_def._drvfunc+1] = [[
int _drv(int drvcls, int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6)
{
switch(drvcls) {]]

end

function end_def()
go_def.drvenum[#go_def.drvenum+1] = ")"
go_def.newobj[#go_def.newobj+1] = "}"
c_def.drvenum[#c_def.drvenum+1] = " DRVCLASS_LAST"
c_def.drvenum[#c_def.drvenum+1] = "};"
c_def.drvfunc[#c_def.drvfunc+1] = [[
default:
QMetaObject::invokeMethod(theApp,"drv",
Q_ARG(int,drvcls),
Expand All @@ -230,20 +241,8 @@ int drv(int drvcls, int drvid, void *exp, void *a0, void* a1, void* a2, void* a3
return 0;
}
return 1;
}
int _drv(int drvcls, int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6)
{
switch(drvcls) {]]

end

function end_def()
go_def.drvenum[#go_def.drvenum+1] = ")"
go_def.newobj[#go_def.newobj+1] = "}"
c_def.drvenum[#c_def.drvenum+1] = " DRVCLASS_LAST"
c_def.drvenum[#c_def.drvenum+1] = "};"
c_def.drvfunc[#c_def.drvfunc+1] = [[
}]]
c_def._drvfunc[#c_def._drvfunc+1] = [[
default:
return 0;
}
Expand Down Expand Up @@ -695,7 +694,12 @@ func (p *%s) Attr(attr string) interface{} {
}
]]
c_def.funcs[#c_def.funcs+1] = table.concat(c.funcs,"\n")
c_def.drvfunc[#c_def.drvfunc+1] = string.format([[
if item.sync then
c_def.drvfunc[#c_def.drvfunc+1] = string.format([[
case %s:
return drv_%s(drvid,a0,a1,a2,a3,a4,a5,a6);]],name_cls,string.lower(name))
end
c_def._drvfunc[#c_def._drvfunc+1] = string.format([[
case %s:
return drv_%s(drvid,a0,a1,a2,a3,a4,a5,a6);]],name_cls,string.lower(name))
end
1 change: 1 addition & 0 deletions make/ui/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module("app")

name = "app"
base = "object"
sync = true

defs = [[
]]
Expand Down
1 change: 0 additions & 1 deletion qtdrv/cdrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3781,7 +3781,6 @@ int drv(int drvcls, int drvid, void *exp, void *a0, void* a1, void* a2, void* a3
}
return 1;
}

int _drv(int drvcls, int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6)
{
switch(drvcls) {
Expand Down

0 comments on commit ad7e0b0

Please sign in to comment.