Skip to content

Commit

Permalink
adding faster layout definers
Browse files Browse the repository at this point in the history
make sure we store each command hash individually
  • Loading branch information
ericoporto committed Feb 19, 2021
1 parent 64916a5 commit 5d11533
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 3 deletions.
79 changes: 76 additions & 3 deletions imgi_demo/imgi.asc
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ struct ImGi_Context
// Layout
import void LayoutRow(int items, int widths[], int height = 0);
import void LayoutRow1(int width, int height = 0);
import void LayoutRow2(int w1, int w2, int height = 0);
import void LayoutRow3(int w1, int w2, int w3, int height = 0);
import void LayoutRow4(int w1, int w2, int w3, int w4, int height = 0);

// Controls
import ImGi_Res BeginWindow(String title, int x, int y, int width, int height, ImGi_Opt opt = 0);
Expand Down Expand Up @@ -909,6 +912,48 @@ ImGi_Context::LayoutRow1(int width, int height)
layout.item_index = 0;
}

void
ImGi_Context::LayoutRow2(int w1, int w2, int height)
{
ImGi_Layout* layout = this.get_layout();
layout.widths[0] = w1;
layout.widths[1] = w2;
layout.items = 2;
layout.pos_x = layout.indent;
layout.pos_y = layout.next_row;
layout.size_y = height;
layout.item_index = 0;
}

void
ImGi_Context::LayoutRow3(int w1, int w2, int w3, int height)
{
ImGi_Layout* layout = this.get_layout();
layout.widths[0] = w1;
layout.widths[1] = w2;
layout.widths[2] = w3;
layout.items = 3;
layout.pos_x = layout.indent;
layout.pos_y = layout.next_row;
layout.size_y = height;
layout.item_index = 0;
}

void
ImGi_Context::LayoutRow4(int w1, int w2, int w3, int w4, int height)
{
ImGi_Layout* layout = this.get_layout();
layout.widths[0] = w1;
layout.widths[1] = w2;
layout.widths[2] = w3;
layout.widths[3] = w4;
layout.items = 4;
layout.pos_x = layout.indent;
layout.pos_y = layout.next_row;
layout.size_y = height;
layout.item_index = 0;
}

void
push_layout(this ImGi_Context*, Rect* body, Point* scroll)
{
Expand Down Expand Up @@ -2370,12 +2415,13 @@ ImGi_Context _ImGi;
int
_ImGi_Calculate_Command_Hash()
{
int hn = 0;
int hn;
int hlist = HASH_INITIAL;

for (int ic = 0; ic < _ctx_stk_cmd_index; ic++)
{
// hn = (hn ^ c.type)* 16777619;
hn = (hn ^ CMD_IC.dst_idx) * 16777619;
hn = (HASH_INITIAL ^ CMD_IC.dst_idx) * 16777619;
hn = (hn ^ CMD_IC.r.x) * 16777619;
hn = (hn ^ CMD_IC.r.y) * 16777619;
hn = (hn ^ CMD_IC.r.w) * 16777619;
Expand All @@ -2394,8 +2440,10 @@ _ImGi_Calculate_Command_Hash()
// hn = (hn ^ s.Chars[k])* 16777619;
//}
}
CMD_IC.hash = hn;
hlist = (hlist ^ hn) * 16777619;
}
return hn;
return hlist;
}
// select SO or MO
// - SO: Single Overlay Rendering, slower but more compatible
Expand Down Expand Up @@ -2805,6 +2853,31 @@ ImGi::LayoutRow(int items, int widths[], int height)
_ImGi.LayoutRow(items, widths, height);
}

static void
ImGi::LayoutRow1(int width, int height)
{
_ImGi.LayoutRow1(width, height);
}

static void
ImGi::LayoutRow2(int column_1_width, int column_2_width, int height)
{
_ImGi.LayoutRow2(column_1_width, column_2_width, height);
}

static void
ImGi::LayoutRow3(int column_1_width, int column_2_width, int column_3_width, int height)
{
_ImGi.LayoutRow3(column_1_width, column_2_width, column_3_width, height);
}

static void
ImGi::LayoutRow4(int column_1_width, int column_2_width, int column_3_width, int column_4_width, int height)
{
_ImGi.LayoutRow4(column_1_width, column_2_width, column_3_width, column_4_width, height);
}


// Controls
static ImGi_Res
ImGi::BeginWindow(String title, int x, int y, int width, int height,
Expand Down
12 changes: 12 additions & 0 deletions imgi_demo/imgi.ash
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ builtin struct ImGi

/// Pass an array of widths with count elements to configure the columns in a row. You can optionally specify a height.
import static void LayoutRow(int count, int widths[], int height = 0);

/// The layout of the next and following rows will have a single column of following width. You can optionally specify a height.
import static void LayoutRow1(int width, int height = 0);

/// The layout of the next and following rows will have 2 columns of each specified widths. You can optionally specify a height.
import static void LayoutRow2(int w1, int w2, int height = 0);

/// The layout of the next and following rows will have 3 columns of each specified widths. You can optionally specify a height.
import static void LayoutRow3(int w1, int w2, int w3, int height = 0);

/// The layout of the next and following rows will have 4 columns of each specified widths. You can optionally specify a height.
import static void LayoutRow4(int w1, int w2, int w3, int w4, int height = 0);

// Containers

Expand Down
Binary file modified imgi_demo/room1.crm
Binary file not shown.
Binary file modified imgi_demo/room2.crm
Binary file not shown.
Binary file modified imgi_demo/room3.crm
Binary file not shown.
Binary file modified imgi_demo/room4.crm
Binary file not shown.
Binary file modified imgi_demo/room5.crm
Binary file not shown.

0 comments on commit 5d11533

Please sign in to comment.