[script] Allow setting the position of the windows

Although the windows are set up to in a reasonable default configuration, the
themes may align the windows differently to not crop some important elements.

The Window.SetX and SetY allow positioning the window anywhere on the canvas.
Use this sparingly as it induces a full refresh of all screens.

If there is a desire to have totally different scenes, the second window can be
positioned somewhere far away so there is overlap and a complete different set
of sprites is used. Another sensible configuration is to have the screens side
by side and allow sprites to span the gap. Remember to create password dialogs
for each screen as not all may be visible.
calculate-0.9.5
Charlie Brej 15 years ago
parent d2f16135f0
commit 7e487da507

@ -200,6 +200,55 @@ static script_return_t sprite_window_get_height (script_state_t *state,
return script_return_obj (script_obj_new_number (height)); return script_return_obj (script_obj_new_number (height));
} }
static script_return_t sprite_window_set_x (script_state_t *state,
void *user_data)
{
script_lib_sprite_data_t *data = user_data;
ply_list_node_t *node;
script_lib_display_t *display;
int index;
int x;
index = script_obj_hash_get_number (state->local, "window");
x = script_obj_hash_get_number (state->local, "value");
node = ply_list_get_nth_node (data->displays, index);
if (node)
{
display = ply_list_node_get_data (node);
if (display->x != x)
{
display->x = x;
data->full_refresh = true;
}
}
return script_return_obj_null ();
}
static script_return_t sprite_window_set_y (script_state_t *state,
void *user_data)
{
script_lib_sprite_data_t *data = user_data;
ply_list_node_t *node;
script_lib_display_t *display;
int index;
int y;
index = script_obj_hash_get_number (state->local, "window");
y = script_obj_hash_get_number (state->local, "value");
ply_trace("%d\n", index);
node = ply_list_get_nth_node (data->displays, index);
if (node)
{
display = ply_list_node_get_data (node);
if (display->y != y)
{
display->y = y;
data->full_refresh = true;
}
}
return script_return_obj_null ();
}
static uint32_t extract_rgb_color (script_state_t *state) static uint32_t extract_rgb_color (script_state_t *state)
{ {
uint8_t red = CLAMP (255 * script_obj_hash_get_number (state->local, "red"), 0, 255); uint8_t red = CLAMP (255 * script_obj_hash_get_number (state->local, "red"), 0, 255);
@ -399,6 +448,20 @@ script_lib_sprite_data_t *script_lib_sprite_setup (script_state_t *state,
data, data,
"window", "window",
NULL); NULL);
script_add_native_function (window_hash,
"SetX",
sprite_window_set_x,
data,
"window",
"value",
NULL);
script_add_native_function (window_hash,
"SetY",
sprite_window_set_y,
data,
"window",
"value",
NULL);
script_add_native_function (window_hash, script_add_native_function (window_hash,
"SetBackgroundTopColor", "SetBackgroundTopColor",
sprite_window_set_background_top_color, sprite_window_set_background_top_color,

Loading…
Cancel
Save