Skip to content

Commit 68c9da4

Browse files
committed
ui change and faster exit time
1 parent fd7682d commit 68c9da4

2 files changed

Lines changed: 136 additions & 71 deletions

File tree

desktop-agent/src/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <propkey.h>
1717
#include <shlobj.h>
1818

19+
1920
std::atomic<bool> running(true);
2021
std::atomic<bool> paused(false);
2122

@@ -134,7 +135,10 @@ if (std::chrono::duration_cast<std::chrono::seconds>(now - lastSettingsCheck).co
134135
interval = currentSettings.captureIntervalSeconds;
135136
}
136137
// Wait for next capture
137-
std::this_thread::sleep_for(std::chrono::seconds(interval));
138+
for(int i = 0; i < interval && running; ++i) {
139+
std::this_thread::sleep_for(std::chrono::seconds(1));
140+
}
141+
138142
}
139143
}
140144

@@ -230,12 +234,8 @@ ShowWindow(GetConsoleWindow(), SW_HIDE);
230234
if (!loggedIn) {
231235
LoginWindow loginGui;
232236
if (loginGui.show()) {
233-
234-
235237
std::string enteredUser = loginGui.getUsername();
236238
std::string enteredPass = loginGui.getPassword();
237-
238-
239239
backendClient.setUsername(enteredUser);
240240
backendClient.setPassword(enteredPass);
241241

@@ -257,8 +257,7 @@ ShowWindow(GetConsoleWindow(), SW_HIDE);
257257

258258
// Initialize camera
259259
CameraCapture camera(config.getCameraIndex());
260-
if (!camera.initialize())
261-
{
260+
if (!camera.initialize()){
262261
std::cerr << "Failed to initialize camera" << std::endl;
263262
return 1;
264263
}

desktop-agent/src/ui/LoginWindow.cpp

Lines changed: 130 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LoginWindow::LoginWindow(){
1313
ImGui::CreateContext();
1414

1515
ImGuiIO& io = ImGui::GetIO();
16-
io.FontGlobalScale = 1.6f;
16+
io.FontGlobalScale = 2.0f;
1717

1818

1919
ImGui_ImplGlfw_InitForOpenGL(m_window,true);
@@ -26,83 +26,149 @@ LoginWindow::LoginWindow(){
2626
void LoginWindow::setupStyles(){
2727
ImGui::StyleColorsDark();
2828
auto& style = ImGui::GetStyle();
29-
style.WindowRounding =8.0f;
30-
style.FrameRounding =4.0f;
29+
30+
style.WindowRounding =12.0f;
31+
style.FrameRounding = 6.0f;
32+
style.GrabRounding = 6.0f;
33+
34+
// Spacing
35+
style.WindowPadding =ImVec2(30,30);
36+
style.FramePadding =ImVec2(12,8);
37+
style.ItemSpacing = ImVec2(12,12);
38+
39+
// Colors
40+
41+
ImVec4* colors = style.Colors;
42+
// Background - Deep blue-grey (matches your web app)
43+
colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.11f, 0.15f, 0.98f); // #1C1C26
44+
45+
// Input fields - Slightly lighter
46+
colors[ImGuiCol_FrameBg] = ImVec4(0.15f, 0.15f, 0.20f, 1.00f);
47+
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.18f, 0.18f, 0.24f, 1.00f);
48+
colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.20f, 0.26f, 1.00f);
49+
50+
// Buttons - Blue accent
51+
colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.85f);
52+
colors[ImGuiCol_ButtonHovered] = ImVec4(0.30f, 0.65f, 1.00f, 1.00f);
53+
colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.50f, 0.90f, 1.00f);
54+
55+
// Text colors
56+
colors[ImGuiCol_Text] = ImVec4(0.95f, 0.95f, 0.95f, 1.00f);
57+
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.55f, 1.00f);
58+
59+
// Borders
60+
colors[ImGuiCol_Border] = ImVec4(0.25f, 0.25f, 0.30f, 0.50f);
3161

3262
}
3363

64+
65+
3466
bool LoginWindow::show(){
3567

3668
while(!glfwWindowShouldClose(m_window)){
37-
glfwPollEvents();
38-
// Clear the screen
39-
int display_w,display_h;
40-
glfwGetFramebufferSize(m_window,&display_w,&display_h);
41-
glViewport(0,0,display_w,display_h);
42-
43-
glClearColor(0.08f, 0.08f, 0.09f, 1.0f);
44-
glClear(GL_COLOR_BUFFER_BIT);
45-
46-
47-
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
48-
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 20));
49-
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10, 15));
50-
51-
// Start ImGui Frame
52-
ImGui_ImplOpenGL3_NewFrame();
53-
ImGui_ImplGlfw_NewFrame();
54-
ImGui::NewFrame();
55-
56-
//Dynamic centering
57-
float box_width = 700.0f;
58-
float box_height =400.0f;
59-
ImVec2 center_pos = ImVec2(
60-
(display_w - box_width) * 0.5f,
61-
(display_h - box_height) * 0.5f);
62-
ImGui::SetNextWindowPos(center_pos, ImGuiCond_Always);
63-
ImGui::SetNextWindowSize(ImVec2(box_width, box_height));
64-
65-
// Draw UI
66-
ImGui::Begin("Login", nullptr,ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
67-
ImGui::Text("Sign in to Posture Guardian");
68-
ImGui::Separator();
69-
ImGui::Spacing();
70-
71-
ImGui::PushItemWidth(-0.1f);
72-
ImGui::Text("Username");
73-
ImGui::InputText("##User",m_userBuf,64);
74-
75-
ImGui::Text("Password");
76-
ImGui::InputText("##Pass",m_passBuf, 64,ImGuiInputTextFlags_Password);
77-
ImGui::PopItemWidth();
78-
79-
ImGui::Spacing();
80-
ImGui::Separator();
81-
ImGui::Spacing();
82-
83-
84-
if(ImGui::Button("Login",ImVec2(180,45))){
85-
m_username =m_userBuf;
69+
glfwPollEvents();
70+
71+
// Check if window was closed
72+
if(glfwWindowShouldClose(m_window)){
73+
return false;
74+
}
75+
76+
// Clear screen
77+
int display_w, display_h;
78+
glfwGetFramebufferSize(m_window, &display_w, &display_h);
79+
glViewport(0, 0, display_w, display_h);
80+
glClearColor(0.10f, 0.10f, 0.13f, 1.0f);
81+
glClear(GL_COLOR_BUFFER_BIT);
82+
83+
// Start ImGui frame
84+
ImGui_ImplOpenGL3_NewFrame();
85+
ImGui_ImplGlfw_NewFrame();
86+
ImGui::NewFrame();
87+
88+
// Center window
89+
ImGui::SetNextWindowPos(ImVec2(display_w * 0.5f, display_h * 0.5f),
90+
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
91+
ImGui::SetNextWindowSize(ImVec2(900, 520));
92+
93+
// Main window
94+
ImGui::Begin("##MainLogin", nullptr,
95+
ImGuiWindowFlags_NoDecoration |
96+
ImGuiWindowFlags_NoMove |
97+
ImGuiWindowFlags_NoResize);
98+
99+
// Title
100+
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
101+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
102+
ImGui::Text("Welcome Back");
103+
ImGui::PopStyleColor();
104+
105+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.65f, 0.65f, 0.7f, 1.0f));
106+
ImGui::Text("Sign in to Posture Guardian");
107+
ImGui::PopStyleColor();
108+
109+
ImGui::Dummy(ImVec2(0, 20));
110+
111+
// Username field
112+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.85f, 0.85f, 0.9f, 1.0f));
113+
ImGui::Text("Username");
114+
ImGui::PopStyleColor();
115+
116+
ImGui::PushItemWidth(-1);
117+
ImGui::InputTextWithHint("##User", "Enter your username", m_userBuf, 64);
118+
119+
ImGui::Dummy(ImVec2(0, 10));
120+
121+
// Password field
122+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.85f, 0.85f, 0.9f, 1.0f));
123+
ImGui::Text("Password");
124+
ImGui::PopStyleColor();
125+
126+
ImGui::InputTextWithHint("##Pass", "Enter your password", m_passBuf, 64,
127+
ImGuiInputTextFlags_Password);
128+
ImGui::PopItemWidth();
129+
130+
ImGui::Dummy(ImVec2(0, 25));
131+
132+
133+
// Login button
134+
if(ImGui::Button("Sign In", ImVec2(-1, 55))){
135+
m_username = m_userBuf;
86136
m_password = m_passBuf;
87-
ImGui::PopStyleVar(3);
137+
ImGui::End();
138+
ImGui::Render();
139+
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
140+
glfwSwapBuffers(m_window);
88141
return true;
89142
}
90-
ImGui::SameLine();
91-
if(ImGui::Button("Register", ImVec2(180,45))){
92-
ShellExecuteA(NULL, "open", "https://posture-guardian.vercel.app/register", NULL, NULL, SW_SHOWNORMAL);
93-
}
94-
95-
ImGui::End();
96143

97-
ImGui::PopStyleVar(3);
144+
ImGui::Dummy(ImVec2(0, 10));
98145

99-
ImGui::Render();
100-
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
101-
glfwSwapBuffers(m_window);
146+
// Register link
147+
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
148+
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.2f, 0.2f, 0.25f, 0.5f));
149+
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.15f, 0.15f, 0.20f, 0.5f));
150+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.6f, 0.75f, 1.0f, 1.0f));
151+
152+
if(ImGui::Button("Don't have an account? Register here", ImVec2(-1, 32))){
153+
ShellExecuteA(NULL, "open", "https://posture-guardian.vercel.app/register",
154+
NULL, NULL, SW_SHOWNORMAL);
102155
}
103-
return false;
104156

157+
ImGui::PopStyleColor(4);
158+
159+
ImGui::End();
160+
161+
162+
163+
ImGui::Render();
164+
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
165+
glfwSwapBuffers(m_window);
105166
}
167+
return false;
168+
}
169+
170+
171+
106172
LoginWindow::~LoginWindow(){
107173
ImGui_ImplOpenGL3_Shutdown();
108174
ImGui_ImplGlfw_Shutdown();

0 commit comments

Comments
 (0)