Skip to content

Commit

Permalink
Changed the interface to Application and added a new method to get th…
Browse files Browse the repository at this point in the history
…e window.
  • Loading branch information
anirul committed Feb 14, 2024
1 parent 370abe3 commit 0df4ef5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
11 changes: 8 additions & 3 deletions examples/02-scene_simple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#include <windows.h>
#endif

#include <imgui.h>

#include "frame/common/application.h"
#include "frame/file/file_system.h"
#include "frame/file/image_stb.h"
#include "frame/gui/draw_gui_factory.h"
#include "frame/gui/window_resolution.h"
#include "frame/gui/window_logger.h"
#include "frame/gui/window_resolution.h"
#include "frame/window_factory.h"
#include "modal_info.h"

Expand Down Expand Up @@ -46,9 +48,12 @@ try
"Resolution", size, win->GetDesktopSize(), win->GetPixelPerInch());
ptr_window_resolution = gui_resolution.get();
gui_window->AddWindow(std::move(gui_resolution));
gui_window->AddWindow(
std::make_unique<frame::gui::WindowLogger>("Logger"));
gui_window->AddWindow(std::make_unique<frame::gui::WindowLogger>("Logger"));
// Set the main window in full.
// gui_window->SetVisible(false);
ImGuiStyle& style = ImGui::GetStyle();
style.Colors[ImGuiCol_PopupBg] = ImVec4(
0.1f, 0.5f, 0.1f, 0.9f); // Dark background with some transparency
gui_window->AddModalWindow(
std::make_unique<ModalInfo>("Info", "This is a test modal window."));
win->GetDevice().AddPlugin(std::move(gui_window));
Expand Down
9 changes: 7 additions & 2 deletions include/frame/common/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ class Application
* @param window: The unique pointer to the window (should have been
* created prior).
*/
Application(std::unique_ptr<frame::WindowInterface>&& window);
Application(std::unique_ptr<frame::WindowInterface> window);
/**
* @brief Get the Window object.
* @return The window.
*/
frame::WindowInterface& GetWindow();
/**
* @brief Startup this will initialized the inner level of the window
* according to a path.
Expand All @@ -34,7 +39,7 @@ class Application
* @brief Same as previously but this use a level.
* @param level: A unique pointer to a level.
*/
void Startup(std::unique_ptr<frame::LevelInterface>&& level);
void Startup(std::unique_ptr<frame::LevelInterface> level);
/**
* @brief A helper function that call the inner resize of the window.
* @param size: The new size of the window.
Expand Down
10 changes: 8 additions & 2 deletions src/frame/common/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
namespace frame::common
{

Application::Application(std::unique_ptr<frame::WindowInterface>&& window)
Application::Application(std::unique_ptr<frame::WindowInterface> window)
: window_(std::move(window))
{
assert(window_);
}

frame::WindowInterface& Application::GetWindow()
{
assert(window_);
return *window_;
}

void Application::Startup(std::filesystem::path path)
{
assert(window_);
Expand All @@ -25,7 +31,7 @@ void Application::Startup(std::filesystem::path path)
device.AddPlugin(std::move(plugin));
}

void Application::Startup(std::unique_ptr<frame::LevelInterface>&& level)
void Application::Startup(std::unique_ptr<frame::LevelInterface> level)
{
assert(window_);
auto& device = window_->GetDevice();
Expand Down

0 comments on commit 0df4ef5

Please sign in to comment.