mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
93 lines
No EOL
1.8 KiB
Text
93 lines
No EOL
1.8 KiB
Text
function widget() constructor {
|
|
active = false;
|
|
hover = false;
|
|
iactive = false;
|
|
ihover = false;
|
|
parent = noone;
|
|
interactable = true;
|
|
|
|
lua_thread = noone;
|
|
lua_thread_key = "";
|
|
|
|
x = 0;
|
|
y = 0;
|
|
w = 0;
|
|
h = 0;
|
|
|
|
rx = 0;
|
|
ry = 0;
|
|
|
|
static setLua = function(_lua_thread, _lua_key, _lua_func) {
|
|
lua_thread = _lua_thread;
|
|
lua_thread_key = _lua_key;
|
|
onModify = method(self, _lua_func);
|
|
}
|
|
|
|
static setInteract = function(interactable = noone) {
|
|
self.interactable = interactable;
|
|
}
|
|
|
|
static register = function(parent = noone) {
|
|
if(!interactable) return;
|
|
|
|
array_push(WIDGET_ACTIVE, self);
|
|
self.parent = parent;
|
|
}
|
|
|
|
static trigger = function() { }
|
|
|
|
static parentFocus = function() {
|
|
if(parent == noone) return;
|
|
|
|
if(y < 0)
|
|
parent.scroll_y_to += abs(y) + ui(16);
|
|
else if(y + ui(16) > parent.surface_h)
|
|
parent.scroll_y_to -= abs(parent.surface_h - y) + h + ui(16);
|
|
}
|
|
|
|
static activate = function() {
|
|
if(!interactable) return;
|
|
|
|
WIDGET_CURRENT = self;
|
|
WIDGET_CURRENT_SCROLL = parent;
|
|
parentFocus();
|
|
}
|
|
|
|
static deactivate = function() {
|
|
if(WIDGET_CURRENT != self) return;
|
|
WIDGET_CURRENT = noone;
|
|
WIDGET_CURRENT_SCROLL = noone;
|
|
}
|
|
|
|
static setFocusHover = function(active = false, hover = false) {
|
|
self.active = interactable && active;
|
|
self.hover = interactable && hover;
|
|
self.iactive = active;
|
|
self.ihover = hover;
|
|
}
|
|
|
|
static resetFocus = function() {
|
|
active = false;
|
|
hover = false;
|
|
}
|
|
|
|
static drawParam = function(params) {}
|
|
static draw = function() {}
|
|
}
|
|
|
|
function widgetParam(x, y, w, h, data, extra_data, m, rx = 0, ry = 0) constructor {
|
|
self.x = x;
|
|
self.y = y;
|
|
|
|
self.w = w;
|
|
self.h = h;
|
|
self.s = ui(28);
|
|
self.data = data;
|
|
self.extra_data = extra_data;
|
|
self.m = m;
|
|
self.rx = rx;
|
|
self.ry = ry;
|
|
|
|
self.halign = fa_left;
|
|
self.valign = fa_top;
|
|
} |