Skip to content
Merged
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
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ jobs:
check-latest: true
- name: Install vglyph
run: v install vglyph
- name: Update packages
run: v retry -- sudo apt -qq update
- name: Install X11/GL development dependencies (headers and libs)
run: v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev
- name: Install C development dependencies (headers and libs)
if: runner.os == 'Linux'
run: v retry -- sudo apt -qq update && v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev
- name: Install development dependencies on macos (headers and libs)
if: runner.os == 'macOS'
run: v retry -- brew install pango harfbuzz freetype2
- name: Checkout the gui module
uses: actions/checkout@v4
with:
Expand All @@ -44,22 +46,18 @@ jobs:
run: v fmt -verify -inprocess gui/
- name: Check formatting of MD files
run: v check-md gui/
- name: Run tests
run: v test gui/
- name: Check syntax of examples
run: v gui/examples/_check.vsh
- name: Check compilation of examples
run: v should-compile-all gui/examples/

compiling-with-prod:
compiling:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
fail-fast: true
runs-on: ${{ matrix.os }}
timeout-minutes: 25
env:
VFLAGS: -no-parallel
VFLAGS: -no-parallel -cc clang
steps:
- name: Install V
id: install-v
Expand All @@ -82,10 +80,10 @@ jobs:
run: v test gui/
- name: Check compilation of examples
run: v should-compile-all gui/examples/
- name: Check compilation of examples with -prod
- name: Check compilation of examples with -W
run: v gui/examples/_build.vsh

compiling-with-prod-on-windows:
compiling-on-windows:
runs-on: windows-latest
timeout-minutes: 25
env:
Expand All @@ -96,6 +94,8 @@ jobs:
uses: vlang/setup-v@v1.4
with:
check-latest: true
- name: Install pango and freetype
run: vcpkg install pango freetype
- name: Install vglyph
run: v install vglyph
- name: Checkout the gui module
Expand All @@ -106,5 +106,5 @@ jobs:
run: v test gui/
- name: Check compilation of examples
run: v should-compile-all gui/examples/
- name: Check compilation of examples with -prod
- name: Check compilation of examples with -W
run: v gui/examples/_build.vsh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn main_view(window &gui.Window) gui.View {
gui.text(text: '${app.clicks} clicks'),
gui.button(
content: [gui.text(text: 'Click me')]
on_click: fn (_, _, mut w gui.Window) {
on_click: fn (_ &gui.Layout, mut _ gui.Event, mut w gui.Window) {
w.state[App]().clicks += 1
}
),
Expand Down
7 changes: 7 additions & 0 deletions _view_input_test.v
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// vtest build: false
// TODO: this test is skipped for now on the CI, because it needs a X11 server to be running,
// in order for clipboard copy/paste to work.
// See these for a way to do it on the CI (which does not run a graphics service by default):
// https://github.com/vlang/v/blob/master/.github/workflows/c2v_ci.yml#L75
// https://github.com/vlang/v/blob/master/.github/workflows/c2v_ci.yml#L103
// https://github.com/vlang/v/blob/master/.github/workflows/c2v_ci.yml#L130
module gui

fn test_input_delete_key_at_end_is_noop() {
Expand Down
4 changes: 2 additions & 2 deletions examples/_build.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ mut errors := []string{}
for file in files {
_, name, _ := split_path(file)
output_file := join_path(output_dir, name)
cmd := 'v -no-parallel -prod -o ${output_file:-22s} ${file}'
dsp := 'v -no-parallel -prod -o ${output_file:-22s} ${os.file_name(file):-26s}'
cmd := 'v -no-parallel -W -o ${output_file:-22s} ${file}'
dsp := 'v -no-parallel -W -o ${output_file:-22s} ${os.file_name(file):-26s}'
print(dsp)
result := execute(cmd)
if result.exit_code == 0 {
Expand Down
26 changes: 26 additions & 0 deletions examples/clicks.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@[has_globals]
module main

import gui

__global clicks = 0

fn main() {
mut window := gui.window(
title: 'Click the button:'
width: 300
height: 40
on_init: fn (mut w gui.Window) {
w.update_view(fn (mut window gui.Window) gui.View {
return gui.button(
padding: gui.pad_tblr(5, 120)
content: [gui.text(text: 'Clicks: ${clicks}')]
on_click: fn (_ &gui.Layout, mut _ gui.Event, mut w gui.Window) {
clicks++
}
)
})
}
)
window.run()
}
Loading