Golang bindings for XCGUI, Windows GUI library, DirectUI design idea.

Overview

XCGUI

version GoDoc License

项目文档   帮助文档   程序示例

介绍

English | 简体中文

DirectUI设计思想: 在窗口内没有子窗口,界面元素都是逻辑上的区域(无HWND句柄,安全,灵活), 所有UI元素都是自主开发(不受系统限制), 更加灵活的实现各种程序界面,满足不同用户的需求.

官方网站:www.xcgui.com

可视化UI设计器

使用UI设计器可以快速设计界面,节省大量代码。

uidesigner

设计器使用例子,只有这么多代码:

package main

import (
	"github.com/twgh/xcgui/app"
	"github.com/twgh/xcgui/window"
	"github.com/twgh/xcgui/xcc"
)

func main() {
	a := app.New("")
	// 添加文件搜索路径, 你运行时需要改成自己的路径,也可以使用相对路径
	a.AddFileSearchPath(`D:\GoProject\src\github.com\twgh\xcgui-example\uidesigner\res`)
	// 从zip中加载资源文件
	a.LoadResourceZip("qqmusic.zip", "resource.res", "")
	// 从zip中加载布局文件
	hWindow := a.LoadLayoutZip("qqmusic.zip", "main.xml", "", 0)
	if hWindow == 0 {
		panic("error")
	}
	// 创建窗口对象
	win := window.NewWindowByHandle(hWindow)

	// 调整布局
	win.AdjustLayout()
	// 显示窗口
	win.ShowWindow(xcc.SW_SHOW)

	a.Run()
	a.Exit()
}

获取

go get github.com/twgh/xcgui

动态链接库下载

网盘 下载地址
百度网盘 下载,提取码:wcs7
OneDrive 下载
Google Drive 下载
GIthub 下载

程序运行时需要把XCGUI.dll放到程序运行目录。

在开发时最好是放到C:\Windows\System32目录,这样就不需要频繁把dll放到不同程序的运行目录了。

简单窗口(纯代码)

SimpleWindow

package main

import (
	"github.com/twgh/xcgui/app"
	"github.com/twgh/xcgui/widget"
	"github.com/twgh/xcgui/window"
	"github.com/twgh/xcgui/xc"
	"github.com/twgh/xcgui/xcc"
)

func main() {
	// 1.初始化UI库
	a := app.New("")
	// 2.创建窗口
	win := window.NewWindow(0, 0, 466, 300, "炫彩窗口", 0, xcc.Xc_Window_Style_Default)

	// 设置窗口边框大小
	win.SetBorderSize(1, 30, 1, 1)
	// 设置窗口透明类型
	win.SetTransparentType(xcc.Window_Transparent_Shadow)
	// 设置窗口阴影
	win.SetShadowInfo(10, 255, 10, false, 0)
	// 窗口置顶
	win.SetTop()
	// 窗口居中
	win.Center()
	// 创建标签_窗口标题
	lbl_Title := widget.NewShapeText(15, 15, 56, 20, "Title", win.Handle)
	lbl_Title.SetTextColor(xc.RGB(255, 255, 255), 255)

	// 创建最小化按钮
	btn_Min := widget.NewButton(396, 10, 30, 30, "-", win.Handle)
	btn_Min.SetTextColor(xc.RGB(255, 255, 255), 255)
	btn_Min.SetType(xcc.Button_Type_Min)
	btn_Min.EnableBkTransparent(true)
	// 创建结束按钮
	btn_Close := widget.NewButton(426, 10, 30, 30, "X", win.Handle)
	btn_Close.SetTextColor(xc.RGB(255, 255, 255), 255)
	btn_Close.SetType(xcc.Button_Type_Close)
	btn_Close.EnableBkTransparent(true)

	// 3.显示窗口
	win.ShowWindow(xcc.SW_SHOW)
	// 4.运行程序
	a.Run()
	// 5.释放UI库
	a.Exit()
}

常量

xcc包里都是常量,像这样使用:xcc.Xc_Window_Style_Default

需要用到xcc包常量的参数注释都是类似这样的,复制Xc_Window_Style_xcc包里搜索即可看到相关常量注释:5eX6pD.jpg

命令介绍

xc包里的函数都是xcgui.dll里原本的函数,有一千多个函数,可以直接使用,封装好的类都在其他包里。

在某些情况下,把xc包里的原生函数与封装好的类混合起来使用会更加方便。

封装进度

这些类都是基于xc包里的一千多个函数封装的。

中文名称 包名 类名 是否封装完毕 文档
程序 app App 文档
窗口 window Window 文档
框架窗口 window FrameWindow 文档
模态窗口 window ModalWindow 文档
形状对象 widget Shape 文档
圆形形状对象 widget ShapeEllipse 文档
形状对象GIF widget ShapeGif 文档
组框形状对象 widget ShapeGroupBox 文档
直线形状对象 widget ShapeLine 文档
形状对象图片 widget ShapePicture 文档
矩形形状对象 widget ShapeRect 文档
形状对象文本 widget ShapeText 文档
表格 widget Table 文档
按钮 widget Button 文档
下拉组合框 widget ComboBox 文档
编辑框(常规, 富文本, 聊天气泡) widget Edit 文档
代码编辑框 widget Editor 文档
基础元素 widget Element 文档
列表 widget List 文档
列表框 widget ListBox 文档
弹出菜单 widget Menu 文档
进度条 widget ProgressBar 文档
静态文本连接按钮 widget TextLink 文档
布局元素 widget LayoutEle 文档
布局框架 widget LayoutFrame 文档
列表视图 widget ListView 文档
菜单条 widget MenuBar 文档
Pane元素 widget Pane 文档
滚动条 widget ScrollBar 文档
滚动视图 widget ScrollView 文档
滑动条元素 widget SliderBar 文档
标签栏元素 widget TabBar 文档
工具条 widget ToolBar 文档
列表树元素 widget Tree 文档
日期时间 widget DateTime 文档
月历卡片 widget MonthCal 文档
数据适配器-列表视元素 adapter AdapterListView 文档
数据适配器-单列Map-列表头(listHeader) adapter AdapterMap 文档
数据适配器-XList-XListBox adapter AdapterTable 文档
数据适配器-树元素 adapter AdapterTree 文档
背景管理器 bkmanager BkManager 文档
字体 fontx FontX 文档
图片操作 image Image 文档
列表项模板 listitemtemplate ListItemTemplate 文档
节点 listitemtemplate Node 文档
图形绘制 draw Draw 文档
XCGUI所有函数 xc 文档
XCGUI常量 xcc 文档
缓动 ease 文档
资源操作 res 文档
Issues
  • fatal error: too many callback functions

    fatal error: too many callback functions

    不停的调用XC_CallUiThread会报fatal error: too many callback functions错误

    这两个帖子好像也提到了超过2000次后会出问题 https://stackoverflow.com/questions/66864829/golang-fatal-error-too-many-callback-functions https://github.com/golang/go/issues/1912

    复现代码

    package main
    
    import (
    	"fmt"
    	"github.com/twgh/xcgui/app"
    	"github.com/twgh/xcgui/widget"
    	"github.com/twgh/xcgui/window"
    	"github.com/twgh/xcgui/xc"
    	"github.com/twgh/xcgui/xcc"
    	"time"
    )
    
    func main() {
    
    	a := app.New("")
    
    	win := window.NewWindow(0, 0, 466, 300, "炫彩窗口", 0, xcc.Xc_Window_Style_Default)
    
    	logEdit := widget.NewEdit(100, 100, 100, 100, win.Handle)
    
    	btn_test := widget.NewButton(250, 150, 50, 50, "点击", win.Handle)
    	btn_test.Event_BnClick(func(pbHandled *bool) int {
    		*pbHandled = true
    		go func() {
    			// 不断的调用会报错
    			for ;; {
    				xc.XC_CallUiThread(func(data int) int {
    					timeStyle := logEdit.AddStyleEx("微软雅黑",10, 0, xc.RGB(255, 255, 255), true)
    						logEdit.AddTextEx(fmt.Sprintf("%s: ", time.Now().Format("2006-01-02 15:04:05")), timeStyle)
    					return 0
    				}, 1)
    				time.Sleep(500 * time.Microsecond)
    			}
    		}()
    		return 0
    	})
    	// 3.显示窗口
    	win.ShowWindow(xcc.SW_SHOW)
    	// 4.运行程序
    	a.Run()
    	// 5.释放UI库
    	a.Exit()
    }
    
    
    opened by wengooooo 4
  • list无法添加列文本

    list无法添加列文本

    list无法添加列文本

    复现的代码

    package main
    
    import (
    	"fmt"
    	"github.com/twgh/xcgui/app"
    	"github.com/twgh/xcgui/widget"
    	"github.com/twgh/xcgui/window"
    	"github.com/twgh/xcgui/xcc"
    )
    
    func main() {
    
    	a := app.New("")
    
    	win := window.NewWindow(0, 0, 466, 300, "炫彩窗口", 0, xcc.Xc_Window_Style_Default)
    
    	list := widget.NewList(50, 50, 300, 300, win.Handle)
    	list.CreateAdapterHeader()
    	list.CreateAdapter()
    
    	list.AddColumnText(50, "test1", "aaa") //没有显示文本出来
    	list.AddColumnText(100, "test2", "bbb") //没有显示文本出来
    	list.AddColumnText(100, "test3", "ccc") //没有显示文本出来
    
    	for i:=0; i < 10; i++ {
    		index := list.AddItemText(fmt.Sprintf("item-%d", i))
    		list.SetItemText(index, 1, fmt.Sprintf("subitem-%d", i))
    		list.SetItemText(index, 2, fmt.Sprintf("subitem-%d", i))
    	}
    
    	win.ShowWindow(xcc.SW_SHOW)
    
    	a.Run()
    
    	a.Exit()
    }
    
    
    opened by wengooooo 3
  • XEdit_GetText获取不到结果过

    XEdit_GetText获取不到结果过

    XEdit_GetText获取不到结果,我看注释写着未实现

    opened by wengooooo 1
  • Add license scan report and status

    Add license scan report and status

    Your FOSSA integration was successful! Attached in this PR is a badge and license report to track scan status in your README.

    Below are docs for integrating FOSSA license checks into your CI:

    opened by fossabot 0
Releases(v1.0.5)
A list of Go GUI projects

(Please follow @Go100and1 for updates on this page, and all kinds of details and facts in Go). A list of Go GUI/graphics/image related projects native

null 715 Oct 19, 2021
Native Go (golang) Graphical Interface system (2D and 3D), built on GoKi tree framework

GoGi is part of the GoKi Go language (golang) full strength tree structure system (ki = 木 = tree in Japanese) package gi is a scenegraph-based 2D and

GoKi 950 Oct 25, 2021
Tiny cross-platform webview library for C/C++/Golang. Uses WebKit (Gtk/Cocoa) and Edge (Windows)

webview A tiny cross-platform webview library for C/C++/Golang to build modern cross-platform GUIs. Also, there are Rust bindings, Python bindings, Ni

webview 9k Oct 15, 2021
Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

Dear ImGui (This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addit

omar 32.4k Oct 21, 2021
Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development

Go bindings for Sciter Check this page for other language bindings (Delphi / D / Go / .NET / Python / Rust). Attention The ownership of project is tra

Terra Informatica Software, Inc 2.2k Oct 15, 2021
Windows GUI framework for Go.

gform is an easy to use Windows GUI toolkit for Go It provides two approaches to create UI. 1. Pure code. gform.Init() mainWindow := gform.NewForm(ni

Allen Dang 263 Sep 10, 2021
This project provides Go bindings for nuklear.h — a small ANSI C GUI library.

Nuklear Package nk provides Go bindings for nuklear.h — a small ANSI C gui library. See github.com/vurtun/nuklear. All the binding code has automatica

null 1.5k Oct 12, 2021
Common library for Go GUI apps on Windows

winc Common library for Go GUI apps on Windows. It is for Windows OS only. This makes library smaller than some other UI libraries for Go.

Tad Vizbaras 110 Oct 7, 2021
Platform-native GUI library for Go.

ui: platform-native GUI library for Go This is a library that aims to provide simple GUI software development in Go. It is based on my libui, a simple

Pietro Gagliardi 8k Oct 15, 2021
Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)

Thanks to go-astilectron build cross platform GUI apps with GO and HTML/JS/CSS. It is the official GO bindings of astilectron and is powered by Electr

Quentin Renard 4.1k Oct 23, 2021
Cross platform rapid GUI framework for golang based on Dear ImGui.

giu Cross platform rapid GUI framework for golang based on Dear ImGui and the great golang binding imgui-go. Any contribution (features, widgets, tuto

Allen Dang 1k Oct 17, 2021
Easy Go GUI wrapper for interactive manipulation of visual algorithms/backend code.

RenderView ================ Install: go get github.com/TheGrum/renderview Needs either Shiny (limited functionality), Gio, go-gtk, or gotk3. The latt

null 21 Sep 12, 2021
Cross-platform GUI for go is never this easy and clean.

gimu Strongly suggest NOT to use this project anymore, the auto-generated cgo wrapper of Nuklear has a random crash issue which is hard to fix (becaus

Allen Dang 66 Oct 17, 2021
A Windows GUI toolkit for the Go Programming Language

About Walk Walk is a "Windows Application Library Kit" for the Go Programming Language. Its primarily useful for Desktop GUI development, but there is

Alexander Neumann 5.7k Oct 24, 2021
Windows GUI library for Go (Golang). Comes with a graphical UI designer.

Version 2 Please go to Version 2 of this library for the latest version. Windows GUI Library This is a pure Go library to create native Windows GUIs.

null 60 Oct 6, 2021
Go wrapper around the Iup GUI toolset

Iup Go Wrapper iup is a Go wrapper around the Iup GUI toolkit. The project was started on April 27, 2011. Fork https://github.com/grd/iup is a fork of

grd 24 Nov 28, 2020
SDL2 binding for Go

SDL2 binding for Go go-sdl2 is SDL2 wrapped for Go users. It enables interoperability between Go and the SDL2 library which is written in C. That mean

Ve & Co. 1.6k Oct 14, 2021
Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly

Introduction Qt is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on var

null 8.8k Oct 25, 2021
qt5 bindings for go

#go-qt5 ##Before you start This is a fork of visualfc's qt4 bindings, and several critical bugs are inherited along the way. Until these bugs are fixe

Utkan Güngördü 417 Mar 29, 2021