From 5ab277a62d6fcd6a9ded38b07f526d2e6014003a Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Tue, 31 Mar 2026 14:55:41 +0100 Subject: [PATCH] adjust comment style to match imgui standard --- backends/imgui_impl_emscripten.cpp | 26 +++++++++++++------------- backends/imgui_impl_emscripten.h | 12 ++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/backends/imgui_impl_emscripten.cpp b/backends/imgui_impl_emscripten.cpp index 4aad0717b..228997f13 100644 --- a/backends/imgui_impl_emscripten.cpp +++ b/backends/imgui_impl_emscripten.cpp @@ -14,7 +14,7 @@ namespace { -/// A map of HTML5 key names to imgui keys +// A map of HTML5 key names to imgui keys static const std::unordered_map key_translate_lookup{ // main character keys {"Backquote", ImGuiKey_GraveAccent}, @@ -156,7 +156,7 @@ static const std::unordered_map key_translate_lookup{ ImGuiKey translate_key(char const* emscripten_key) __attribute__((__const__)); ImGuiKey translate_key(char const* emscripten_key) { - /// Translate an emscripten-provided browser string describing a keycode to an imgui key code + // Translate an emscripten-provided browser string describing a keycode to an imgui key code if(auto it{key_translate_lookup.find(emscripten_key)}; it != key_translate_lookup.end()) { return it->second; } @@ -165,7 +165,7 @@ ImGuiKey translate_key(char const* emscripten_key) { constexpr ImGuiMouseButton translate_mousebutton(unsigned short emscripten_button) __attribute__((__const__)); constexpr ImGuiMouseButton translate_mousebutton(unsigned short emscripten_button) { - /// Translate an emscripten-provided integer describing a mouse button to an imgui mouse button + // Translate an emscripten-provided integer describing a mouse button to an imgui mouse button if(emscripten_button == 1) return ImGuiMouseButton_Middle; // 1 = middle mouse button if(emscripten_button == 2) return ImGuiMouseButton_Right; // 2 = right mouse button if(emscripten_button > ImGuiMouseButton_COUNT) return ImGuiMouseButton_Middle; // treat any weird clicks on unexpected buttons (button 6 upwards) as middle mouse @@ -176,7 +176,7 @@ constexpr ImGuiMouseButton translate_mousebutton(unsigned short emscripten_butto namespace emscripten_browser_cursor_internal { -////////////////////////////////// Interface /////////////////////////////////// +// Browser cursor helpers enum class cursor { // General @@ -234,17 +234,17 @@ enum class cursor { void set(cursor new_cursor); // set a new cursor from a cursor enum void unset(); // clear the current cursor setting -//////////////////////////////// Implementation //////////////////////////////// +// Browser cursor helper implementation bool is_set() { - /// Returns whether the cursor is currently set + // Returns whether the cursor is currently set return EM_ASM_INT( return !(!document.body.style.cursor || document.body.style.cursor.length === 0 ); ); } std::string get_string() { - /// Return the current cursor setting as a string + // Return the current cursor setting as a string auto cursor_str_ptr{reinterpret_cast(EM_ASM_PTR( return stringToNewUTF8(document.body.style.cursor); ))}; @@ -254,7 +254,7 @@ std::string get_string() { } void set(cursor new_cursor) { - /// Set the cursor according to the given enum + // Set the cursor according to the given enum // Note, implementations omitted for cursors not used by imgui. For full implementation, use https://github.com/Armchair-Software/emscripten-browser-cursor switch(new_cursor) { case cursor::cursor_default: @@ -289,7 +289,7 @@ void set(cursor new_cursor) { } void set(std::string const &new_cursor) { - /// Set the cursor from an arbitrary string + // Set the cursor from an arbitrary string EM_ASM({ document.body.style.cursor = UTF8ToString($0); }, new_cursor.c_str()); @@ -300,7 +300,7 @@ void set(std::string const &new_cursor) { namespace { void update_cursor() { - /// Sync any cursor changes due to ImGUI to the browser's cursor + // Sync any cursor changes due to ImGui to the browser's cursor static emscripten_browser_cursor_internal::cursor current_cursor{emscripten_browser_cursor_internal::cursor::invalid}; static std::optional cursor_to_restore; @@ -356,7 +356,7 @@ void update_cursor() { } // anonymous namespace void ImGui_ImplEmscripten_Init() { - /// Initialise the Emscripten backend, setting input callbacks + // Initialise the Emscripten backend, setting input callbacks auto &imgui_io{ImGui::GetIO()}; imgui_io.BackendPlatformName = "imgui_impl_emscripten"; imgui_io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; @@ -581,7 +581,7 @@ void ImGui_ImplEmscripten_Init() { } void ImGui_ImplEmscripten_Shutdown() { - /// Unset any callbacks set by Init + // Unset any callbacks set by Init emscripten_set_mousemove_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, false, nullptr); emscripten_set_mousedown_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, false, nullptr); emscripten_set_mouseup_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, false, nullptr); @@ -603,7 +603,7 @@ void ImGui_ImplEmscripten_Shutdown() { } void ImGui_ImplEmscripten_NewFrame() { - /// Update any state that needs to be polled + // Update any state that needs to be polled update_cursor(); } diff --git a/backends/imgui_impl_emscripten.h b/backends/imgui_impl_emscripten.h index f961f0590..fb15af075 100644 --- a/backends/imgui_impl_emscripten.h +++ b/backends/imgui_impl_emscripten.h @@ -39,14 +39,14 @@ #error The imgui_impl_emscripten backend reqiuires Emscripten. #endif -/// Initialise the Emscripten backend, setting input callbacks. This should be called after ImGui::CreateContext(); +// Initialise the Emscripten backend, setting input callbacks. This should be called after ImGui::CreateContext(); void ImGui_ImplEmscripten_Init(); -/// Shut down the Emscripten backend. This unsets all Emscripten input callbacks set by Init. -/// Note it'll also unset any Emscripten input callbacks set elsewhere in the program! -/// Note also there is no obligation to ever call this, as there is not necessarily any such concept as "shutting down" when running in the browser, and we have no resources to release. The user can just close the tab. +// Shut down the Emscripten backend. This unsets all Emscripten input callbacks set by Init. +// Note it'll also unset any Emscripten input callbacks set elsewhere in the program! +// Note also there is no obligation to ever call this, as there is not necessarily any such concept as "shutting down" when running in the browser, and we have no resources to release. The user can just close the tab. void ImGui_ImplEmscripten_Shutdown(); -/// Call every frame to update polled input events, i.e. gamepads, and update imgui's cursors. -/// If you aren't using gamepad input to control imgui, and you're not using browser native cursor rendering (i.e. if imgui is rendering cursors internally), you don't need to call this. +// Call every frame to update polled input events, i.e. gamepads, and update imgui's cursors. +// If you aren't using gamepad input to control imgui, and you're not using browser native cursor rendering (i.e. if imgui is rendering cursors internally), you don't need to call this. void ImGui_ImplEmscripten_NewFrame();