Browse Source

Tiling UI updates

master
Adam Pippin 4 years ago
parent
commit
9d98dc238c
  1. 21
      UI.cpp

21
UI.cpp

@ -6,7 +6,7 @@
struct Window *UI_get_window(int hwnd);
void base_window_callback(int hwnd, int x, int y, int width, int height);
void draw(int parent_hwnd, int x, int y, int width, int height);
void UI_draw(int parent_hwnd, int x, int y, int width, int height);
struct Window windows[MAX_WINDOWS];
int next_hwnd = 1;
@ -37,16 +37,18 @@ int UI(int pid, unsigned int signal)
}
M5.Lcd.setTextColor(TFT_WHITE, TFT_DARKGREY);
// TODO: Get actual screen bounds somehow
draw(windows[i].hwnd, 0, 0, 160, 80);
// Horizontal
UI_draw(windows[i].hwnd, 0, 0, 160, 80);
// Vertical
//UI_draw(windows[i].hwnd, 0, 0, 80, 160);
}
}
return 0;
}
void draw(int parent_hwnd, int x, int y, int width, int height)
void UI_draw(int parent_hwnd, int x, int y, int width, int height)
{
Serial.printf("Drawing window %d\n", parent_hwnd);
// Trigger draw
Window* parent_window = UI_get_window(parent_hwnd);
if (parent_window->hwnd == -1)
@ -70,8 +72,6 @@ void draw(int parent_hwnd, int x, int y, int width, int height)
}
}
Serial.printf("Found %d children\n", child_count);
if (child_count == 0)
{
return;
@ -92,30 +92,27 @@ void draw(int parent_hwnd, int x, int y, int width, int height)
{
case LAYOUT_MODE_NONE:
{
Serial.printf("Layout mode: none\n");
for (int i=0; i<child_count; i++)
{
draw(children[i]->hwnd, x, y, width, height);
UI_draw(children[i]->hwnd, x, y, width, height);
}
}
break;
case LAYOUT_MODE_SPLIT_VERTICAL:
{
Serial.printf("Layout mode: vertical\n");
int child_width = width / child_count;
for (int i=0; i<child_count; i++)
{
draw(children[i]->hwnd, x + (i * child_width), y, child_width, height);
UI_draw(children[i]->hwnd, x + (i * child_width), y, child_width, height);
}
}
break;
case LAYOUT_MODE_SPLIT_HORIZONTAL:
{
Serial.printf("Layout mode: horizontal\n");
int child_height = height / child_count;
for (int i=0; i<child_count; i++)
{
draw(children[i]->hwnd, x, y + (i * child_height), width, child_height);
UI_draw(children[i]->hwnd, x, y + (i * child_height), width, child_height);
}
}
break;

Loading…
Cancel
Save