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

Lights off
Lights on

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 © 2023, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.