forked from hoffstadt/DearPyGui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvToolWindow.cpp
More file actions
73 lines (56 loc) · 1.4 KB
/
mvToolWindow.cpp
File metadata and controls
73 lines (56 loc) · 1.4 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "mvToolWindow.h"
#include "mvItemRegistry.h"
void mvToolWindow::draw()
{
if (!m_show)
return;
if (m_dirtySize)
{
ImGui::SetNextWindowSize(ImVec2((float)m_width, (float)m_height));
m_dirtySize = false;
}
if (m_dirtyPos)
{
ImGui::SetNextWindowPos(ImVec2((float)m_xpos, (float)m_ypos));
m_dirtyPos = false;
}
if (!ImGui::Begin(getTitle(), &m_show, m_windowflags))
{
ImGui::End();
return;
}
drawWidgets();
if (ImGui::IsWindowFocused())
{
float titleBarHeight = ImGui::GetStyle().FramePadding.y * 2 + ImGui::GetFontSize();
// update mouse
ImVec2 mousePos = ImGui::GetMousePos();
float x = mousePos.x - ImGui::GetWindowPos().x;
float y = mousePos.y - ImGui::GetWindowPos().y - titleBarHeight;
GContext->input.mousePos.x = (int)x;
GContext->input.mousePos.y = (int)y;
std::lock_guard<std::recursive_mutex> lk(GContext->mutex);
GContext->activeWindow = getUUID();
}
ImGui::End();
}
void mvToolWindow::setXPos(int pos)
{
m_xpos = pos;
m_dirtyPos = true;
}
void mvToolWindow::setYPos(int pos)
{
m_ypos = pos;
m_dirtyPos = true;
}
void mvToolWindow::setWidth(int width)
{
m_width = width;
m_dirtySize = true;
}
void mvToolWindow::setHeight(int height)
{
m_height = height;
m_dirtySize = true;
}