33 lines
976 B
C++
33 lines
976 B
C++
#include "ui_window.h"
|
|
#include "gfx/shape_renderer.h"
|
|
#include "gfx/txt_renderer.h"
|
|
|
|
UIWindow::UIWindow(const char* title, int x, int y, int width, int height) {
|
|
_title = title;
|
|
_x = x;
|
|
_y = y;
|
|
_width = width;
|
|
_height = height;
|
|
}
|
|
|
|
void UIWindow::render(ShapeRenderer* shape_renderer, TextRenderer* txt_renderer) {
|
|
int title_bar_height = 30;
|
|
|
|
/* Define colours. */
|
|
float frame_color[] = { 0.2f, 0.2f, 0.25f };
|
|
float title_bar_color[] = { 0.15f, 0.15f, 0.2f };
|
|
float title_text_color[] = { 0.9f, 0.9f, 0.9f };
|
|
|
|
/* Draw main window frame/background. */
|
|
shape_renderer->draw_rect(_x, _y, _width, _height, frame_color);
|
|
|
|
/* Draw title bar. */
|
|
shape_renderer->draw_rect(_x, _y+_height-title_bar_height, _width,
|
|
title_bar_height, title_bar_color);
|
|
|
|
/* Draw title text. */
|
|
txt_renderer->render_text(_title.c_str(), _x+5, _y+_height-title_bar_height+8,
|
|
1.0f, title_text_color);
|
|
}
|
|
|