Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion conan/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def requirements(self):

if self.options.eeprom_editor or self.options.kickui:
self.requires("imgui/1.92.6")
self.requires("portable-file-dialogs/0.1.0")

if self.settings.os == "Windows":
self.requires("npcap/1.70")
Expand Down
21 changes: 11 additions & 10 deletions tools/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
find_package(imgui REQUIRED CONFIG)
find_package(OpenGL REQUIRED)

find_package(glfw3)
if (glfw3_FOUND)
message(STATUS "Using glfw found installed on system")
else()
message(STATUS "Downloading glfw using FetchContent")
# GLFW via FetchContent — the Conan glfw recipe pulls xorg/system which
# demands dozens of X11 -dev packages that are not actually needed.
include(FetchContent)
Expand All @@ -14,11 +19,7 @@ FetchContent_Declare(glfw
GIT_TAG 3.4
)
FetchContent_MakeAvailable(glfw)

# ImGui backend + helper sources shipped in the Conan package under res/
get_filename_component(_IMGUI_PKG_DIR "${imgui_INCLUDE_DIR}" DIRECTORY)
set(IMGUI_RES_DIR "${_IMGUI_PKG_DIR}/res")
set(IMGUI_BACKENDS_DIR "${IMGUI_RES_DIR}/bindings")
endif()

# Embed the bundled fonts (assets/fonts/*.ttf) into a generated source file.
file(GLOB KICKCAT_BUNDLED_FONTS CONFIGURE_DEPENDS
Expand All @@ -41,15 +42,15 @@ add_custom_command(
add_library(kickcat_imgui STATIC
GuiApp.cc
${KICKCAT_BUNDLED_FONTS_CC}
${IMGUI_BACKENDS_DIR}/imgui_impl_glfw.cpp
${IMGUI_BACKENDS_DIR}/imgui_impl_opengl3.cpp
${IMGUI_RES_DIR}/misc/cpp/imgui_stdlib.cpp
backend/imgui_impl_glfw.cpp
backend/imgui_impl_opengl3.cpp
vendor/imgui_stdlib.cpp
)

target_include_directories(kickcat_imgui PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${IMGUI_BACKENDS_DIR}
${IMGUI_RES_DIR}
backend
vendor
)

target_link_libraries(kickcat_imgui PUBLIC
Expand Down
21 changes: 21 additions & 0 deletions tools/common/vendor/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014-2026 Omar Cornut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
100 changes: 100 additions & 0 deletions tools/common/vendor/imgui_stdlib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)

// This is also an example of how you may wrap your own similar types.
// TL;DR; this is using the ImGuiInputTextFlags_CallbackResize facility,
// which also demonstrated in 'Dear ImGui Demo->Widgets->Text Input->Resize Callback'.

// Changelog:
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string

// Usage:
// {
// #include "misc/cpp/imgui_stdlib.h"
// #include "misc/cpp/imgui_stdlib.cpp" // <-- If you want to include implementation without messing with your project/build.
// [...]
// std::string my_string;
// ImGui::InputText("my string", &my_string);
// }

// See more C++ related extension (fmt, RAII, syntactic sugar) on Wiki:
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness

#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_stdlib.h"

// Clang warnings with -Weverything
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
#endif

struct InputTextCallback_UserData
{
std::string* Str;
ImGuiInputTextCallback ChainCallback;
void* ChainCallbackUserData;
};

static int InputTextCallback(ImGuiInputTextCallbackData* data)
{
InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData;
if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
{
// Resize string callback
// If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want.
std::string* str = user_data->Str;
IM_ASSERT(data->Buf == str->c_str());
str->resize(data->BufTextLen);
data->Buf = (char*)str->c_str();
}
else if (user_data->ChainCallback)
{
// Forward to user callback, if any
data->UserData = user_data->ChainCallbackUserData;
return user_data->ChainCallback(data);
}
return 0;
}

bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
flags |= ImGuiInputTextFlags_CallbackResize;

InputTextCallback_UserData cb_user_data;
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
}

bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
flags |= ImGuiInputTextFlags_CallbackResize;

InputTextCallback_UserData cb_user_data;
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data);
}

bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
flags |= ImGuiInputTextFlags_CallbackResize;

InputTextCallback_UserData cb_user_data;
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
}

#if defined(__clang__)
#pragma clang diagnostic pop
#endif

#endif // #ifndef IMGUI_DISABLE
37 changes: 37 additions & 0 deletions tools/common/vendor/imgui_stdlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)

// This is also an example of how you may wrap your own similar types.
// TL;DR; this is using the ImGuiInputTextFlags_CallbackResize facility,
// which also demonstrated in 'Dear ImGui Demo->Widgets->Text Input->Resize Callback'.

// Changelog:
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string

// Usage:
// {
// #include "misc/cpp/imgui_stdlib.h"
// #include "misc/cpp/imgui_stdlib.cpp" // <-- If you want to include implementation without messing with your project/build.
// [...]
// std::string my_string;
// ImGui::InputText("my string", &my_string);
// }

// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness

#pragma once

#ifndef IMGUI_DISABLE

#include <string>

namespace ImGui
{
// ImGui::InputText() with std::string
// Because text input needs dynamic resizing, we need to setup a callback to grow the capacity
IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
}

#endif // #ifndef IMGUI_DISABLE
2 changes: 1 addition & 1 deletion tools/eeprom_editor/App.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#endif

#include <imgui.h>
#include <portable-file-dialogs.h>
#include "vendor/portable-file-dialogs.h"

#include "kickcat/EEPROM/EEPROM_factory.h"
#include "kickcat/Bus.h"
Expand Down
2 changes: 0 additions & 2 deletions tools/eeprom_editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
find_package(portable-file-dialogs REQUIRED CONFIG)

add_executable(eeprom_editor
main.cc
Expand All @@ -15,7 +14,6 @@ add_executable(eeprom_editor
target_link_libraries(eeprom_editor PRIVATE
kickcat
kickcat_imgui
portable-file-dialogs::portable-file-dialogs
)

set_kickcat_properties(eeprom_editor)
Expand Down
2 changes: 1 addition & 1 deletion tools/eeprom_editor/StringsEditor.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Editors.h"

#include <misc/cpp/imgui_stdlib.h>
#include <imgui_stdlib.h>

namespace kickcat::eeprom_editor::strings
{
Expand Down
Loading