feature/imgui-sdl
Last change
on this file since d255d52 was d255d52, checked in by Dmitry Portnoy <dportnoy@…>, 3 years ago |
Get VulkanGame and SDLGame to compile on Linux
|
-
Property mode
set to
100644
|
File size:
748 bytes
|
Line | |
---|
1 | #include "button-imgui.hpp"
|
---|
2 |
|
---|
3 | #include "../../IMGUI/imgui.h"
|
---|
4 | #include "../../IMGUI/imgui_internal.h" // For CalcItemSize
|
---|
5 |
|
---|
6 | ButtonImGui::ButtonImGui(string label) {
|
---|
7 | this->label = label;
|
---|
8 |
|
---|
9 | calculateSize();
|
---|
10 | }
|
---|
11 |
|
---|
12 | ButtonImGui::~ButtonImGui() {
|
---|
13 | }
|
---|
14 |
|
---|
15 | bool ButtonImGui::draw(int offset) {
|
---|
16 | ImGui::InvisibleButton("", ImVec2(offset, 18));
|
---|
17 | ImGui::SameLine();
|
---|
18 |
|
---|
19 | //ImGui::SetCursorPos(int x, int y);
|
---|
20 | return ImGui::Button(label.c_str());
|
---|
21 | }
|
---|
22 |
|
---|
23 | void ButtonImGui::calculateSize() {
|
---|
24 | vec2 labelSize = ImGui::CalcTextSize(label.c_str());
|
---|
25 | ImGuiStyle& style = ImGui::GetStyle();
|
---|
26 |
|
---|
27 | vec2 size = ImGui::CalcItemSize(vec2(0, 0), labelSize.x + style.FramePadding.x * 2.0f, labelSize.y + style.FramePadding.y * 2.0f);
|
---|
28 |
|
---|
29 | width = size.x;
|
---|
30 | height = size.y;
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.