Skip to content

Commit 3cc891a

Browse files
committed
fmt all files
1 parent eb79a70 commit 3cc891a

39 files changed

Lines changed: 201 additions & 315 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.vscode
1818
*.code-workspace
1919
.lite_workspace.lua
20-
ui.iml
20+
*.iml
2121
*~
2222
*#
2323

apps/v2048/2048.v

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,10 @@ fn (app &App) draw() {
619619
app.gg.draw_text(ww / 2, (m * 8 / 10) + ypad, msg2, app.label_format(.score_end))
620620
}
621621
// Draw at the end, so that it's on top of the victory / game over overlays
622-
app.gg.draw_text(int(app.bounds.x) + labelx, int(app.bounds.y) + labely, 'Points: ${app.board.points}',
623-
app.label_format(.points))
624-
app.gg.draw_text(int(app.bounds.x) + ww - labelx, int(app.bounds.y) + labely, 'Moves: ${app.moves}',
625-
app.label_format(.moves))
622+
app.gg.draw_text(int(app.bounds.x) + labelx, int(app.bounds.y) + labely,
623+
'Points: ${app.board.points}', app.label_format(.points))
624+
app.gg.draw_text(int(app.bounds.x) + ww - labelx, int(app.bounds.y) + labely,
625+
'Moves: ${app.moves}', app.label_format(.moves))
626626
}
627627

628628
fn (app &App) draw_tiles() {
@@ -916,7 +916,8 @@ $if emscripten ? {
916916
pub fn new_gg_app() &App {
917917
mut app := &App{}
918918
app.new_game()
919-
mut font_path := os.join_path(os.dir(@FILE), '..', '..', 'assets', 'fonts', 'RobotoMono-Regular.ttf')
919+
mut font_path := os.join_path(os.dir(@FILE), '..', '..', 'assets', 'fonts',
920+
'RobotoMono-Regular.ttf')
920921
$if android {
921922
font_path = 'fonts/RobotoMono-Regular.ttf'
922923
}

bin/vui_png.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ fn main() {
4545
// println("hello $mf.file")
4646
if os.file_ext(mf.file) == '.png' {
4747
mf.layout.ui.window.set_title('V UI Png Edit: ${mf.file}')
48-
mut rv := uic.rasterview_component_from_id(mf.layout.ui.window,
49-
'rv')
48+
mut rv :=
49+
uic.rasterview_component_from_id(mf.layout.ui.window, 'rv')
5050
rv.load_image(mf.file)
5151
colors := rv.top_colors()
5252
mut cp := uic.colorpalette_component_from_id(mf.layout.ui.window,
@@ -64,8 +64,8 @@ fn main() {
6464
// println('new $mf.file!!!')
6565
if os.file_ext(mf.file) == '.png' {
6666
// create image
67-
mut rv := uic.rasterview_component_from_id(mf.layout.ui.window,
68-
'rv')
67+
mut rv :=
68+
uic.rasterview_component_from_id(mf.layout.ui.window, 'rv')
6969
rv.extract_size(mf.file)
7070
rv.new_image()
7171
rv.save_image_as(mf.file)
@@ -75,8 +75,8 @@ fn main() {
7575
on_save: fn (mf &uic.MenuFileComponent) {
7676
// println("save $mf.file")
7777
if os.file_ext(mf.file) == '.png' {
78-
mut rv := uic.rasterview_component_from_id(mf.layout.ui.window,
79-
'rv')
78+
mut rv :=
79+
uic.rasterview_component_from_id(mf.layout.ui.window, 'rv')
8080
rv.save_image_as(mf.file)
8181
mf.layout.ui.window.root_layout.unfocus_all()
8282
}

component/colorbox.v

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,9 @@ fn cv_h_draw(mut d ui.DrawDevice, c &ui.CanvasLayout) {
220220
for j in 0 .. 255 {
221221
c.draw_device_rect_empty(d, 0, j, 30, 1, cb.hsv_to_rgb(f64(j) / 256.0, .75, .75))
222222
}
223-
c.draw_device_rounded_rect_filled(d, -3, int(cb.h * 256) - 3, 36, 6, 2, cb.hsv_to_rgb(cb.h,
224-
.2, .7))
225-
c.draw_device_rect_filled(d, 3, int(cb.h * 256) - 1, 24, 2, cb.hsv_to_rgb(cb.h, .75,
226-
.75))
223+
c.draw_device_rounded_rect_filled(d, -3, int(cb.h * 256) - 3, 36, 6, 2, cb.hsv_to_rgb(cb.h, .2,
224+
.7))
225+
c.draw_device_rect_filled(d, 3, int(cb.h * 256) - 1, 24, 2, cb.hsv_to_rgb(cb.h, .75, .75))
227226
c.draw_device_rounded_rect_empty(d, -3, int(cb.h * 256) - 3, 36, 6, 2, if cb.light {
228227
gg.black
229228
} else {
@@ -256,8 +255,8 @@ fn cv_sv_draw(mut d ui.DrawDevice, mut c ui.CanvasLayout) {
256255

257256
c.draw_device_rounded_rect_filled(d, int(cb.s * 256.0) - 10, int((1.0 - cb.v) * 256.0) - 10,
258257
20, 20, 10, cb.hsv_to_rgb(cb.h, 1 - cb.s, 1.0 - cb.v))
259-
c.draw_device_rounded_rect_filled(d, int(cb.s * 256.0) - 7, int((1.0 - cb.v) * 256.0) - 7,
260-
14, 14, 7, cb.hsv_to_rgb(cb.h, cb.s, cb.v))
258+
c.draw_device_rounded_rect_filled(d, int(cb.s * 256.0) - 7, int((1.0 - cb.v) * 256.0) - 7, 14,
259+
14, 7, cb.hsv_to_rgb(cb.h, cb.s, cb.v))
261260
}
262261

263262
fn cv_sel_key_down(c &ui.CanvasLayout, e ui.KeyEvent) {
@@ -301,8 +300,7 @@ fn cv_sel_draw(mut d ui.DrawDevice, mut c ui.CanvasLayout) {
301300
hsv = cb.hsv_sel[i + j * cb_nc]
302301
h, s, v = hsv.h, hsv.s, hsv.v
303302
c.draw_device_rounded_rect_filled(d, cb_sp + i * (cb_hsv_col + cb_sp), cb_sp +
304-
j * (cb_hsv_col + cb_sp), cb_hsv_col, cb_hsv_col, .25, cb.hsv_to_rgb(h,
305-
s, v))
303+
j * (cb_hsv_col + cb_sp), cb_hsv_col, cb_hsv_col, .25, cb.hsv_to_rgb(h, s, v))
306304
}
307305
}
308306
}

component/colorpalette.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ pub fn (mut cp ColorPaletteComponent) connect_color(color &gg.Color) {
134134

135135
// TODO: documentation
136136
pub fn colorpalette_click(cb &ColorButtonComponent) {
137-
mut cp := colorpalette_component_from_id(cb.widget.ui.window, ui.component_parent_id(cb.widget.id))
137+
mut cp := colorpalette_component_from_id(cb.widget.ui.window,
138+
ui.component_parent_id(cb.widget.id))
138139
cp.selected = cb.widget.id
139140
unsafe {
140141
*(cp.color) = cb.bg_color

component/colorsliders.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ pub fn colorsliders_stack(p ColorSlidersParams) &ui.Stack {
173173
cs.r_textbox.text = &cs.r_textbox_text
174174
cs.g_textbox.text = &cs.g_textbox_text
175175
cs.b_textbox.text = &cs.b_textbox_text
176-
ui.component_connect(cs, layout, r_slider, g_slider, b_slider, r_textbox, g_textbox,
177-
b_textbox)
176+
ui.component_connect(cs, layout, r_slider, g_slider, b_slider, r_textbox, g_textbox, b_textbox)
178177
// layout.on_init = colorsliders_init
179178
return layout
180179
}
@@ -191,7 +190,8 @@ pub fn colorsliders_component_from_id(w ui.Window, id string) &ColorSlidersCompo
191190

192191
// TODO: documentation
193192
pub fn (cs &ColorSlidersComponent) color() gg.Color {
194-
return gg.rgb(u8(cs.r_textbox.text.int()), u8(cs.g_textbox.text.int()), u8(cs.b_textbox.text.int()))
193+
return gg.rgb(u8(cs.r_textbox.text.int()), u8(cs.g_textbox.text.int()),
194+
u8(cs.b_textbox.text.int()))
195195
}
196196

197197
// TODO: documentation

component/double_listbox.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ pub fn doublelistbox_stack(c DoubleListBoxParams) &ui.Stack {
4040
on_click: doublelistbox_move_right
4141
)
4242
mut btn_left := ui.button(id: c.id + '_btn_left', text: '<<', on_click: doublelistbox_move_left)
43-
mut btn_clear := ui.button(id: c.id + '_btn_clear', text: 'clear', on_click: doublelistbox_clear)
43+
mut btn_clear :=
44+
ui.button(id: c.id + '_btn_clear', text: 'clear', on_click: doublelistbox_clear)
4445
mut layout := ui.row(
4546
title: c.title
4647
id: ui.component_id(c.id, 'layout')

component/grid.v

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,8 @@ fn (mut g GridComponent) draw_device_colbar(mut d ui.DrawDevice) {
569569
g.pos_x, g.pos_y = g.layout.abs_pos(0, 0)
570570

571571
// draw empty rectangles to clear top left corner preventing current selection drawn when is scrolled
572-
d.draw_rect_filled(g.pos_x, g.pos_y, g.rowbar_width + g.header_size, g.colbar_height,
573-
gg.white)
574-
d.draw_rect_filled(g.pos_x, g.pos_y, g.rowbar_width, g.colbar_height + g.header_size,
575-
gg.white)
572+
d.draw_rect_filled(g.pos_x, g.pos_y, g.rowbar_width + g.header_size, g.colbar_height, gg.white)
573+
d.draw_rect_filled(g.pos_x, g.pos_y, g.rowbar_width, g.colbar_height + g.header_size, gg.white)
576574
mut pos_x := g.layout.x + g.layout.offset_x + g.rowbar_width + g.header_size
577575
for j, var in g.headers {
578576
tb.set_pos(pos_x, g.pos_y)
@@ -843,10 +841,10 @@ fn (mut g GridComponent) visible_cells() {
843841

844842
// TODO: documentation
845843
pub fn (mut g GridComponent) visible_fixed_cells() {
846-
g.from_i = math.min(math.max((g.layout.scrollview.offset_y - g.colbar_height - g.header_size) / g.cell_height,
847-
0), g.nrow() - 1)
848-
g.to_i = math.min((g.layout.scrollview.offset_y +
849-
g.layout.height - g.colbar_height - g.header_size) / g.cell_height, g.nrow() - 1) + 1
844+
g.from_i = math.min(math.max((g.layout.scrollview.offset_y - g.colbar_height - g.header_size) / g.cell_height, 0),
845+
g.nrow() - 1)
846+
g.to_i = math.min((g.layout.scrollview.offset_y + g.layout.height - g.colbar_height -
847+
g.header_size) / g.cell_height, g.nrow() - 1) + 1
850848
g.from_y = g.from_i * g.cell_height + g.colbar_height + g.header_size
851849
// println("vfc $g.from_i, $g.to_i")
852850
}

component/menufile.v

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,16 @@ fn btn_open_ok(b &ui.Button) {
210210
// println('ok')
211211
filebrowser_subwindow_close(b.ui.window, ui.component_parent_id(b.id))
212212
fb := filebrowser_component(b)
213-
mut dtv := treeview_component_from_id(b.ui.window, ui.component_id_from_by(b.id, 2,
214-
'dtv'))
215-
mut mf := menufile_component_from_id(b.ui.window, ui.component_parent_id_by(b.id,
216-
2))
213+
mut dtv := treeview_component_from_id(b.ui.window, ui.component_id_from_by(b.id, 2, 'dtv'))
214+
mut mf := menufile_component_from_id(b.ui.window, ui.component_parent_id_by(b.id, 2))
217215
mf.folder_to_open = fb.selected_full_title()
218216
dtv.open_dir(mf.folder_to_open)
219217
}
220218

221219
fn btn_open_cancel(b &ui.Button) {
222220
// println('cancel open')
223221
filebrowser_subwindow_close(b.ui.window, ui.component_parent_id(b.id))
224-
mut mf := menufile_component_from_id(b.ui.window, ui.component_parent_id_by(b.id,
225-
2))
222+
mut mf := menufile_component_from_id(b.ui.window, ui.component_parent_id_by(b.id, 2))
226223
mf.folder_to_open = ''
227224
}
228225

component/rasterview.v

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ fn (rv &RasterViewComponent) draw_device_current(d ui.DrawDevice) {
345345
}
346346
pos_x, pos_y := rv.get_pos(rv.cur_i, rv.cur_j)
347347
cur_color := gg.cyan
348-
rv.layout.draw_device_rect_surrounded(d, pos_x, pos_y, rv.pixel_size, rv.pixel_size,
349-
2, cur_color)
348+
rv.layout.draw_device_rect_surrounded(d, pos_x, pos_y, rv.pixel_size, rv.pixel_size, 2,
349+
cur_color)
350350
}
351351

352352
fn (rv &RasterViewComponent) draw_device_selection(d ui.DrawDevice) {
@@ -355,8 +355,8 @@ fn (rv &RasterViewComponent) draw_device_selection(d ui.DrawDevice) {
355355
}
356356
pos_x, pos_y := rv.get_pos(rv.sel_i, rv.sel_j)
357357
sel_color := gg.red
358-
rv.layout.draw_device_rect_surrounded(d, pos_x, pos_y, rv.pixel_size, rv.pixel_size,
359-
3, sel_color)
358+
rv.layout.draw_device_rect_surrounded(d, pos_x, pos_y, rv.pixel_size, rv.pixel_size, 3,
359+
sel_color)
360360
}
361361

362362
fn (rv &RasterViewComponent) size() (int, int) {
@@ -374,8 +374,8 @@ fn (mut rv RasterViewComponent) visible_pixels() {
374374
rv.from_y = rv.from_i * rv.size
375375

376376
rv.from_j = math.min(math.max(rv.layout.scrollview.offset_x / rv.size, 0), rv.width() - 1)
377-
rv.to_j = math.min((rv.layout.scrollview.offset_x +
378-
rv.layout.width) / rv.size, rv.width() - 1) + 1
377+
rv.to_j = math.min((rv.layout.scrollview.offset_x + rv.layout.width) / rv.size, rv.width() -
378+
1) + 1
379379
rv.from_x = rv.from_j * rv.size
380380
} else {
381381
rv.from_i, rv.to_i, rv.from_y = 0, rv.height(), 0
@@ -478,7 +478,8 @@ pub fn (mut rv RasterViewComponent) update_bounds() {
478478

479479
// TODO: documentation
480480
pub fn (rv &RasterViewComponent) get_margins() (int, int, int, int) { // top, bottom, left, right
481-
return rv.bounds_i, rv.height() - rv.bounds_i - rv.bounds_h, rv.bounds_j, rv.width() - rv.bounds_j - rv.bounds_w
481+
return rv.bounds_i, rv.height() - rv.bounds_i - rv.bounds_h, rv.bounds_j, rv.width() -
482+
rv.bounds_j - rv.bounds_w
482483
}
483484

484485
// TODO: documentation
@@ -488,8 +489,8 @@ pub fn (mut rv RasterViewComponent) move_pixels(di int, dj int) {
488489
|| (dj < 0 && dj < -ml) || (dj > 0 && dj > mr) {
489490
return
490491
}
491-
mut from_i, mut to_i, mut from_j, mut to_j, mut step_i, mut step_j := (rv.bounds_i + rv.bounds_h - 1), rv.bounds_i, (
492-
rv.bounds_j + rv.bounds_w - 1), rv.bounds_j, 1, 1
492+
mut from_i, mut to_i, mut from_j, mut to_j, mut step_i, mut step_j := (rv.bounds_i +
493+
rv.bounds_h - 1), rv.bounds_i, (rv.bounds_j + rv.bounds_w - 1), rv.bounds_j, 1, 1
493494

494495
if di < 0 {
495496
step_i = -1

0 commit comments

Comments
 (0)