Skip to content

Commit ab1c54d

Browse files
committed
add window name support
1 parent c3cd497 commit ab1c54d

7 files changed

+13
-10
lines changed

examples/example.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ int main()
6767
ImGui::End();
6868
}
6969
},
70-
std::make_unique<imgui::DefaultStyle>(), 1200, 800);
70+
std::make_unique<imgui::DefaultStyle>(), "ImGui Example", 1200, 800);
7171
ui_context->run();
7272
}

include/imgui/ui.h

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ struct Style;
99

1010
std::unique_ptr<Context> create_ui(std::function<void(Context*)>&& fun,
1111
std::unique_ptr<Style> style,
12+
std::string const& name,
1213
size_t initial_width, size_t initial_height);
1314

1415
} // namespace imgui

src/sdl/select_sdl_renderer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ std::pair<int,std::string> run_gl_init() {
4646
} // namespace
4747

4848
std::pair<std::unique_ptr<imgui::SystemIntegration>, std::unique_ptr<imgui::Renderer>>
49-
is::select_sdl_setup(size_t initial_width, size_t initial_height) {
49+
is::select_sdl_setup(size_t initial_width, size_t initial_height, std::string const& wn) {
5050
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0)
5151
throw std::runtime_error("error");
5252
auto version = run_gl_init();
5353
auto try_window = SDL_CreateWindow(
54-
"window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, initial_width,
54+
wn.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, initial_width,
5555
initial_height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
5656

5757
if (try_window) {

src/sdl/select_sdl_renderer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ struct Renderer;
66
struct SystemIntegration;
77
namespace sdl {
88
std::pair<std::unique_ptr<SystemIntegration>, std::unique_ptr<Renderer>>
9-
select_sdl_setup(size_t initial_width, size_t initial_height);
9+
select_sdl_setup(size_t initial_width, size_t initial_height, std::string const& wn);
1010
} // namespace sdl
1111
} // namespace imgui

src/ui.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,22 @@ auto construct_gl_renderer() {
4040

4141
std::unique_ptr<imgui::Context> imgui::create_ui(
4242
std::function<void(imgui::Context*)>&& fun, std::unique_ptr<Style> style,
43+
std::string const& window_name,
4344
size_t initial_width, size_t initial_height) {
4445
#ifdef WIN32
45-
auto sys = win32::select_win32_setup(initial_width, initial_height);
46+
auto sys = win32::select_win32_setup(initial_width, initial_height, window_name);
4647
return std::make_unique<Context>(std::move(sys.first),
4748
std::move(sys.second),
4849
std::move(style), std::move(fun));
4950
#elif defined(EMSCRIPTEN)
5051
return std::make_unique<imgui::Context>(
51-
std::make_unique<emscripten::SystemIntegration>(initial_width,
52+
std::make_unique<emscripten::SystemIntegration>(
53+
initial_width,
5254
initial_height),
5355
construct_gl_renderer(), std::move(style), std::move(fun));
5456
#elif defined(SDL)
5557
{
56-
auto sys = sdl::select_sdl_setup(initial_width, initial_height);
58+
auto sys = sdl::select_sdl_setup(initial_width, initial_height, window_name);
5759
return std::make_unique<Context>(std::move(sys.first),
5860
std::move(sys.second),
5961
std::move(style), std::move(fun));

src/win32/select_win32_renderer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace iw = imgui::win32;
99
auto WndProc = nullptr;
1010

1111
std::pair<std::unique_ptr<imgui::SystemIntegration>, std::unique_ptr<imgui::Renderer>> iw::select_win32_setup(size_t initial_width,
12-
size_t initial_height)
12+
size_t initial_height, std::string const& window_name)
1313
{
1414
auto is_d3d_9_available = Direct3DCreate9(D3D_SDK_VERSION);
1515
// further tests for other versions could be added..
@@ -19,7 +19,7 @@ std::pair<std::unique_ptr<imgui::SystemIntegration>, std::unique_ptr<imgui::Rend
1919
else
2020
return {nullptr, nullptr};
2121

22-
auto system = std::make_unique<iw::SystemIntegration>(initial_width, initial_height, "window");
22+
auto system = std::make_unique<iw::SystemIntegration>(initial_width, initial_height, window_name.c_str());
2323
auto renderer = std::make_unique<id::Renderer>(system->handle());
2424
return {std::move(system), std::move(renderer)};
2525
}

src/win32/select_win32_renderer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ struct Renderer;
77
struct SystemIntegration;
88
namespace win32
99
{
10-
std::pair<std::unique_ptr<SystemIntegration>, std::unique_ptr<Renderer>> select_win32_setup(size_t initial_width, size_t initial_height);
10+
std::pair<std::unique_ptr<SystemIntegration>, std::unique_ptr<Renderer>> select_win32_setup(size_t initial_width, size_t initial_height, std::string const& window_name);
1111
} // namespace win32
1212
} // namespace imgui

0 commit comments

Comments
 (0)