diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38bd9007..70df7e2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -44,14 +46,10 @@ 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] @@ -59,7 +57,7 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 25 env: - VFLAGS: -no-parallel + VFLAGS: -no-parallel -cc clang steps: - name: Install V id: install-v @@ -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: @@ -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 @@ -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 diff --git a/README.md b/README.md index c1755bf8..dcbba8a3 100644 --- a/README.md +++ b/README.md @@ -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 } ), diff --git a/_view_input_test.v b/_view_input_test.v index 22812650..e1035a8f 100644 --- a/_view_input_test.v +++ b/_view_input_test.v @@ -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() { diff --git a/examples/_build.vsh b/examples/_build.vsh index 9616c268..ff11f52d 100755 --- a/examples/_build.vsh +++ b/examples/_build.vsh @@ -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 { diff --git a/examples/clicks.v b/examples/clicks.v new file mode 100644 index 00000000..75b186c7 --- /dev/null +++ b/examples/clicks.v @@ -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() +}