autocomplete

This commit is contained in:
Tanasart 2024-04-10 10:02:23 +07:00
parent 454bdfe3c3
commit d69665f802
13 changed files with 64 additions and 26 deletions

View file

@ -4,7 +4,9 @@
#macro DIALOG_DRAW_FOCUS draw_sprite_stretched_ext(THEME.dialog_active, 0, dialog_x - 8, dialog_y - 8, dialog_w + 16, dialog_h + 16, COLORS._main_accent, 1);
#region data
with(_p_dialog) other.depth = min(depth - 1, other.depth);
on_top = false;
with(_p_dialog) { if(on_top) continue; other.depth = min(depth - 1, other.depth); }
ds_list_add(DIALOGS, self);

View file

@ -137,7 +137,7 @@ event_inherited();
if(dl.status == 0 && hov) {
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS)) {
var path = get_save_filename("Compressed zip (.zip)| *.zip", $"PixelComposer {vr}.zip");
var path = get_save_filename_ext("Compressed zip (.zip)| *.zip", $"PixelComposer {vr}.zip", "", "Download location");
if(path != "") {
dl.status = 1;
dl.download_path = path;

View file

@ -14,19 +14,35 @@ if (_id == note_get) {
dls = json_try_parse(res, []);
for( var i = 0, n = array_length(dls); i < n; i++ ) {
var _v = dls[i].version;
dls[i].status = 0;
dls[i].download_path = "";
dls[i].size_total = 0;
dls[i].size_downloaded = 0;
if(struct_has(PREFERENCES.versions, _v)) {
var _path = PREFERENCES.versions[$ _v];
if(file_exists(_path)) {
dls[i].status = 2;
dls[i].download_path = _path;
dls[i].size_total = file_size(_path);
}
}
}
PREF_SAVE();
}
} else if ( struct_has(downloading, _id)) {
var dl = downloading[$ _id];
if(_status == 0) {
dl.status = 2;
PREFERENCES.versions[$ dl.version] = dl.download_path;
PREF_SAVE();
} else if(_status == 1) {
dl.size_total = ds_map_find_value(async_load, "contentLength");

View file

@ -8,6 +8,7 @@ event_inherited();
dialog_y = 0;
dialog_w = 300;
dialog_h = 160;
on_top = true;
selecting = 0;
textbox = noone;
@ -43,8 +44,10 @@ event_inherited();
if(sHOVER && point_in_rectangle(_m[0], _m[1], 0, _ly + 1, _dw, _ly + hght - 1)) {
selecting = i;
if(mouse_press(mb_left))
if(mouse_press(mb_left)) {
applyAutoComplete(_dat[3]);
MOUSE_BLOCK = true;
}
}
if(selecting == i) {
@ -78,7 +81,8 @@ event_inherited();
}
if(keyboard_check_pressed(vk_down)) {
selecting = safe_mod(selecting + 1, array_length(data));
selecting++
if(selecting >= array_length(data) - 1) selecting = 0;
sc_content.scroll_y_to = -(selecting - 2) * hght;
}

View file

@ -3,6 +3,7 @@ active = textbox != noone && array_length(data);
if(textbox == noone) exit;
if(textbox != WIDGET_CURRENT) exit;
if(array_empty(data)) exit;
if(dialog_x == 0 && dialog_y == 0) exit;
#region
dialog_x = clamp(dialog_x, 0, WIN_W - dialog_w - 1);
@ -32,7 +33,7 @@ if(array_empty(data)) exit;
#region draw
draw_sprite_stretched(THEME.textbox, 3, dialog_x, dialog_y, dialog_w, dialog_h);
sc_content.setFocusHover(sFOCUS, sHOVER);
sc_content.setFocusHover(true, true);
sc_content.draw(dialog_x, dialog_y);
draw_sprite_stretched(THEME.textbox, 1, dialog_x, dialog_y, dialog_w, dialog_h);
#endregion

View file

@ -0,0 +1,9 @@
/// @description Insert description here
if(textbox == noone) exit;
if(textbox != WIDGET_CURRENT) exit;
if(array_empty(data)) exit;
if(point_in_rectangle(mouse_mx, mouse_my, dialog_x, dialog_y, dialog_x + dialog_w, dialog_y + dialog_h)) {
HOVER = self.id;
if(mouse_press(mb_left)) FOCUS = self.id;
}

View file

@ -4,6 +4,7 @@
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"o_dialog_textbox_autocomplete",
@ -12,10 +13,7 @@
"name":"widget",
"path":"folders/dialog/widget.yy",
},
"parentObjectId":{
"name":"_p_dialog",
"path":"objects/_p_dialog/_p_dialog.yy",
},
"parentObjectId":null,
"persistent":false,
"physicsAngularDamping":0.1,
"physicsDensity":0.5,

View file

@ -165,7 +165,7 @@ function colorSelector(onApply = noone) constructor {
draw_sprite_stretched(THEME.ui_panel_bg, 1, col_x - ui(8), col_y - ui(8), ui(256 + 16), ui(256 + 16));
color_surface = surface_verify(color_surface, 256, 256);
color_surface = surface_verify(color_surface, ui(256), ui(256));
surface_set_target(color_surface);
if(disp_mode == 0) {
shader_set(sh_color_picker_hue);
@ -179,7 +179,7 @@ function colorSelector(onApply = noone) constructor {
shader_set_palette(palette);
}
draw_sprite_uniform(s_fx_pixel, 0, 0, 0, 256);
draw_sprite_uniform(s_fx_pixel, 0, 0, 0, ui(256));
shader_reset();
surface_reset_target();

View file

@ -46,7 +46,7 @@
globalvar TOOLTIP, DRAGGING, DIALOG_DEPTH_HOVER;
global.KEYS = {
download_links: ""
download_links: "",
};
#endregion

View file

@ -49,9 +49,12 @@ function Node_Rigid_Object_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group
})]);
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
if(attributes.show_objects)
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i];
var gr = is_instanceof(group, Node_Rigid_Group)? group : noone;
if(inline_context != noone) gr = inline_context;
if(attributes.show_objects && gr != noone)
for( var i = 0, n = ds_list_size(gr.nodes); i < n; i++ ) {
var _node = gr.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue;
var _hov = _node.drawOverlayPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
active &= !_hov;

View file

@ -134,6 +134,8 @@
PREFERENCES.gifski_path = "%APP%/gifski/";
PREFERENCES.ffmpeg_path = "%APP%/ffmpeg/";
PREFERENCES.versions = {};
#endregion
PREFERENCES_DEF = variable_clone(PREFERENCES);

View file

@ -749,6 +749,9 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
static drawParam = function(params) { #region
setParam(params);
if(format == TEXT_AREA_FORMAT.codeHLSL || format == TEXT_AREA_FORMAT.codeLUA)
font = f_code;
return draw(params.x, params.y, params.w, params.h, params.data, params.m);
} #endregion