Skip to content

Commit 0df4ef5

Browse files
committed
Changed the interface to Application and added a new method to get the window.
1 parent 370abe3 commit 0df4ef5

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

examples/02-scene_simple/main.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
#include <windows.h>
1010
#endif
1111

12+
#include <imgui.h>
13+
1214
#include "frame/common/application.h"
1315
#include "frame/file/file_system.h"
1416
#include "frame/file/image_stb.h"
1517
#include "frame/gui/draw_gui_factory.h"
16-
#include "frame/gui/window_resolution.h"
1718
#include "frame/gui/window_logger.h"
19+
#include "frame/gui/window_resolution.h"
1820
#include "frame/window_factory.h"
1921
#include "modal_info.h"
2022

@@ -46,9 +48,12 @@ try
4648
"Resolution", size, win->GetDesktopSize(), win->GetPixelPerInch());
4749
ptr_window_resolution = gui_resolution.get();
4850
gui_window->AddWindow(std::move(gui_resolution));
49-
gui_window->AddWindow(
50-
std::make_unique<frame::gui::WindowLogger>("Logger"));
51+
gui_window->AddWindow(std::make_unique<frame::gui::WindowLogger>("Logger"));
52+
// Set the main window in full.
5153
// gui_window->SetVisible(false);
54+
ImGuiStyle& style = ImGui::GetStyle();
55+
style.Colors[ImGuiCol_PopupBg] = ImVec4(
56+
0.1f, 0.5f, 0.1f, 0.9f); // Dark background with some transparency
5257
gui_window->AddModalWindow(
5358
std::make_unique<ModalInfo>("Info", "This is a test modal window."));
5459
win->GetDevice().AddPlugin(std::move(gui_window));

include/frame/common/application.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ class Application
2222
* @param window: The unique pointer to the window (should have been
2323
* created prior).
2424
*/
25-
Application(std::unique_ptr<frame::WindowInterface>&& window);
25+
Application(std::unique_ptr<frame::WindowInterface> window);
26+
/**
27+
* @brief Get the Window object.
28+
* @return The window.
29+
*/
30+
frame::WindowInterface& GetWindow();
2631
/**
2732
* @brief Startup this will initialized the inner level of the window
2833
* according to a path.
@@ -34,7 +39,7 @@ class Application
3439
* @brief Same as previously but this use a level.
3540
* @param level: A unique pointer to a level.
3641
*/
37-
void Startup(std::unique_ptr<frame::LevelInterface>&& level);
42+
void Startup(std::unique_ptr<frame::LevelInterface> level);
3843
/**
3944
* @brief A helper function that call the inner resize of the window.
4045
* @param size: The new size of the window.

src/frame/common/application.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
namespace frame::common
66
{
77

8-
Application::Application(std::unique_ptr<frame::WindowInterface>&& window)
8+
Application::Application(std::unique_ptr<frame::WindowInterface> window)
99
: window_(std::move(window))
1010
{
1111
assert(window_);
1212
}
1313

14+
frame::WindowInterface& Application::GetWindow()
15+
{
16+
assert(window_);
17+
return *window_;
18+
}
19+
1420
void Application::Startup(std::filesystem::path path)
1521
{
1622
assert(window_);
@@ -25,7 +31,7 @@ void Application::Startup(std::filesystem::path path)
2531
device.AddPlugin(std::move(plugin));
2632
}
2733

28-
void Application::Startup(std::unique_ptr<frame::LevelInterface>&& level)
34+
void Application::Startup(std::unique_ptr<frame::LevelInterface> level)
2935
{
3036
assert(window_);
3137
auto& device = window_->GetDevice();

0 commit comments

Comments
 (0)