Skip to content

Commit bc2ea1b

Browse files
authored
fix ui field to unsafe{ nil } and treeview clipping issue (#563)
1 parent 459eb3b commit bc2ea1b

File tree

105 files changed

+433
-608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+433
-608
lines changed

apps/users/users.v

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ module users
33
import ui
44
import gx
55

6-
const (
7-
nr_cols = 4
8-
cell_height = 25
9-
cell_width = 100
10-
table_width = cell_width * nr_cols
11-
)
6+
const nr_cols = 4
7+
const cell_height = 25
8+
const cell_width = 100
9+
const table_width = cell_width * nr_cols
1210

1311
struct User {
1412
first_name string

apps/v2048/2048.v

+74-75
Original file line numberDiff line numberDiff line change
@@ -48,81 +48,80 @@ struct Theme {
4848
tile_colors []gx.Color
4949
}
5050

51-
const (
52-
themes = [
53-
&Theme{
54-
bg_color: gx.rgb(250, 248, 239)
55-
padding_color: gx.rgb(143, 130, 119)
56-
victory_color: gx.rgb(100, 160, 100)
57-
game_over_color: gx.rgb(190, 50, 50)
58-
text_color: gx.black
59-
tile_colors: [
60-
gx.rgb(205, 193, 180), // Empty / 0 tile
61-
gx.rgb(238, 228, 218), // 2
62-
gx.rgb(237, 224, 200), // 4
63-
gx.rgb(242, 177, 121), // 8
64-
gx.rgb(245, 149, 99), // 16
65-
gx.rgb(246, 124, 95), // 32
66-
gx.rgb(246, 94, 59), // 64
67-
gx.rgb(237, 207, 114), // 128
68-
gx.rgb(237, 204, 97), // 256
69-
gx.rgb(237, 200, 80), // 512
70-
gx.rgb(237, 197, 63), // 1024
71-
gx.rgb(237, 194, 46),
72-
]
73-
},
74-
&Theme{
75-
bg_color: gx.rgb(55, 55, 55)
76-
padding_color: gx.rgb(68, 60, 59)
77-
victory_color: gx.rgb(100, 160, 100)
78-
game_over_color: gx.rgb(190, 50, 50)
79-
text_color: gx.white
80-
tile_colors: [
81-
gx.rgb(123, 115, 108),
82-
gx.rgb(142, 136, 130),
83-
gx.rgb(142, 134, 120),
84-
gx.rgb(145, 106, 72),
85-
gx.rgb(147, 89, 59),
86-
gx.rgb(147, 74, 57),
87-
gx.rgb(147, 56, 35),
88-
gx.rgb(142, 124, 68),
89-
gx.rgb(142, 122, 58),
90-
gx.rgb(142, 120, 48),
91-
gx.rgb(142, 118, 37),
92-
gx.rgb(142, 116, 27),
93-
]
94-
},
95-
&Theme{
96-
bg_color: gx.rgb(38, 38, 66)
97-
padding_color: gx.rgb(58, 50, 74)
98-
victory_color: gx.rgb(100, 160, 100)
99-
game_over_color: gx.rgb(190, 50, 50)
100-
text_color: gx.white
101-
tile_colors: [
102-
gx.rgb(92, 86, 140),
103-
gx.rgb(106, 99, 169),
104-
gx.rgb(106, 97, 156),
105-
gx.rgb(108, 79, 93),
106-
gx.rgb(110, 66, 76),
107-
gx.rgb(110, 55, 74),
108-
gx.rgb(110, 42, 45),
109-
gx.rgb(106, 93, 88),
110-
gx.rgb(106, 91, 75),
111-
gx.rgb(106, 90, 62),
112-
gx.rgb(106, 88, 48),
113-
gx.rgb(106, 87, 35),
114-
]
115-
},
116-
]
117-
window_title = 'V 2048'
118-
default_window_width = 544
119-
default_window_height = 560
120-
animation_length = 10 // frames
121-
frames_per_ai_move = 8
122-
possible_moves = [Direction.up, .right, .down, .left]
123-
predictions_per_move = 200
124-
prediction_depth = 8
125-
)
51+
const themes = [
52+
&Theme{
53+
bg_color: gx.rgb(250, 248, 239)
54+
padding_color: gx.rgb(143, 130, 119)
55+
victory_color: gx.rgb(100, 160, 100)
56+
game_over_color: gx.rgb(190, 50, 50)
57+
text_color: gx.black
58+
tile_colors: [
59+
gx.rgb(205, 193, 180), // Empty / 0 tile
60+
gx.rgb(238, 228, 218), // 2
61+
gx.rgb(237, 224, 200), // 4
62+
gx.rgb(242, 177, 121), // 8
63+
gx.rgb(245, 149, 99), // 16
64+
gx.rgb(246, 124, 95), // 32
65+
gx.rgb(246, 94, 59), // 64
66+
gx.rgb(237, 207, 114), // 128
67+
gx.rgb(237, 204, 97), // 256
68+
gx.rgb(237, 200, 80), // 512
69+
gx.rgb(237, 197, 63), // 1024
70+
gx.rgb(237, 194, 46),
71+
]
72+
},
73+
&Theme{
74+
bg_color: gx.rgb(55, 55, 55)
75+
padding_color: gx.rgb(68, 60, 59)
76+
victory_color: gx.rgb(100, 160, 100)
77+
game_over_color: gx.rgb(190, 50, 50)
78+
text_color: gx.white
79+
tile_colors: [
80+
gx.rgb(123, 115, 108),
81+
gx.rgb(142, 136, 130),
82+
gx.rgb(142, 134, 120),
83+
gx.rgb(145, 106, 72),
84+
gx.rgb(147, 89, 59),
85+
gx.rgb(147, 74, 57),
86+
gx.rgb(147, 56, 35),
87+
gx.rgb(142, 124, 68),
88+
gx.rgb(142, 122, 58),
89+
gx.rgb(142, 120, 48),
90+
gx.rgb(142, 118, 37),
91+
gx.rgb(142, 116, 27),
92+
]
93+
},
94+
&Theme{
95+
bg_color: gx.rgb(38, 38, 66)
96+
padding_color: gx.rgb(58, 50, 74)
97+
victory_color: gx.rgb(100, 160, 100)
98+
game_over_color: gx.rgb(190, 50, 50)
99+
text_color: gx.white
100+
tile_colors: [
101+
gx.rgb(92, 86, 140),
102+
gx.rgb(106, 99, 169),
103+
gx.rgb(106, 97, 156),
104+
gx.rgb(108, 79, 93),
105+
gx.rgb(110, 66, 76),
106+
gx.rgb(110, 55, 74),
107+
gx.rgb(110, 42, 45),
108+
gx.rgb(106, 93, 88),
109+
gx.rgb(106, 91, 75),
110+
gx.rgb(106, 90, 62),
111+
gx.rgb(106, 88, 48),
112+
gx.rgb(106, 87, 35),
113+
]
114+
},
115+
]
116+
const window_title = 'V 2048'
117+
const default_window_width = 544
118+
const default_window_height = 560
119+
const animation_length = 10 // frames
120+
121+
const frames_per_ai_move = 8
122+
const possible_moves = [Direction.up, .right, .down, .left]
123+
const predictions_per_move = 200
124+
const prediction_depth = 8
126125

127126
// Used for performance monitoring when `-d showfps` is passed, unused / optimized out otherwise
128127
struct Perf {

bin/vui_build.v

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import time
66
import os
77
import x.json2
88

9-
const (
10-
time_sleep = 500
11-
help_text = $embed_file('help/vui_demo.help').to_string()
12-
demos_json = $embed_file('assets/demos.json').to_string()
13-
)
9+
const time_sleep = 500
10+
const help_text = $embed_file('help/vui_demo.help').to_string()
11+
const demos_json = $embed_file('assets/demos.json').to_string()
1412

1513
// vfmt off
1614
@[heap]

bin/vui_edit.v

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import ui.component as uic
33
import gx
44
import os
55

6-
const (
7-
win_width = 800
8-
win_height = 600
9-
)
6+
const win_width = 800
7+
const win_height = 600
108

119
struct App {
1210
mut:
@@ -16,7 +14,7 @@ mut:
1614

1715
fn main() {
1816
mut app := &App{
19-
window: 0
17+
window: unsafe { nil }
2018
}
2119
// TODO: use a proper parser loop, or even better - the `flag` module
2220
mut args := os.args#[1..].clone()

bin/vui_png.v

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import ui.component as uic
33
import gx
44
import os
55

6-
const (
7-
win_width = 800
8-
win_height = 600
9-
help_text = $embed_file('help/vui_png.help').to_string()
10-
)
6+
const win_width = 800
7+
const win_height = 600
8+
const help_text = $embed_file('help/vui_png.help').to_string()
119

1210
fn main() {
1311
// TODO: use a proper parser loop, or even better - the `flag` module

bin/vui_todo.v

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import ui
22

3-
const (
4-
w_width = 400
5-
w_height = 600
6-
w_title = 'V DO'
7-
)
3+
const w_width = 400
4+
const w_height = 600
5+
const w_title = 'V DO'
86

97
struct Task {
108
mut:

component/colorsliders.v

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ module component
33
import ui
44
import gx
55

6-
const (
7-
slider_min = 0
8-
slider_max = 255
9-
slider_val = (slider_max + slider_min) / 2
10-
)
6+
const slider_min = 0
7+
const slider_max = 255
8+
const slider_val = (slider_max + slider_min) / 2
119

1210
type ColorSlidersFn = fn (cs &ColorSlidersComponent)
1311

component/fontbutton.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn fontbutton(c FontButtonParams) &ui.Button {
3939
on_click: font_button_click
4040
style_params: ui.button_style(radius: f32(c.radius))
4141
padding: f32(c.padding)
42-
ui: 0
42+
ui: unsafe { nil }
4343
}
4444
mut fb := &FontButtonComponent{
4545
btn: b

component/fontchooser.v

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ module component
33
import ui
44
import os
55

6-
const (
7-
fontchooser_row_id = '_row_sw_font'
8-
fontchooser_lb_id = '_lb_sw_font'
9-
)
6+
const fontchooser_row_id = '_row_sw_font'
7+
const fontchooser_lb_id = '_lb_sw_font'
108

119
@[heap]
1210
pub struct FontChooserComponent {

component/grid_formula.v

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import gx
55
import math
66
import regex
77

8-
const (
9-
no_cell = GridCell{-1, -1}
10-
)
8+
const no_cell = GridCell{-1, -1}
119

1210
// Spreadsheet-like (ex: A1, B4, ...)
1311
type AlphaCell = string

component/subwindow_colorbox.v

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ module component
33
import ui
44
import gx
55

6-
const (
7-
colorbox_subwindow_id = '_sw_cbox'
8-
colorbox_subwindow_layout_id = ui.component_id('_sw_cbox', 'layout')
9-
)
6+
const colorbox_subwindow_id = '_sw_cbox'
7+
const colorbox_subwindow_layout_id = ui.component_id('_sw_cbox', 'layout')
108

119
// Append colorbox to window
1210
pub fn colorbox_subwindow_add(mut w ui.Window) {

component/subwindow_filebrowser.v

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ module component
22

33
import ui
44

5-
const (
6-
filebrowser_subwindow_id = '_sw_filebrowser'
7-
newfilebrowser_subwindow_id = '_sw_newfilebrowser'
8-
)
5+
const filebrowser_subwindow_id = '_sw_filebrowser'
6+
const newfilebrowser_subwindow_id = '_sw_newfilebrowser'
97

108
// Subwindow
119
@[params]

component/subwindow_fontchooser.v

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ module component
22

33
import ui
44

5-
const (
6-
fontchooser_subwindow_id = '_sw_font'
7-
)
5+
const fontchooser_subwindow_id = '_sw_font'
86

97
// Append fontchooser to window
108
pub fn fontchooser_subwindow_add(mut w ui.Window) { //}, fontchooser_lb_change ui.ListBoxSelectionChangedFn) {

component/treeview.v

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import ui
44
import gx
55
import os
66

7-
const (
8-
tree_sep = ':'
9-
root_sep = '_|||_'
10-
)
7+
const tree_sep = ':'
8+
const root_sep = '_|||_'
119

1210
type TreeItem = Tree | string
1311

@@ -176,7 +174,6 @@ pub fn treeview_stack(c TreeViewParams) &ui.Stack {
176174
widths: ui.compact
177175
heights: ui.compact
178176
bg_color: c.bg_color
179-
clipping: true
180177
)
181178
mut tv := &TreeViewComponent{
182179
id: c.id

examples/7guis/circledrawer.v

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import ui
22
import gx
33
import math
44

5-
const (
6-
default_radius = 20
7-
)
5+
const default_radius = 20
86

97
// Circle
108

examples/7guis/counter.v

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import ui
22
import gx
33

4-
const (
5-
win_width = 200
6-
win_height = 40
7-
)
4+
const win_width = 200
5+
const win_height = 40
86

97
@[heap]
108
struct App {

examples/7guis/counter_with_closure.v

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import ui
22
import gx
33

4-
const (
5-
win_width = 200
6-
win_height = 40
7-
)
4+
const win_width = 200
5+
const win_height = 40
86

97
@[heap]
108
struct App {

examples/7guis/flightbooker.v

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import ui
22
import gx
33
import time
44

5-
const (
6-
no_time = time.Time{}
7-
)
5+
const no_time = time.Time{}
86

97
@[heap]
108
struct App {

0 commit comments

Comments
 (0)