import dlib;
import ui;
import ui : YELLOW, BLUE, RED;
import editor;
import parsing;
import buffer;

import std.algorithm.comparison : clamp;
import std.format;
import std.conv;

__gshared const Panel  g_nil_panel;
__gshared Panel*       g_NIL_PANEL;
__gshared const Editor g_nil_ed;
__gshared Editor*      g_NIL_ED;
__gshared const UIKey  ZERO = ZeroKey();

/******
	- Set up "themes" for different components (e.g. command palette window, editor view, status bar) then have the ability to create styles and apply them to different sections via a string lookup, e.g. start of function to draw cmd palette call ApplyTheme(selected_theme_name) then do code to draw things, get to options and call ApplyTheme(selected_theme_name_for_options), etc.
	- Move scrolling behaviour into ui.d and externally be oblivious to it, e.g. just feed it all lines of text in a text buffer, will have to specifically handle extreme cases later but initially i think it should be fine
******/

const f32 CMD_X_PAD    = 8.0;
const f32 CMD_Y_PAD    = 4.0;
const u32 CMD_TITLE_PX = 14;
const u32 CMD_SUB_PX   = 10;

shared static this()
{
	g_NIL_PANEL = cast(Panel* )&g_nil_panel;
	g_NIL_ED    = cast(Editor*)&g_nil_ed;
}

struct Panel
{
	Panel*  first, last, next, prev, parent;
	Axis2D  layout_axis;
	Editor* ed;
	u64     id;
	u32     text_size;
}
