forked from bobsayshilol/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui_button.cpp
More file actions
31 lines (25 loc) · 729 Bytes
/
ui_button.cpp
File metadata and controls
31 lines (25 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "../include/ui_button.h"
#include "../include/engine_sim_application.h"
#include "../include/ui_utilities.h"
UiButton::UiButton() {
m_text = "";
m_fontSize = 12;
m_checkMouse = true;
}
UiButton::~UiButton() {
/* void */
}
void UiButton::update(float dt) {
m_mouseBounds = m_bounds;
}
void UiButton::render() {
ysVector color = m_app->getBackgroundColor();
if (isMouseHeld()) {
color = mix(m_app->getBackgroundColor(), m_app->getWhite(), 0.02f);
}
else if (isMouseOver()) {
color = mix(m_app->getBackgroundColor(), m_app->getWhite(), 0.01f);
}
drawFrame(m_bounds, 1.0, ysMath::Constants::One, color);
drawCenteredText(m_text, m_bounds, m_fontSize);
}