Add NeoUI 240x320 UI SDK, migrate all GUI plugins, add Yabasic FFI wrapper and fix camera rotation

This commit is contained in:
Luxferre committed 2026-10-26 19:11:58 +02:00
1 parent 1f9138f0c6
commit c137feee0e
59 files changed
+5932 -2128

No files matched your search

+485
View File
@@ -0,0 +1,485 @@
// ============================================================================
// neoui.yab - Yabasic Native C FFI Wrapper for Bananarchy NeoUI (libneoui.so)
// ============================================================================
// Exposes all NeoUI 240x320 X11 + Pango/Xft + .Xresources/.xth UI SDK
// functions to Yabasic programs via libffi (frnfn_call / frnfn_call$).
//
// Usage in your Yabasic program:
// import neoui
// neoui_init("myapp", 0)
// ============================================================================
NEOUI_LIB$ = "/usr/lib/libneoui.so"
// ----------------------------------------------------------------------------
// Geometry Constants (240x320 QVGA)
// ----------------------------------------------------------------------------
SCREEN_W = 240
SCREEN_H = 320
TOPBAR_H = 24
WIN_X = 0
WIN_Y = 24
WIN_W = 240
WIN_H = 296
HEADER_H = 34
SOFTBAR_H = 26
// ----------------------------------------------------------------------------
// Theme Color Token IDs for neoui_color(color_id)
// ----------------------------------------------------------------------------
COLOR_BG_MAIN = 0
COLOR_BG_BAR = 1
COLOR_BG_HEADER = 2
COLOR_BG_FOOTER = 3
COLOR_BG_OVERLAY = 4
COLOR_BG_ALT_EVEN = 5
COLOR_BG_ALT_ODD = 6
COLOR_BG_INPUT = 7
COLOR_BG_INPUT_FOCUS = 8
COLOR_BG_BUTTON = 9
COLOR_BG_SEARCH = 10
COLOR_BG_BUBBLE_IN = 11
COLOR_BG_BUBBLE_OUT = 12
COLOR_BG_TOAST = 13
COLOR_FG_MAIN = 14
COLOR_FG_BRIGHT = 15
COLOR_FG_MUTED = 16
COLOR_SEL_BG = 17
COLOR_SEL_FG = 18
COLOR_ACCENT = 19
COLOR_ACCENT_ALT = 20
COLOR_HIGHLIGHT = 21
COLOR_BORDER = 22
COLOR_DIVIDER = 23
COLOR_SUCCESS = 24
COLOR_INFO = 25
COLOR_WARNING = 26
COLOR_DANGER = 27
COLOR_DANGER_BG = 28
// ----------------------------------------------------------------------------
// Proportional Pango Font Roles
// ----------------------------------------------------------------------------
FONT_SMALL = 0
FONT_MAIN = 1
FONT_ICON = 2
FONT_LARGE = 3
// ----------------------------------------------------------------------------
// Semantic Xft Text Color Roles
// ----------------------------------------------------------------------------
TEXT_WHITE = 0
TEXT_LIGHT = 1
TEXT_MUTED = 2
TEXT_YELLOW = 3
TEXT_GREEN = 4
TEXT_BLUE = 5
TEXT_ORANGE = 6
TEXT_RED = 7
// ----------------------------------------------------------------------------
// Event Types returned by neoui_poll_event(timeout_ms)
// ----------------------------------------------------------------------------
EV_NONE = 0
EV_EXPOSE = 1
EV_KEY_PRESS = 2
EV_KEY_RELEASE = 3
EV_SOFTKEY_LEFT = 4
EV_SOFTKEY_RIGHT = 5
EV_SOFTKEY_CHORD = 6
EV_FIFO_CMD = 7
EV_THEME_RELOAD = 8
EV_CLOSE_REQ = 9
// ----------------------------------------------------------------------------
// Logical Keypad Key Codes returned by neoui_event_key()
// ----------------------------------------------------------------------------
KEY_NONE = 0
KEY_UP = 1
KEY_DOWN = 2
KEY_LEFT = 3
KEY_RIGHT = 4
KEY_OK = 5
KEY_BACK = 6
KEY_CALL = 7
KEY_END = 8
KEY_SOFT_LEFT = 9
KEY_SOFT_RIGHT = 10
KEY_SPACE = 32
KEY_HASH = 35
KEY_STAR = 42
KEY_PLUS = 43
KEY_0 = 48
KEY_1 = 49
KEY_2 = 50
KEY_3 = 51
KEY_4 = 52
KEY_5 = 53
KEY_6 = 54
KEY_7 = 55
KEY_8 = 56
KEY_9 = 57
// ----------------------------------------------------------------------------
// Multi-Tap Input Modes
// ----------------------------------------------------------------------------
INPUT_ABC_TITLE = 0
INPUT_ABC_LOWER = 1
INPUT_ABC_UPPER = 2
INPUT_123 = 3
INPUT_SYM = 4
// ----------------------------------------------------------------------------
// Image Scaling Modes
// ----------------------------------------------------------------------------
SCALE_FIT = 0
SCALE_FILL = 1
SCALE_STRETCH = 2
// ============================================================================
// 1. Window & Daemon Lifecycle
// ============================================================================
export sub neoui_init(app_name$, preload_mode)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_init", "string", app_name$, "int32", preload_mode)
end sub
export sub neoui_init_ex(app_name$, res_name$, res_class$, win_title$, x, y, w, h, override_redirect, preload_mode)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_init_ex", "string", app_name$, "string", res_name$, "string", res_class$, "string", win_title$, "int32", x, "int32", y, "int32", w, "int32", h, "int32", override_redirect, "int32", preload_mode)
end sub
export sub neoui_shutdown()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_shutdown")
end sub
export sub neoui_show()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_show")
end sub
export sub neoui_hide()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_hide")
end sub
export sub neoui_is_visible()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_is_visible")
end sub
export sub neoui_raise_and_grab()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_raise_and_grab")
end sub
export sub neoui_ungrab()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_ungrab")
end sub
export sub neoui_width()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_width")
end sub
export sub neoui_height()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_height")
end sub
export sub neoui_begin_frame()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_begin_frame")
end sub
export sub neoui_end_frame()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_end_frame")
end sub
export sub neoui_flush()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_flush")
end sub
// ============================================================================
// 2. Unified .Xresources / .xth Theme & Icon Resolution
// ============================================================================
export sub neoui_reload_theme()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_reload_theme")
end sub
export sub neoui_check_reload_theme()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_check_reload_theme")
end sub
export sub neoui_apply_theme_file(xth_path$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_apply_theme_file", "string", xth_path$)
end sub
export sub neoui_broadcast_theme_reload(skip_plugin$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_broadcast_theme_reload", "string", skip_plugin$)
end sub
export sub neoui_theme_name$()
return frnfn_call$(NEOUI_LIB$, "string", "neoui_theme_name", "options", "copy_string_result")
end sub
export sub neoui_font_face$()
return frnfn_call$(NEOUI_LIB$, "string", "neoui_font_face", "options", "copy_string_result")
end sub
export sub neoui_icon_font_face$()
return frnfn_call$(NEOUI_LIB$, "string", "neoui_icon_font_face", "options", "copy_string_result")
end sub
export sub neoui_base_font_size()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_base_font_size")
end sub
export sub neoui_font_size(font_role)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_font_size", "int32", font_role)
end sub
export sub neoui_color(color_id)
return frnfn_call(NEOUI_LIB$, "uint32", "neoui_color", "int32", color_id)
end sub
export sub neoui_adjust_rgb(rgb, delta)
return frnfn_call(NEOUI_LIB$, "uint32", "neoui_adjust_rgb", "uint32", rgb, "int32", delta)
end sub
export sub neoui_blend_rgb(c1, c2, weight2_pct)
return frnfn_call(NEOUI_LIB$, "uint32", "neoui_blend_rgb", "uint32", c1, "uint32", c2, "int32", weight2_pct)
end sub
export sub neoui_parse_hex_rgb(hex_str$, fallback_rgb)
return frnfn_call(NEOUI_LIB$, "uint32", "neoui_parse_hex_rgb", "string", hex_str$, "uint32", fallback_rgb)
end sub
export sub neoui_format_hex_rgb$(rgb)
return frnfn_call$(NEOUI_LIB$, "string", "neoui_format_hex_rgb", "uint32", rgb, "options", "copy_string_result")
end sub
export sub neoui_icon$(icon_name$)
return frnfn_call$(NEOUI_LIB$, "string", "neoui_icon", "string", icon_name$, "options", "copy_string_result")
end sub
// ============================================================================
// 3. Drawing Primitives & Text Rendering
// ============================================================================
export sub neoui_clear(rgb)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_clear", "uint32", rgb)
end sub
export sub neoui_fill_rect(x, y, w, h, rgb)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_fill_rect", "int32", x, "int32", y, "int32", w, "int32", h, "uint32", rgb)
end sub
export sub neoui_draw_rect(x, y, w, h, rgb)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_rect", "int32", x, "int32", y, "int32", w, "int32", h, "uint32", rgb)
end sub
export sub neoui_draw_line(x1, y1, x2, y2, rgb)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_line", "int32", x1, "int32", y1, "int32", x2, "int32", y2, "uint32", rgb)
end sub
export sub neoui_set_clip(x, y, w, h)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_set_clip", "int32", x, "int32", y, "int32", w, "int32", h)
end sub
export sub neoui_reset_clip()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_reset_clip")
end sub
export sub neoui_draw_text(font_role, color_role, x, y, h, text$, max_w)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_text", "int32", font_role, "int32", color_role, "int32", x, "int32", y, "int32", h, "string", text$, "int32", max_w)
end sub
export sub neoui_draw_text_centered(font_role, color_role, x, y, w, h, text$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_text_centered", "int32", font_role, "int32", color_role, "int32", x, "int32", y, "int32", w, "int32", h, "string", text$)
end sub
export sub neoui_draw_text_right(font_role, color_role, right_x, y, h, text$, max_w)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_text_right", "int32", font_role, "int32", color_role, "int32", right_x, "int32", y, "int32", h, "string", text$, "int32", max_w)
end sub
export sub neoui_draw_text_wrapped(font_role, color_role, x, y, w, h, text$, scroll_line)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_text_wrapped", "int32", font_role, "int32", color_role, "int32", x, "int32", y, "int32", w, "int32", h, "string", text$, "int32", scroll_line)
end sub
export sub neoui_text_width(font_role, text$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_text_width", "int32", font_role, "string", text$)
end sub
export sub neoui_tail_fit_text$(font_role, text$, max_w)
return frnfn_call$(NEOUI_LIB$, "string", "neoui_tail_fit_text", "int32", font_role, "string", text$, "int32", max_w, "options", "copy_string_result")
end sub
export sub neoui_draw_image_file(path$, x, y, w, h, scale_mode)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_image_file", "string", path$, "int32", x, "int32", y, "int32", w, "int32", h, "int32", scale_mode)
end sub
// ============================================================================
// 4. Standardized OS Shell UI Components (Widgets)
// ============================================================================
export sub neoui_draw_header(icon_str$, icon_color_role, title$, right_badge$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_header", "string", icon_str$, "int32", icon_color_role, "string", title$, "string", right_badge$)
end sub
export sub neoui_draw_header_ex(h, icon_str$, icon_color_role, title$, title_color_role, right_badge$, right_color_role)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_header_ex", "int32", h, "string", icon_str$, "int32", icon_color_role, "string", title$, "int32", title_color_role, "string", right_badge$, "int32", right_color_role)
end sub
export sub neoui_draw_tabs(pipe_labels$, active_idx, y, h)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_tabs", "string", pipe_labels$, "int32", active_idx, "int32", y, "int32", h)
end sub
export sub neoui_draw_softkeys(left_label$, center_label$, right_label$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_softkeys", "string", left_label$, "string", center_label$, "string", right_label$)
end sub
export sub neoui_draw_softkeys_ex(left_label$, center_label$, right_label$, center_color_role)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_softkeys_ex", "string", left_label$, "string", center_label$, "string", right_label$, "int32", center_color_role)
end sub
export sub neoui_draw_list_row(row_index, y, h, is_selected, icon_str$, icon_color_role, title$, subtitle$, right_text$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_list_row", "int32", row_index, "int32", y, "int32", h, "int32", is_selected, "string", icon_str$, "int32", icon_color_role, "string", title$, "string", subtitle$, "string", right_text$)
end sub
export sub neoui_draw_slider_row(row_index, y, h, is_selected, icon_str$, icon_color_role, label$, pct, value_text$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_slider_row", "int32", row_index, "int32", y, "int32", h, "int32", is_selected, "string", icon_str$, "int32", icon_color_role, "string", label$, "int32", pct, "string", value_text$)
end sub
export sub neoui_draw_toggle_row(row_index, y, h, is_selected, icon_str$, icon_color_role, label$, is_on, state_text$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_toggle_row", "int32", row_index, "int32", y, "int32", h, "int32", is_selected, "string", icon_str$, "int32", icon_color_role, "string", label$, "int32", is_on, "string", state_text$)
end sub
export sub neoui_draw_button(x, y, w, h, is_selected, is_danger, icon_str$, label$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_button", "int32", x, "int32", y, "int32", w, "int32", h, "int32", is_selected, "int32", is_danger, "string", icon_str$, "string", label$)
end sub
export sub neoui_draw_input_box(x, y, w, h, is_focused, label$, value$, placeholder$, password_mask)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_input_box", "int32", x, "int32", y, "int32", w, "int32", h, "int32", is_focused, "string", label$, "string", value$, "string", placeholder$, "int32", password_mask)
end sub
export sub neoui_draw_progress_bar(x, y, w, h, pct, fill_rgb)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_progress_bar", "int32", x, "int32", y, "int32", w, "int32", h, "int32", pct, "uint32", fill_rgb)
end sub
export sub neoui_draw_scrollbar(x, y, h, total_items, visible_items, scroll_offset)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_scrollbar", "int32", x, "int32", y, "int32", h, "int32", total_items, "int32", visible_items, "int32", scroll_offset)
end sub
export sub neoui_draw_modal_box(x, y, w, h, icon_str$, icon_color_role, title$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_modal_box", "int32", x, "int32", y, "int32", w, "int32", h, "string", icon_str$, "int32", icon_color_role, "string", title$)
end sub
export sub neoui_draw_confirm_dialog(title$, line1$, line2$, no_label$, yes_label$, selected_yes)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_confirm_dialog", "string", title$, "string", line1$, "string", line2$, "string", no_label$, "string", yes_label$, "int32", selected_yes)
end sub
export sub neoui_draw_menu_popup(pipe_items$, pipe_icons$, selected_idx, max_visible_rows)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_menu_popup", "string", pipe_items$, "string", pipe_icons$, "int32", selected_idx, "int32", max_visible_rows)
end sub
export sub neoui_draw_toast(message$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_toast", "string", message$)
end sub
export sub neoui_show_toast(message$, duration_ms)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_show_toast", "string", message$, "int32", duration_ms)
end sub
export sub neoui_clear_toast()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_clear_toast")
end sub
// ============================================================================
// 5. Event Loop, Keypad & Multi-Tap Input Management
// ============================================================================
export sub neoui_poll_event(timeout_ms)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_poll_event", "int32", timeout_ms)
end sub
export sub neoui_event_key()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_event_key")
end sub
export sub neoui_event_keycode()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_event_keycode")
end sub
export sub neoui_event_keysym()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_event_keysym")
end sub
export sub neoui_event_command$()
return frnfn_call$(NEOUI_LIB$, "string", "neoui_event_command", "options", "copy_string_result")
end sub
export sub neoui_set_chord_xdrawer(enabled)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_set_chord_xdrawer", "int32", enabled)
end sub
export sub neoui_input_reset(initial_text$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_reset", "string", initial_text$)
end sub
export sub neoui_input_set_text(text$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_set_text", "string", text$)
end sub
export sub neoui_input_get_text$()
return frnfn_call$(NEOUI_LIB$, "string", "neoui_input_get_text", "options", "copy_string_result")
end sub
export sub neoui_input_set_mode(mode)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_set_mode", "int32", mode)
end sub
export sub neoui_input_get_mode()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_get_mode")
end sub
export sub neoui_input_cycle_mode()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_cycle_mode")
end sub
export sub neoui_input_mode_badge$()
return frnfn_call$(NEOUI_LIB$, "string", "neoui_input_mode_badge", "options", "copy_string_result")
end sub
export sub neoui_input_feed_key(neo_key)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_feed_key", "int32", neo_key)
end sub
export sub neoui_input_commit_tap()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_commit_tap")
end sub
export sub neoui_input_backspace()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_backspace")
end sub
export sub neoui_input_is_tap_active()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_input_is_tap_active")
end sub
export sub neoui_input_candidate_bar$(idle_hint$)
return frnfn_call$(NEOUI_LIB$, "string", "neoui_input_candidate_bar", "string", idle_hint$, "options", "copy_string_result")
end sub
export sub neoui_draw_multitap_bar(x, y, w, h, idle_hint$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_draw_multitap_bar", "int32", x, "int32", y, "int32", w, "int32", h, "string", idle_hint$)
end sub
// ============================================================================
// 6. System & IPC Utilities
// ============================================================================
export sub neoui_send_plugin_cmd(plugin_name$, cmd$)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_send_plugin_cmd", "string", plugin_name$, "string", cmd$)
end sub
export sub neoui_vibrate(duration_ms)
return frnfn_call(NEOUI_LIB$, "int32", "neoui_vibrate", "int32", duration_ms)
end sub
export sub neoui_now_ms()
return frnfn_call(NEOUI_LIB$, "int32", "neoui_now_ms")
end sub
+414
View File
@@ -0,0 +1,414 @@
#!/usr/bin/yabasic
// ============================================================================
// neoui_demo.yab - Bananarchy NeoUI SDK Showcase for Yabasic
// ============================================================================
// Demonstrates:
// - Live .Xresources / ~/.xthemes/*.xth theme resolution & hot-reload
// - Header bar, 3-Tab navigation bar, and Softkey bar
// - List rows, Toggle rows, Slider rows, Progress bars, and Buttons
// - Multi-tap T9 keypad text input with scrolling candidate bar & mode badge
// - Custom drawing primitives, Nerd Font icons, and theme color swatches
// - Popup action menu, Confirmation dialog, and Toast notification banner
//
// Controls:
// - 1 / 2 / 3 (when not typing): Switch tabs (Widgets / Input / Theme)
// - Up / Down: Navigate rows or menu items
// - Left / Right: Adjust sliders, switch tabs, or toggle No/Yes in dialog
// - OK (Enter): Toggle item / Submit text / Trigger action
// - Left Softkey (F1): Open Action Menu
// - Right Softkey (F2) / Backspace: Close modal / Delete char / Exit
// - Both Softkeys together: Open Bananarchy XDrawer overlay
// ============================================================================
import neoui
if neoui_init("neoui_demo", 0) = 0 then
print "Failed to initialize NeoUI X11 window"
exit 1
fi
// Tab index: 0 = Widgets, 1 = Input, 2 = Theme & Canvas
active_tab = 0
// Tab 0 (Widgets) state
widget_sel = 0
wifi_enabled = 1
torch_enabled = 0
volume_pct = 75
bright_pct = 80
progress_pct = 45
// Tab 1 (Multi-Tap Input) state
input_focus = 0
dim notes$(10)
notes$(0) = "Welcome to NeoUI SDK!"
notes$(1) = "Try typing with 0-9 keys"
notes$(2) = "Press # to switch mode"
note_count = 3
neoui_input_reset("Bananarchy ")
// Modal state: 0 = None, 1 = Popup Menu, 2 = Confirm Reset Dialog
modal_mode = 0
menu_sel = 0
confirm_yes = 0
sub render_widgets_tab()
local y, wifi_txt$, torch_txt$, vol_txt$, brt_txt$
y = 60
if wifi_enabled then
wifi_txt$ = "Connected"
else
wifi_txt$ = "Off"
fi
neoui_draw_toggle_row(0, y, 36, widget_sel = 0, neoui_icon$("wifi"), neoui.TEXT_BLUE, "Wi-Fi Radio", wifi_enabled, wifi_txt$)
y = y + 36
if torch_enabled then
torch_txt$ = "Active"
else
torch_txt$ = "Off"
fi
neoui_draw_toggle_row(1, y, 36, widget_sel = 1, neoui_icon$("torch"), neoui.TEXT_YELLOW, "Flashlight", torch_enabled, torch_txt$)
y = y + 36
vol_txt$ = str$(volume_pct) + "%"
neoui_draw_slider_row(2, y, 38, widget_sel = 2, neoui_icon$("speaker"), neoui.TEXT_GREEN, "Speaker Vol", volume_pct, vol_txt$)
y = y + 38
brt_txt$ = str$(bright_pct) + "%"
neoui_draw_slider_row(3, y, 38, widget_sel = 3, neoui_icon$("sun"), neoui.TEXT_ORANGE, "Backlight", bright_pct, brt_txt$)
y = y + 42
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_MUTED, 8, y, 14, "Task Progress (" + str$(progress_pct) + "%)", 160)
neoui_draw_progress_bar(8, y + 15, 224, 10, progress_pct, neoui_color(neoui.COLOR_ACCENT))
y = y + 30
neoui_draw_button(12, y, 104, 26, widget_sel = 4, 0, neoui_icon$("check"), "Step +15%")
neoui_draw_button(124, y, 104, 26, widget_sel = 5, 1, neoui_icon$("trash"), "Reset All")
neoui_draw_scrollbar(236, 60, 210, 6, 6, 0)
end sub
sub render_input_tab()
local i, y, txt$, badge$
txt$ = neoui_input_get_text$()
badge$ = neoui_input_mode_badge$()
neoui_draw_input_box(8, 64, 224, 42, input_focus = 0, "Multi-Tap Keypad Input [" + badge$ + "]", txt$, "Type with 0-9, # mode...", 0)
neoui_draw_button(8, 110, 108, 24, input_focus = 1, 0, neoui_icon$("plus"), "Add Note")
neoui_draw_button(124, 110, 108, 24, input_focus = 2, 0, neoui_icon$("refresh"), "Clear Text")
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_YELLOW, 8, 138, 16, "Saved Notes (" + str$(note_count) + "):", 220)
y = 156
for i = 0 to note_count - 1
if y + 28 <= 246 then
neoui_draw_list_row(i, y, 28, input_focus = (3 + i), neoui_icon$("edit"), neoui.TEXT_BLUE, notes$(i), "", "#" + str$(i + 1))
y = y + 28
fi
next i
if input_focus = 0 then
neoui_draw_multitap_bar(0, 248, 240, 22, "0-9:Type 1:Sym #:Mode OK:Add")
fi
end sub
sub render_theme_tab()
local y, c_id, sx, sy, sw, sh, rgb
y = 64
neoui_fill_rect(8, y, 224, 68, neoui_color(neoui.COLOR_BG_ALT_ODD))
neoui_draw_rect(8, y, 224, 68, neoui_color(neoui.COLOR_BORDER))
neoui_draw_text(neoui.FONT_MAIN, neoui.TEXT_YELLOW, 14, y + 4, 18, "Theme: " + neoui_theme_name$(), 210)
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_LIGHT, 14, y + 24, 16, "Font: " + neoui_font_face$() + " (" + str$(neoui_base_font_size()) + "px)", 210)
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_MUTED, 14, y + 42, 16, "BG: " + neoui_format_hex_rgb$(neoui_color(neoui.COLOR_BG_MAIN)) + " ACC: " + neoui_format_hex_rgb$(neoui_color(neoui.COLOR_ACCENT)), 210)
y = 138
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_WHITE, 8, y, 16, "Active .Xresources Palette Swatches:", 224)
y = 158
sw = 26
sh = 22
for c_id = 0 to 15
sx = 8 + mod(c_id, 8) * 28
sy = y + int(c_id / 8) * 26
rgb = neoui_color(c_id + 13)
neoui_fill_rect(sx, sy, sw, sh, rgb)
neoui_draw_rect(sx, sy, sw, sh, neoui_color(neoui.COLOR_BORDER))
next c_id
y = 214
neoui_fill_rect(8, y, 224, 48, neoui_color(neoui.COLOR_BG_HEADER))
neoui_draw_rect(8, y, 224, 48, neoui_color(neoui.COLOR_ACCENT))
neoui_draw_line(14, y + 24, 226, y + 24, neoui_color(neoui.COLOR_DIVIDER))
neoui_draw_text_centered(neoui.FONT_ICON, neoui.TEXT_YELLOW, 8, y + 2, 224, 20, neoui_icon$("phone") + " " + neoui_icon$("sms") + " " + neoui_icon$("music") + " " + neoui_icon$("camera") + " " + neoui_icon$("theme") + " " + neoui_icon$("wifi"))
neoui_draw_text_centered(neoui.FONT_SMALL, neoui.TEXT_GREEN, 8, y + 26, 224, 18, "Press OK to hot-reload .Xresources")
end sub
sub render_all()
local badge$, mid_lbl$, right_lbl$
neoui_begin_frame()
if active_tab = 1 then
badge$ = neoui_input_mode_badge$()
else
badge$ = neoui_theme_name$()
fi
neoui_draw_header(neoui_icon$("theme"), neoui.TEXT_YELLOW, "NeoUI SDK Demo", badge$)
neoui_draw_tabs("1:Widgets|2:Input|3:Theme", active_tab, 34, 24)
if active_tab = 0 then
render_widgets_tab()
mid_lbl$ = "Toggle"
right_lbl$ = "Quit"
elsif active_tab = 1 then
render_input_tab()
mid_lbl$ = "Add"
if input_focus = 0 and len(neoui_input_get_text$()) > 0 then
right_lbl$ = "Del"
else
right_lbl$ = "Quit"
fi
else
render_theme_tab()
mid_lbl$ = "Reload"
right_lbl$ = "Quit"
fi
if modal_mode = 1 then
neoui_draw_menu_popup("Show Toast Banner|Vibrate Phone|Reload Theme|Reset Demo State|Quit Demo", neoui_icon$("bell") + "|" + neoui_icon$("audio") + "|" + neoui_icon$("refresh") + "|" + neoui_icon$("trash") + "|" + neoui_icon$("close"), menu_sel, 5)
neoui_draw_softkeys("Close", "Select", "Back")
elsif modal_mode = 2 then
neoui_draw_confirm_dialog("Reset Demo State?", "Restore all sliders, toggles,", "and notes to default values?", "Cancel", "Reset", confirm_yes)
neoui_draw_softkeys("Cancel", "Confirm", "Back")
else
neoui_draw_softkeys("Menu", mid_lbl$, right_lbl$)
fi
neoui_end_frame()
end sub
sub reset_demo_state()
wifi_enabled = 1
torch_enabled = 0
volume_pct = 75
bright_pct = 80
progress_pct = 45
note_count = 3
notes$(0) = "Welcome to NeoUI SDK!"
notes$(1) = "Try typing with 0-9 keys"
notes$(2) = "Press # to switch mode"
neoui_input_reset("Bananarchy ")
neoui_show_toast("Demo state reset!", 1800)
end sub
sub add_current_note()
local t$
neoui_input_commit_tap()
t$ = neoui_input_get_text$()
if len(t$) = 0 then
neoui_show_toast("Input is empty!", 1500)
return
fi
if note_count < 10 then
notes$(note_count) = t$
note_count = note_count + 1
else
notes$(9) = t$
fi
neoui_input_reset("")
neoui_show_toast("Note added!", 1500)
end sub
render_all()
running = 1
while running
ev = neoui_poll_event(250)
if ev = neoui.EV_CLOSE_REQ then
running = 0
elsif ev = neoui.EV_EXPOSE or ev = neoui.EV_THEME_RELOAD then
render_all()
elsif ev = neoui.EV_SOFTKEY_LEFT then
if modal_mode = 0 then
modal_mode = 1
menu_sel = 0
else
modal_mode = 0
fi
render_all()
elsif ev = neoui.EV_SOFTKEY_RIGHT then
if modal_mode <> 0 then
modal_mode = 0
render_all()
elsif active_tab = 1 and input_focus = 0 and len(neoui_input_get_text$()) > 0 then
neoui_input_backspace()
render_all()
else
running = 0
fi
elsif ev = neoui.EV_KEY_PRESS then
k = neoui_event_key()
if modal_mode = 1 then
if k = neoui.KEY_UP then
menu_sel = mod(menu_sel + 4, 5)
elsif k = neoui.KEY_DOWN then
menu_sel = mod(menu_sel + 1, 5)
elsif k = neoui.KEY_BACK then
modal_mode = 0
elsif k = neoui.KEY_OK then
modal_mode = 0
if menu_sel = 0 then
neoui_show_toast("Hello from Yabasic NeoUI!", 2000)
elsif menu_sel = 1 then
neoui_vibrate(60)
neoui_show_toast("Vibrated 60 ms", 1500)
elsif menu_sel = 2 then
neoui_reload_theme()
neoui_show_toast("Theme reloaded!", 1500)
elsif menu_sel = 3 then
modal_mode = 2
confirm_yes = 1
elsif menu_sel = 4 then
running = 0
fi
fi
render_all()
elsif modal_mode = 2 then
if k = neoui.KEY_LEFT or k = neoui.KEY_RIGHT or k = neoui.KEY_UP or k = neoui.KEY_DOWN then
confirm_yes = 1 - confirm_yes
elsif k = neoui.KEY_BACK then
modal_mode = 0
elsif k = neoui.KEY_OK then
modal_mode = 0
if confirm_yes then
reset_demo_state()
fi
fi
render_all()
else
// Normal tab navigation & interaction
if active_tab = 1 and input_focus = 0 then
// When focused on the text input box, feed digits/star/hash to multi-tap
if k = neoui.KEY_UP then
input_focus = 2 + note_count
elsif k = neoui.KEY_DOWN then
input_focus = 1
elsif k = neoui.KEY_LEFT then
if neoui_input_is_tap_active() then
neoui_input_commit_tap()
else
active_tab = 0
fi
elsif k = neoui.KEY_RIGHT then
if neoui_input_is_tap_active() then
neoui_input_commit_tap()
else
active_tab = 2
fi
elsif k = neoui.KEY_OK then
add_current_note()
else
neoui_input_feed_key(k)
fi
render_all()
else
// Global tab shortcuts 1 / 2 / 3 when not typing in input box
if k = neoui.KEY_1 then
active_tab = 0
elsif k = neoui.KEY_2 then
active_tab = 1
elsif k = neoui.KEY_3 then
active_tab = 2
elsif k = neoui.KEY_BACK then
running = 0
elsif active_tab = 0 then
if k = neoui.KEY_UP then
widget_sel = mod(widget_sel + 5, 6)
elsif k = neoui.KEY_DOWN then
widget_sel = mod(widget_sel + 1, 6)
elsif k = neoui.KEY_LEFT then
if widget_sel = 2 then
volume_pct = max(0, volume_pct - 5)
elsif widget_sel = 3 then
bright_pct = max(5, bright_pct - 5)
else
active_tab = 2
fi
elsif k = neoui.KEY_RIGHT then
if widget_sel = 2 then
volume_pct = min(100, volume_pct + 5)
elsif widget_sel = 3 then
bright_pct = min(100, bright_pct + 5)
else
active_tab = 1
fi
elsif k = neoui.KEY_OK then
if widget_sel = 0 then
wifi_enabled = 1 - wifi_enabled
neoui_show_toast("Wi-Fi toggled", 1200)
elsif widget_sel = 1 then
torch_enabled = 1 - torch_enabled
neoui_show_toast("Flashlight toggled", 1200)
elsif widget_sel = 4 then
progress_pct = mod(progress_pct + 15, 105)
if progress_pct > 100 then progress_pct = 0 fi
elsif widget_sel = 5 then
modal_mode = 2
confirm_yes = 1
fi
fi
elsif active_tab = 1 then
total_focus = 3 + note_count
if k = neoui.KEY_UP then
input_focus = mod(input_focus + total_focus - 1, total_focus)
elsif k = neoui.KEY_DOWN then
input_focus = mod(input_focus + 1, total_focus)
elsif k = neoui.KEY_LEFT then
if input_focus = 2 then
input_focus = 1
else
active_tab = 0
fi
elsif k = neoui.KEY_RIGHT then
if input_focus = 1 then
input_focus = 2
else
active_tab = 2
fi
elsif k = neoui.KEY_OK then
if input_focus = 1 then
add_current_note()
elsif input_focus = 2 then
neoui_input_reset("")
neoui_show_toast("Input cleared", 1200)
fi
fi
elsif active_tab = 2 then
if k = neoui.KEY_LEFT then
active_tab = 1
elsif k = neoui.KEY_RIGHT then
active_tab = 0
elsif k = neoui.KEY_OK then
neoui_reload_theme()
neoui_show_toast("Reloaded .Xresources theme!", 1600)
fi
fi
render_all()
fi
fi
fi
wend
neoui_shutdown()