Widgets
Widgets an obsolete application just for playing and getting touch with widgets. Written in plain Ano script, no C involved.
Widgets demonstrates how to use different type of widgets.
User interface
There is dummy widgets to play with.
Compilation
Easiest way to get Widgets running is to go to examples directory in package root, and run:
$ ./build.sh gui_widgets
build.sh script compiles Ano script, menu and widget definitions to C, copies source files in place and pops up instructions what to do next. Follow them. Check also examples/README for more info.
Screenshots
Preview
;
; This is dummy application to demonstrate widget outlook.
;
; @ANO_SCRIPT_NAME gui_widgets
; @ANO_SCRIPT_VERSION 0.0.2
; @ANO_SCRIPT_DESCRIPTION Widget demo
;
; @ANO_FLAGS_VAR_NAME_SUBS [ ]
; @ANO_FLAGS_VAR_WARN_UNUSED [ ]
;
; Copyright (c) 2016-2023, Jani Salonen <salojan at goto10 piste co>
; All rights reserved.
;
; Global uninitialized variables
var [handle] hnd_wnd_main
; Initialize windowing system
window_init
; Open main window
window_open ("Widget demo", NULL, \
[handle] @0, [uint] 1, [uint] 0, [uint] 0, \
[int] -1, [int] -1, [uint] 800, [uint] 900, \
NULL, NULL, NULL, NULL, NULL, NULL, \
NULL, NULL, "cb_destroy", \
NULL, NULL, NULL, "cb_open")
end
callback cb_open (_hnd) {
mov hnd_wnd_main (_hnd)
mov color (# 0xff, 0xff, 0xff, 0x00)
; Create scales and indicators
widget_update_scale_bars (hnd_wnd_main, \
"widget_a", NULL, NULL, 7, 0, 0, 100, 11, color)
widget_indicator_set (hnd_wnd_main, \
"widget_a", NULL, NULL, 7, 0, color, 1, 20)
widget_indicator_set (hnd_wnd_main, \
"widget_b", NULL, NULL, 7, 0, color, 1, 20)
widget_indicator_set (hnd_wnd_main, \
"widget_c", NULL, NULL, 7, 0, color, 1, 20)
widget_indicator_set (hnd_wnd_main, \
"widget_d", NULL, NULL, 7, 0, color, 1, 20)
widget_indicator_set (hnd_wnd_main, \
"widget_e", NULL, NULL, 7, 0, color, 1, 20)
widget_indicator_set (hnd_wnd_main, \
"widget_f", NULL, NULL, 7, 0, color, 1, 20)
widget_update_scale_bars (hnd_wnd_main, \
"slider_a", NULL, NULL, 7, 0, 0, 10, 11, color)
widget_update_scale_bars (hnd_wnd_main, \
"slider_b", NULL, NULL, 7, 0, 0, 20, 5, color)
; Map main window
window_map (hnd_wnd_main)
}
callback cb_destroy {
window_close (hnd_wnd_main)
exit
}
callback cb_turn_a (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
}
callback cb_turn_b (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
}
callback cb_turn_c (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
}
callback cb_turn_d (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
}
callback cb_turn_e (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
}
callback cb_turn_f (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
; Widget even step turns light on, odd step turns it off
mov _s (_step % 2)
; Which lights to set is based on widget step
cmp _step (1)
ja "cb_turn_f_a"
mov _a ("lamp_a")
mov _b ("led_a_a")
mov _c ("led_b_a")
mov _d ("led_c_a")
jmp "cb_turn_f_x"
: "cb_turn_f_a"
cmp _step (3)
ja "cb_turn_f_b"
mov _a ("lamp_b")
mov _b ("led_a_b")
mov _c ("led_b_b")
mov _d ("led_c_b")
jmp "cb_turn_f_x"
: "cb_turn_f_b"
cmp _step (5)
ja "cb_turn_f_c"
mov _a ("lamp_c")
mov _b ("led_a_c")
mov _c ("led_b_c")
mov _d ("led_c_c")
jmp "cb_turn_f_x"
: "cb_turn_f_c"
cmp _step (7)
ja "cb_turn_f_d"
mov _a ("lamp_d")
mov _b ("led_a_d")
mov _c ("led_b_d")
mov _d ("led_c_d")
jmp "cb_turn_f_x"
: "cb_turn_f_d"
cmp _step (9)
ja "cb_turn_f_e"
mov _a ("lamp_e")
mov _b ("led_a_e")
mov _c ("led_b_e")
mov _d ("led_c_e")
jmp "cb_turn_f_x"
: "cb_turn_f_e"
mov _a ("lamp_f")
mov _b ("led_a_f")
mov _c ("led_b_f")
mov _d ("led_c_f")
: "cb_turn_f_x"
widget_step_set (hnd_wnd_main, _a, _s)
widget_step_set (hnd_wnd_main, _b, _s)
widget_step_set (hnd_wnd_main, _c, _s)
widget_step_set (hnd_wnd_main, _d, _s)
; widget_refresh (hnd_wnd_main)
}
callback cb_push_a (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
}
callback cb_push_b (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
}
callback cb_push_c (_widget_name, _widget_id, _min, _max, _steps, _step) {
dump _widget_name
dump _step
widget_step_set (hnd_wnd_main, "led_button_c", _step)
; widget_refresh (hnd_wnd_main)
}
;
; Copyright (c) 2016-2023, Jani Salonen <salojan at goto10 piste co>
; All rights reserved.
;
; @WIDGET_DEFAULT_COLOR rgb:#ffffff
; @WIDGET_DEFAULT_HUE 0
; @WIDGET_DEFAULT_LIGHT no
; @WIDGET_DEFAULT_STATE enable
; @WIDGET_DEFAULT_STICKY no
; @WIDGET_DEFAULT_TITLE_CHARSET UTF-8
; @WIDGET_DEFAULT_TITLE_COLOR rgb:#ffffff
; @WIDGET_DEFAULT_TITLE_DPI 0
; WIDGET_DEFAULT_TITLE_FONT path_to_the_font_file
; @WIDGET_DEFAULT_TITLE_JUSTIFICATION center
; @WIDGET_DEFAULT_TITLE_POSITION above
; @WIDGET_DEFAULT_TITLE_SIZE 11
; @WIDGET_DEFAULT_TRIGGER constant
; @WIDGET_DEFAULT_TYPE 0
; @WIDGET_DEFAULT_VALUE 0
;
; @WIDGET_USE_BOUNDING_BOXES no
;
window "1" {
set "0" {
widget "background" {
name "background"
image "examples/datafiles/background.tga"
}
; Turnswitch type 0
widget "turnswitch" {
name "widget_a"
position x = 80, y = 100
angle min = 45, max = 315
steps start = 0, total = 100
title "Large chicken head", \
x = 0, y = -50
action turn = cb_turn_a
}
; Turnswitch type 1
widget "turnswitch" {
name "widget_b"
type 1
position x = 280, y = 108
angle min = 45, max = 315
steps start = 0, total = 100
title "Small chicken head", \
x = 0, y = -20
action turn = cb_turn_b
}
; Turnswitch type 2
widget "turnswitch" {
name "widget_c"
type 2
position x = 88, y = 310
angle min = 1, max = 359
steps start = 0, total = 359
title "Large round", \
x = 0, y = -20
action turn = cb_turn_c
}
; Turnswitch type 3
widget "turnswitch" {
name "widget_d"
type 3
position x = 296, y = 318
angle min = 1, max = 359
steps start = 0, total = 359
title "Small round", \
x = 0, y = -20
action turn = cb_turn_d
}
; Turnswitch type 4
widget "turnswitch" {
name "widget_e"
type 4
position x = 96, y = 500
angle min = 5, max = 355
steps start = 0, total = 9
title "Large flat-top", \
x = 0, y = -20
action turn = cb_turn_e
}
; Turnswitch type 5
widget "turnswitch" {
name "widget_f"
type 5
position x = 304, y = 508
angle min = 5, max = 355
steps start = 0, total = 11
title "Lights, please!", \
x = 0, y = -20
action turn = cb_turn_f
}
; Lamp type 0
widget "lamp" {
name "lamp_a"
position x = 440, y = 80
title "Red lamp", \
x = 0, y = -10
}
; Lamp type 1
widget "lamp" {
name "lamp_b"
type 1
position x = 558, y = 80
title "Orange", \
x = 0, y = -10
}
; Lamp type 2
widget "lamp" {
name "lamp_c"
type 2
position x = 676, y = 80
title "White", \
x = 0, y = -10
}
; Lamp type 3
widget "lamp" {
name "lamp_d"
type 3
position x = 440, y = 240
title "Green", \
x = 0, y = -10
}
; Lamp type 4
widget "lamp" {
name "lamp_e"
type 4
position x = 558, y = 240
title "Blue", \
x = 0, y = -10
}
; Lamp type 5
widget "lamp" {
name "lamp_f"
type 5
position x = 676, y = 240
title "Purple", \
x = 0, y = -10
}
; Led type 1, subtype 0
widget "led_1" {
name "led_a_a"
position x = 460, y = 400
}
; Led type 1, subtype 1
widget "led_1" {
name "led_a_b"
type 1
position x = 460, y = 432
}
; Led type 1, subtype 2
widget "led_1" {
name "led_a_c"
type 2
position x = 460, y = 464
}
; Led type 1, subtype 3
widget "led_1" {
name "led_a_d"
type 3
position x = 460, y = 496
}
; Led type 1, subtype 4
widget "led_1" {
name "led_a_e"
type 4
position x = 460, y = 528
}
; Led type 1, subtype 5
widget "led_1" {
name "led_a_f"
type 5
position x = 460, y = 560
}
; Led type 2, subtype 0
widget "led_2" {
name "led_b_a"
position x = 584, y = 400
}
; Led type 2, subtype 1
widget "led_2" {
name "led_b_b"
type 1
position x = 584, y = 432
}
; Led type 2, subtype 2
widget "led_2" {
name "led_b_c"
type 2
position x = 584, y = 464
}
; Led type 2, subtype 3
widget "led_2" {
name "led_b_d"
type 3
position x = 584, y = 496
}
; Led type 2, subtype 4
widget "led_2" {
name "led_b_e"
type 4
position x = 584, y = 528
}
; Led type 2, subtype 5
widget "led_2" {
name "led_b_f"
type 5
position x = 584, y = 560
}
; Led type 3, subtype 0
widget "led_3" {
name "led_c_a"
position x = 716, y = 396
}
; Led type 3, subtype 1
widget "led_3" {
name "led_c_b"
type 1
position x = 716, y = 428
}
; Led type 3, subtype 2
widget "led_3" {
name "led_c_c"
type 2
position x = 716, y = 460
}
; Led type 3, subtype 3
widget "led_3" {
name "led_c_d"
type 3
position x = 716, y = 492
}
; Led type 3, subtype 4
widget "led_3" {
name "led_c_e"
type 4
position x = 716, y = 524
}
; Led type 3, subtype 5
widget "led_3" {
name "led_c_f"
type 5
position x = 716, y = 556
}
; Pushbutton type 1, subtype 0
widget "pushbutton_1" {
name "button_a"
position x = 514, y = 420
title "Red button", \
size = 10, x = 0, y = -10
action push = cb_push_a
}
; Pushbutton type 2, subtype 1
widget "pushbutton_2" {
name "button_b"
type 1
position x = 510, y = 480
title "Yellow", \
size = 10, x = 0, y = -10
action push = cb_push_b
}
; Pushbutton type 3, subtype 2
widget "pushbutton_3" {
name "button_c"
type 2
position x = 510, y = 548
title "Sticky", \
size = 10, x = 0, y = -10
sticky yes
action push = cb_push_c
}
; Led for sticky button
widget "led_1" {
name "led_button_c"
type 3
position x = 654, y = 548
title "Sticky?", \
size = 10, x = 0, y = -10
}
; Pushbutton type 1, subtype 3
widget "pushbutton_1" {
name "button_d"
type 3
position x = 646, y = 400
action push = cb_push_a
}
; Pushbutton type 1, subtype 4
widget "pushbutton_1" {
name "button_e"
type 4
position x = 646, y = 430
action push = cb_push_a
}
; Pushbutton type 1, subtype 5
widget "pushbutton_1" {
name "button_f"
type 5
position x = 646, y = 460
action push = cb_push_a
}
; Sliders
widget "slideswitch" {
name "slider_a"
type 1
position x = 70, y = 680
slide length = 100, start = 0, total = 100
title "Channel A", \
size = 10, x = 0, y = -10
trigger release
action slide = cb_turn_a
}
widget "slideswitch" {
name "slider_b"
type 1
position x = 170, y = 680
slide length = 100, start = 0, total = 100
title "Channel B", \
size = 10, x = 0, y = -10
trigger release
action slide = cb_turn_a
}
widget "slideswitch" {
name "slider_c"
type 3
position x = 280, y = 704
slide length = 100, start = 0, total = 100
title "Channel C", \
size = 10, x = 0, y = -34
trigger release
action slide = cb_turn_a
}
widget "slideswitch" {
name "slider_d"
type 3
position x = 360, y = 704
slide length = 100, start = 0, total = 100
title "Channel D", \
size = 10, x = 0, y = -34
trigger release
action slide = cb_turn_a
}
widget "slideswitch" {
name "slider_e"
type 5
position x = 470, y = 680
slide length = 100, start = 0, total = 100
title "Channel E", \
size = 10, x = 0, y = -10
trigger release
action slide = cb_turn_a
}
widget "slideswitch" {
name "slider_f"
type 5
position x = 550, y = 680
slide length = 100, start = 0, total = 100
title "Channel F", \
size = 10, x = 0, y = -10
trigger release
action slide = cb_turn_a
}
widget "slideswitch" {
name "slider_g"
type 0
position x = 650, y = 680
slide length = 50, start = 0, total = 100
title "More sliders", \
size = 10, x = 0, y = -10
trigger release
action slide = cb_turn_a
}
widget "slideswitch" {
name "slider_h"
type 0
position x = 650, y = 740
slide length = 50, start = 0, total = 100
trigger release
action slide = cb_turn_a
}
}
}
Copyright © 2023, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.

