-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCNC_Userinterface.cpp
More file actions
131 lines (116 loc) · 6.93 KB
/
CNC_Userinterface.cpp
File metadata and controls
131 lines (116 loc) · 6.93 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "CNC_Userinterface.h"
#include "CNC_Application.h"
#include "CNC_Types.h"
void CustomizeUi()
{
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.Fonts->AddFontFromFileTTF( "res/blender_book.ttf", 15 );
// Setup Dear ImGui style
ImGui::StyleColorsDark();
ImGuiStyle& myStyle = ImGui::GetStyle();
// padding & spacing
myStyle.WindowPadding = ImVec2( 12.0f, 12.0f );
myStyle.FramePadding = ImVec2( 12.0f, 8.0f );
myStyle.ItemSpacing = ImVec2( 12.0f, 12.0f );
myStyle.ItemInnerSpacing = ImVec2( 4.0f, 4.0f );
myStyle.IndentSpacing = 21.0f;
// borders
myStyle.FrameBorderSize = 0.0f;
myStyle.WindowBorderSize = 0.0f;
myStyle.SeparatorTextBorderSize = 1.0f;
// rounding
myStyle.WindowRounding = 6.0f;
myStyle.FrameRounding = 3.0f;
myStyle.ScrollbarRounding = 9.0f;
myStyle.GrabRounding = 2.0f;
ImVec4* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.13f, 0.13f, 0.70f);
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
colors[ImGuiCol_Border] = ImVec4(0.35f, 0.79f, 0.81f, 0.50f);
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_FrameBg] = ImVec4(0.09f, 0.10f, 0.11f, 0.54f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.17f, 0.18f, 0.20f, 0.40f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.45f, 0.45f, 0.45f, 0.67f);
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.09f, 0.10f, 0.11f, 1.00f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f);
colors[ImGuiCol_CheckMark] = ImVec4(0.23f, 0.82f, 0.72f, 1.00f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.88f, 0.77f, 0.24f, 1.00f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.88f, 0.77f, 0.24f, 1.00f);
colors[ImGuiCol_Button] = ImVec4(0.08f, 0.09f, 0.08f, 0.40f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.27f, 0.28f, 0.30f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.20f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
colors[ImGuiCol_Tab] = ImVec4(0.23f, 0.28f, 0.35f, 0.86f);
colors[ImGuiCol_TabHovered] = ImVec4(0.41f, 0.44f, 0.47f, 0.80f);
colors[ImGuiCol_TabActive] = ImVec4(0.39f, 0.45f, 0.52f, 1.00f);
colors[ImGuiCol_TabUnfocused] = ImVec4(0.07f, 0.10f, 0.15f, 0.97f);
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.26f, 0.42f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f);
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f);
colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f);
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
}
void ShowCornellboxUi( bool* showCornellbox, Application* application )
{
ImGui::SetNextWindowSize(ImVec2(320,480), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowPos( ImVec2( 11, 11), ImGuiCond_FirstUseEver );
ImGui::Begin( "CORNELLBOX UI", showCornellbox );
Camera* camera = &application->m_camera;
Box* box = &application->m_cornellBox;
f32 roll = toDegrees( camera->m_roll );
f32 pitch = toDegrees( camera->m_pitch );
f32 yaw = toDegrees( camera->m_yaw );
f32 posZ = camera->m_position[2];
ImGui::SeparatorText("CAMERA");
ImGui::Spacing();
ImGui::DragFloat( "FOV", &camera->m_fov, 0.5f, 20.0f, 120.0f );
ImGui::DragFloat( "ROLL", &roll, 0.5f, -90.0f, 90.0f );
ImGui::DragFloat( "PITCH", &pitch, 0.5f, -90.0f, 90.0f );
ImGui::DragFloat( "YAW", &yaw, 0.5f, -90.0f, 90.0f );
ImGui::SeparatorText("BOX");
ImGui::Spacing();
ImGui::SliderFloat( "WIDTH", &box->m_width, 1.0f, 20.0f );
ImGui::SliderFloat( "HEIGHT", &box->m_height, 1.0f, 20.0f );
ImGui::SliderFloat( "LENGTH", &box->m_length, 1.0f, 20.0f );
camera->m_roll = toRadians( roll );
camera->m_pitch = toRadians( pitch );
camera->m_yaw = toRadians( yaw );
camera->m_position[2] = posZ;
if( ImGui::Button( "RELOAD SHADER" ) )
{
Platform* platform = application->m_platform;
platform->reloadShaders( application->m_renderer );
}
ImGui::End();
}