New splitting

This commit is contained in:
Krzosa Karol
2025-05-05 08:49:22 +02:00
parent 4a1554ce28
commit 556b05cb78
3 changed files with 17 additions and 4 deletions

View File

@@ -378,6 +378,16 @@ int Lua_GetDir(lua_State *L) {
return 1; return 1;
} }
int Lua_SplitSize(lua_State *L) {
lua_Number num = lua_tonumber(L, 1);
lua_pop(L, 1);
BSet set = GetActiveMainSet();
WindowSplit *split = set.window->split_ref;
split->parent->value = num;
return 0;
}
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) { static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
SDL_PumpEvents(); SDL_PumpEvents();
int numkeys = 0; int numkeys = 0;

View File

@@ -25,6 +25,7 @@ luaL_Reg LuaFunctions[] = {
{"FileExists", Lua_FileExists}, {"FileExists", Lua_FileExists},
{"GetWorkingDir", Lua_GetWorkingDir}, {"GetWorkingDir", Lua_GetWorkingDir},
{"GetDir", Lua_GetDir}, {"GetDir", Lua_GetDir},
{"SplitSize", Lua_SplitSize},
{"Play", Lua_Play}, {"Play", Lua_Play},
{NULL, NULL}, {NULL, NULL},
}; };

View File

@@ -60,10 +60,11 @@ Int GetTitleBarSize(Window *window) {
return (Int)result; return (Int)result;
} }
WindowSplit *CreateSplitForWindow(Window *window) { WindowSplit *CreateSplitForWindow(WindowSplit *parent, Window *window) {
WindowSplit *split = AllocType(Perm, WindowSplit); WindowSplit *split = AllocType(Perm, WindowSplit);
split->kind = WindowSplitKind_Window; split->kind = WindowSplitKind_Window;
split->window = window; split->window = window;
split->parent = parent;
window->split_ref = split; window->split_ref = split;
return split; return split;
} }
@@ -79,11 +80,12 @@ void SplitWindowEx(WindowSplit **node, WindowSplit *split, Window *target, Windo
} }
WindowSplit *hori = AllocType(Perm, WindowSplit); WindowSplit *hori = AllocType(Perm, WindowSplit);
hori->parent = node[0]->parent;
hori->kind = kind; hori->kind = kind;
hori->value_kind = ValueKind_Proportion; hori->value_kind = ValueKind_Proportion;
hori->value = 0.5; hori->value = 0.5;
hori->left = *node; hori->left = *node;
hori->right = CreateSplitForWindow(new_window); hori->right = CreateSplitForWindow(hori, new_window);
*node = hori; *node = hori;
} }
} }
@@ -182,7 +184,7 @@ void InitWindows() {
CreateTitlebar(window->id); CreateTitlebar(window->id);
CreateSearchBar(window->id); CreateSearchBar(window->id);
split->left = CreateSplitForWindow(window); split->left = CreateSplitForWindow(split, window);
} }
{ {
@@ -195,7 +197,7 @@ void InitWindows() {
CreateSearchBar(window->id); CreateSearchBar(window->id);
ActiveWindow = window->id; ActiveWindow = window->id;
split->right = CreateSplitForWindow(window); split->right = CreateSplitForWindow(split, window);
} }