Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more pixmap and image functions #9

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
##Introduction
go-ui is a cross-platform golang ui tool kit, based on qt.

Lua code that generates the wrappers (`uiobjs.go` and `cdrv.cpp`) can be found under `make`.

The wrapper code is by far incomplete. Adding new functionality usually consists of editing or adding files under `make/ui`, and updating `make/make.lua` script, and making relevant changes in `ui` and `qtdrv`.

##System
Windows / Linux / MacOS X

Expand Down
10 changes: 10 additions & 0 deletions make/make.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ require "ui.listwidget"

require "ui.mainwindow"

require "ui.glwidget"
require "ui.sizepolicy"
require "ui.basescrollarea"
require "ui.scrollarea"

require "makelib"

function make()
Expand Down Expand Up @@ -125,6 +130,11 @@ function make()

def(mainwindow)

def(glwidget)
def(sizepolicy)
def(basescrollarea)
def(scrollarea)

end_def()

local ui = io.open("../ui/uiobjs.go","w")
Expand Down
22 changes: 22 additions & 0 deletions make/ui/basescrollarea.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module("basescrollarea")

name = "baseScrollArea"
base = "Widget"

funcs = [[
* CornerWidget() (w IWidget)
* HorizontalScrollBar() (s *ScrollBar)
* VerticalScrollBar() (s *ScrollBar)
* Viewport() (w IWidget)
]]


qtdrv = {
inc = "<QAbstractScrollArea>",
name = "QAbstractScrollArea *",

CornerWidget = "cornerWidget",
HorizontalScrollBar = "horizontalScrollBar",
VerticalScrollBar = "verticalScrollBar",
Viewport = "viewport",
}
2 changes: 1 addition & 1 deletion make/ui/dialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Accept = "accept",
Reject = "reject",

OnAccepted = [[
QObject::connect(self,SIGNAL(acceped()),drvNewSignal(self,a1,a2),SLOT(call()));
QObject::connect(self,SIGNAL(accepted()),drvNewSignal(self,a1,a2),SLOT(call()));
]],

OnRejected = [[
Expand Down
60 changes: 60 additions & 0 deletions make/ui/glwidget.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module("glwidget")

name = "GLWidget"
base = "Widget"

funcs = [[
+ Init()
DeleteTexture(id uint)
DoneCurrent()
DoubleBuffer() (b bool)
ConvertToGLFormat(image *Image) (glImage *Image)
SetMouseTracking(enable bool)
RenderText(x int, y int, z int, str string, font *Font)
UpdateGL()
UpdateOverlayGL()
* OnInitializeGL(fn func())
* OnInitializeOverlayGL(fn func())
* OnPaintGL(fn func())
* OnPaintOverlayGL(fn func())
* OnResizeGL(fn func(int,int))
* OnResizeOverlayGL(fn func(int,int))
]]

qtdrv = {
inc = "\"gldrv.h\"",
name = "QGLWidgetCustom *",

Init = [[
drvNewObj(a0,new QGLWidgetCustom);
]],

DeleteTexture = "deleteTexture",
DoneCurrent = "doneCurrent",
DoubleBuffer = "doubleBuffer",
ConvertToGLFormat = "convertToGLFormat",
SetMouseTracking = "setMouseTracking",
RenderText = "renderText",
UpdateGL = "updateGL",
UpdateOverlayGL = "updateOverlayGL",

OnInitializeGL = [[
QObject::connect(self,SIGNAL(initializeGLSignal()),drvNewSignal(self,a1,a2),SLOT(call()));
]],
OnPaintGL = [[
QObject::connect(self,SIGNAL(paintGLSignal()),drvNewSignal(self,a1,a2),SLOT(call()));
]],
OnResizeGL = [[
QObject::connect(self,SIGNAL(resizeGLSignal(int,int)),drvNewSignal(self,a1,a2),SLOT(call(int,int)));
]],

OnInitializeOverlayGL = [[
QObject::connect(self,SIGNAL(initializeOverlayGLSignal()),drvNewSignal(self,a1,a2),SLOT(call()));
]],
OnPaintOverlayGL = [[
QObject::connect(self,SIGNAL(paintOverlayGLSignal()),drvNewSignal(self,a1,a2),SLOT(call()));
]],
OnResizeOverlayGL = [[
QObject::connect(self,SIGNAL(resizeOverlayGLSignal(int,int)),drvNewSignal(self,a1,a2),SLOT(call(int,int)));
]],
}
3 changes: 2 additions & 1 deletion make/ui/image.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ funcs = [[
@ Size() (sz Size)
@ Rect() (rc Rect)
Fill(color uint)

Scaled(width int, height int, aspectRatioMode AspectRatioMode, transformMode TransformationMode) (image *Image)
]]


Expand All @@ -37,4 +37,5 @@ Depth = "depth",
Size = "size",
Rect = "rect",
Fill = "fill",
Scaled = "scaled",
}
20 changes: 20 additions & 0 deletions make/ui/label.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ funcs = [[
@ TextFormat() (format int)
@ SetPixmap(pixmap *Pixmap)
@ Pixmap() (pixmap *Pixmap)
@ SetScaledContents(b bool)
@ HasScaledContents() (b bool)
@ SetOpenExternalLinks(b bool)
@ OpenExternalLinks() (b bool)
@ SetAlignment(a Alignment)
@ Alignment() (a Alignment)
@ SetIndent(i int)
@ Indent() (i int)
@ SetMargin(i int)
@ Margin() (i int)
* OnLinkActivated(fn func(string))
]]

Expand Down Expand Up @@ -47,6 +57,16 @@ drvSetInt(a1,self->textFormat());
]],
SetPixmap = "setPixmap",
Pixmap = "pixmap",
SetScaledContents = "setScaledContents",
HasScaledContents = "hasScaledContents",
SetOpenExternalLinks = "setOpenExternalLinks",
OpenExternalLinks = "openExternalLinks",
SetAlignment = "setAlignment",
Alignment = "alignment",
SetIndent = "setIndent",
Indent = "indent",
SetMargin = "setMargin",
Margin = "margin",

OnLinkActivated = [[
QObject::connect(self,SIGNAL(linkActivated(QString)),drvNewSignal(self,a1,a2),SLOT(call(QString)));
Expand Down
26 changes: 23 additions & 3 deletions make/ui/pixmap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ funcs = [[
@ HasAlpha() (b bool)
@ HasAlphaChannel() (b bool)
@ IsNull() (b bool)

@ Width() (width int)
@ Height() (height int)
Scaled(width int, height int, aspectRatioMode AspectRatioMode, transformMode TransformationMode) (pixmap *Pixmap)
ScaledToHeight(height int, transformMode TransformationMode) (pixmap *Pixmap)
ScaledToWidth(width int, transformMode TransformationMode) (pixmap *Pixmap)
ToImage() (image *Image)
Load(fileName string) (b bool)
Save(fileName string, format quality int) (b bool)
Fill(clr color.Color)
]]


Expand All @@ -41,12 +49,24 @@ if (pixmap.loadFromData(drvGetByteArray(a1))) {
Close = [[
drvDelPixmap(a0,self);
]],

Depth = "depth",
Size = "size",
Rect = "rect",
HasAlpha = "hasAlpha",
HasAlphaChannel = "hasAlphaChannel",
IsNull = "isNull",

Width = "width",
Height = "height",
Scaled = "scaled",
ScaledToHeight = "scaledToHeight",
ScaledToWidth = "scaledToWidth",
Scroll = "scroll",
ToImage = "toImage",
Load = [[
drvSetBool(a1, self->load(drvGetString(a0)));
]],
Save = [[
drvSetBool(a3, self->save(drvGetString(a1), 0, drvGetInt(a2)));
]],
Fill = "fill",
}
36 changes: 36 additions & 0 deletions make/ui/scrollarea.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module("scrollarea")

name = "ScrollArea"
base = "baseScrollArea"

funcs = [[
+ Init()
@ SetAlignment(a Alignment)
@ Alignment() (a Alignment)
@ SetWidget(w IWidget)
@ Widget() (w IWidget)
@ SetWidgetResizable(b bool)
@ WidgetResizable() (b bool)
@ TakeWidget() (w IWidget)
EnsureVisible(x int, y int, xmargin int, ymargin int)
EnsureWidgetVisible(w IWidget, xmargin int, ymargin int)
]]

qtdrv = {
inc = "<QScrollArea>",
name = "QScrollArea *",

Init = [[
drvNewObj(a0,new QScrollArea());
]],

SetAlignment = "setAlignment",
Alignment = "alignment",
SetWidget = "setWidget",
Widget = "widget",
SetWidgetResizable = "setWidgetResizable",
WidgetResizable = "widgetResizable",
TakeWidget = "takeWidget",
EnsureVisible = "ensureVisible",
EnsureWidgetVisible = "ensureWidgetVisible",
}
40 changes: 40 additions & 0 deletions make/ui/sizepolicy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module("sizepolicy")

name = "SizePolicy"
base = "object"

unmap = true

funcs = [[
+ Init()
+ InitWithPolicy(horizontal SizePolicyPolicy, vertical SizePolicyPolicy, control SizePolicyControlType)
- Close()
@ HorizontalPolicy() (policy SizePolicyPolicy)
@ SetHorizontalPolicy(policy SizePolicyPolicy)
@ VerticalPolicy() (policy SizePolicyPolicy)
@ SetVerticalPolicy(policy SizePolicyPolicy)
@ HasHeightForWidth() (b bool)
Transpose()
]]


qtdrv = {
inc = "<QSizePolicy>",
name = "QSizePolicy *",

Init = [[
drvNewObj(a0, new QSizePolicy());
]],
InitWithPolicy = [[
drvNewObj(a0, new QSizePolicy(drvGetSizePolicyPolicy(a1),drvGetSizePolicyPolicy(a2),drvGetSizePolicyControlType(a3)));
]],
Close = [[
drvDelObj(a0,self);
]],
HorizontalPolicy = "horizontalPolicy",
SetHorizontalPolicy = "setHorizontalPolicy",
VerticalPolicy = "verticalPolicy",
SetVerticalPolicy = "setVerticalPolicy",
HasHeightForWidth = "hasHeightForWidth",
Transpose = "transpose",
}
6 changes: 5 additions & 1 deletion make/ui/widget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ funcs = [[
@ SetUpdatesEnabled(b bool)
@ UpdatesEnabled() (b bool)
@ IsActivateWindow() (b bool)
ActivateWindow()
@ ActivateWindow()
@ SetSizePolicy(policy *SizePolicy)
@ SizePolicy() (policy *SizePolicy)
Done()
Update()
Repaint()
Expand Down Expand Up @@ -154,6 +156,8 @@ SetUpdatesEnabled = "setUpdatesEnabled",
UpdatesEnabled = "updatesEnabled",
IsActivateWindow = "isActiveWindow",
ActivateWindow = "activateWindow",
SetSizePolicy = "setSizePolicy",
SizePolicy = "sizePolicy",
Done = "close",
Update = "update",
Repaint = "repaint",
Expand Down
Loading