Skip to content

Commit

Permalink
Update UI Elements
Browse files Browse the repository at this point in the history
- Resize config window
- Tidy header.h and UI window
- Add helpmarker to imgui_custom.h
- Run sim window

Remove int / operator from Vector3.h
Fix LiveLogViewer and make it work as expected
- Minor changes/Fixes
Create Globals file
  • Loading branch information
ConniBug committed Jan 26, 2023
1 parent 1772595 commit 56fc656
Show file tree
Hide file tree
Showing 13 changed files with 971 additions and 785 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ set(IMGUI_SOURCES
set(GLFW_PATH ./glfw)
set(SOURCES
main.cpp
windows/window_handler.hpp
windows/window_handler.h
components/LiveLogViewer.cpp components/LiveLogViewer.h
windows/run_sim.h
components/imgui_custom.h
includes/Vector3.h
includes/CommandLine.h windows/header.h windows/window_logs.h)
includes/CommandLine.h windows/header.h windows/window_logs.h includes/Globals.h includes/Globals.cpp)

include_directories(
${IMGUI_DIR}
Expand Down
405 changes: 204 additions & 201 deletions components/LiveLogViewer.cpp

Large diffs are not rendered by default.

692 changes: 348 additions & 344 deletions components/LiveLogViewer.h

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions components/imgui_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,33 @@

namespace ImGui {
namespace Custom {
namespace helper {

}
// Stolen from imgui_demo.cpp
//
// Helper to display a little (?) mark which shows a tooltip when hovered.
// In your own code you may want to display an actual icon if you are using a merged icon fonts (see docs/FONTS.md)
static void HelpMarker(const char* desc, float window_rounding = 6.f, const char* text = "(?)")
{
// Set rounding
float initial_rounding = ImGui::GetStyle().WindowRounding;
ImGui::GetStyle().WindowRounding = window_rounding;

ImGui::SameLine();
ImGui::TextDisabled(text);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort))
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(desc);
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}

ImGui::GetStyle().WindowRounding = initial_rounding;
}

bool DropdownButton(ImVec2 buttonSize) {
ImGuiWindow* window = ImGui::GetCurrentWindow();
float x = ImGui::GetCursorPosX();
Expand Down
7 changes: 7 additions & 0 deletions includes/Globals.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// Created by Conni Bilham on 26/01/2023.
//

#include "Globals.h"

Globals* globals = new Globals();
24 changes: 24 additions & 0 deletions includes/Globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Created by Conni Bilham on 26/01/2023.
//
#pragma once

#ifndef GALAXYSIMULATIONUI_GLOBALS_H
#define GALAXYSIMULATIONUI_GLOBALS_H

#include "imgui.h"
#include <string>

struct Globals {
bool show_demo_window = true;
bool show_another_window = true;

std::string* active_log_file = new std::string("initial");
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);

void* logViewer = nullptr;
};

extern Globals* globals;

#endif //GALAXYSIMULATIONUI_GLOBALS_H
8 changes: 0 additions & 8 deletions includes/Vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,6 @@ struct Vector_t {
return *this;
}

constexpr Vector_t& operator/(int div) noexcept
{
x /= div;
y /= div;
z /= div;
return *this;
}

constexpr Vector_t& operator/(TYPE div) noexcept
{
x /= div;
Expand Down
6 changes: 4 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#endif

#include <GLFW/glfw3.h> // Will drag system OpenGL headers
#include "windows/window_handler.hpp"
#include "windows/window_handler.h"

#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <GLES2/gl2.h>
Expand All @@ -28,6 +28,8 @@ ImVec4 clear_color = ImVec4(0.f, 0.f, 0.f, 1.00f);

int main(int, char**)
{
init();

// Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
Expand Down Expand Up @@ -85,7 +87,7 @@ int main(int, char**)
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();

handler::new_frame(window);
new_frame(window);

// Rendering
ImGui::Render();
Expand Down
34 changes: 16 additions & 18 deletions windows/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,26 @@
#include "imgui.h"
#include "Vector3.h"

namespace handler {
namespace windows {
void draw_header(ImVec2 position, ImVec2 size) {
namespace windows {
void draw_header(ImVec2 position, ImVec2 size) {
// auto viewPort = ImGui::GetMainViewport()->Size;
ImGui::SetNextWindowSize(size);
ImGui::SetNextWindowPos(position);
if (ImGui::Begin("Header Window", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar)) {
ImGui::Text("Galaxy Simulation - V0.1.0b");
ImGui::Spacing();
ImGui::SetNextWindowSize(size);
ImGui::SetNextWindowPos(position);
if (ImGui::Begin("Header Window", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar)) {
ImGui::Text("Galaxy Simulation - V0.1.0b");
ImGui::Spacing();

// Get frame number
ImGui::Text("Frame: %d", ImGui::GetFrameCount());
// Get frame number
ImGui::Text("Frame: %d", ImGui::GetFrameCount());

// Get compile time info
ImGui::Text("Compiled on: %s at %s", __DATE__, __TIME__);
// Get compile time info
ImGui::Text("Compiled on: %s at %s", __DATE__, __TIME__);

// Get runtime info
ImGui::Text("Runtime: %s", std::string(std::to_string(__cplusplus) + " C++").c_str());
// Get runtime info
ImGui::Text("Runtime: %s", std::string(std::to_string(__cplusplus) + " C++").c_str());

ImGui::End();
}
ImGui::End();
}
} // Windows
} // Handler
}
} // Windows
#endif //GALAXYSIMULATIONUI_HEADER_H
Loading

0 comments on commit 56fc656

Please sign in to comment.