refactor(gui): reorganize GUI includes and introduce new components
- Updated include paths for various GUI-related headers to improve organization and clarity. - Introduced new components for better modularity, including PaletteEditorWidget and EditorCardManager. - Refactored existing code to utilize the new components, ensuring consistency across the GUI subsystem. Benefits: - Enhances maintainability and readability of the GUI code. - Facilitates future enhancements and optimizations within the GUI subsystem.
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
set(
|
||||
YAZE_GUI_SRC
|
||||
app/gui/canvas.cc
|
||||
# ==============================================================================
|
||||
# GUI Library Refactoring (see docs/gui-refactor.md)
|
||||
# ==============================================================================
|
||||
# The monolithic yaze_gui has been decomposed into smaller, layered libraries
|
||||
# to improve build times and code organization. The yaze_gui target is now
|
||||
# an INTERFACE library that aggregates these components for backward
|
||||
# compatibility.
|
||||
# ==============================================================================
|
||||
|
||||
# 1. Define Source Groups for each sub-library
|
||||
set(GUI_CORE_SRC
|
||||
app/gui/core/color.cc
|
||||
app/gui/core/input.cc
|
||||
app/gui/core/layout_helpers.cc
|
||||
app/gui/core/style.cc
|
||||
app/gui/core/theme_manager.cc
|
||||
app/gui/core/ui_helpers.cc
|
||||
)
|
||||
|
||||
set(CANVAS_SRC
|
||||
app/gui/canvas/bpp_format_ui.cc
|
||||
app/gui/canvas/canvas.cc
|
||||
app/gui/canvas/canvas_automation_api.cc
|
||||
app/gui/canvas/canvas_context_menu.cc
|
||||
app/gui/canvas/canvas_interaction_handler.cc
|
||||
@@ -9,61 +27,89 @@ set(
|
||||
app/gui/canvas/canvas_performance_integration.cc
|
||||
app/gui/canvas/canvas_usage_tracker.cc
|
||||
app/gui/canvas/canvas_utils.cc
|
||||
app/gui/color.cc
|
||||
app/gui/editor_card_manager.cc
|
||||
app/gui/editor_layout.cc
|
||||
app/gui/input.cc
|
||||
app/gui/layout_helpers.cc
|
||||
app/gui/themed_widgets.cc
|
||||
app/gui/modules/asset_browser.cc
|
||||
app/gui/modules/text_editor.cc
|
||||
app/gui/style.cc
|
||||
app/gui/theme_manager.cc
|
||||
app/gui/ui_helpers.cc
|
||||
app/gui/background_renderer.cc # Moved from yaze_editor (used by style.cc)
|
||||
app/gui/widgets/agent_chat_widget.cc
|
||||
app/gui/widgets/collaboration_panel.cc
|
||||
)
|
||||
|
||||
set(GUI_WIDGETS_SRC
|
||||
app/gui/widgets/asset_browser.cc
|
||||
app/gui/widgets/dungeon_object_emulator_preview.cc
|
||||
app/gui/widgets/palette_editor_widget.cc
|
||||
app/gui/widgets/palette_widget.cc
|
||||
app/gui/widgets/text_editor.cc
|
||||
app/gui/widgets/themed_widgets.cc
|
||||
app/gui/widgets/tile_selector_widget.cc
|
||||
app/gui/widgets/widget_auto_register.cc
|
||||
app/gui/widgets/widget_id_registry.cc
|
||||
app/gui/widgets/widget_measurement.cc
|
||||
app/gui/widgets/widget_state_capture.cc
|
||||
# Canvas system components
|
||||
)
|
||||
|
||||
# ==============================================================================
|
||||
# Yaze GUI Library
|
||||
# ==============================================================================
|
||||
# This library contains all GUI-related functionality:
|
||||
# - Canvas system
|
||||
# - ImGui widgets and utilities
|
||||
# - Input handling
|
||||
# - Theme management
|
||||
# - Color utilities
|
||||
# - Background rendering
|
||||
#
|
||||
# Dependencies: yaze_gfx, yaze_util, ImGui, SDL2
|
||||
# ==============================================================================
|
||||
|
||||
add_library(yaze_gui STATIC ${YAZE_GUI_SRC})
|
||||
|
||||
target_precompile_headers(yaze_gui PRIVATE
|
||||
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/yaze_pch.h>"
|
||||
set(GUI_AUTOMATION_SRC
|
||||
app/gui/automation/widget_auto_register.cc
|
||||
app/gui/automation/widget_id_registry.cc
|
||||
app/gui/automation/widget_measurement.cc
|
||||
app/gui/automation/widget_state_capture.cc
|
||||
)
|
||||
|
||||
target_include_directories(yaze_gui PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src/lib
|
||||
${CMAKE_SOURCE_DIR}/src/lib/imgui
|
||||
${CMAKE_SOURCE_DIR}/incl
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${PROJECT_BINARY_DIR}
|
||||
set(GUI_APP_SRC
|
||||
app/gui/app/agent_chat_widget.cc
|
||||
app/gui/app/background_renderer.cc
|
||||
app/gui/app/collaboration_panel.cc
|
||||
app/gui/app/editor_card_manager.cc
|
||||
app/gui/app/editor_layout.cc
|
||||
)
|
||||
|
||||
target_link_libraries(yaze_gui PUBLIC
|
||||
# 2. Create Static Libraries and Establish Link Dependencies
|
||||
add_library(yaze_gui_core STATIC ${GUI_CORE_SRC})
|
||||
add_library(yaze_canvas STATIC ${CANVAS_SRC})
|
||||
add_library(yaze_gui_widgets STATIC ${GUI_WIDGETS_SRC})
|
||||
add_library(yaze_gui_automation STATIC ${GUI_AUTOMATION_SRC})
|
||||
add_library(yaze_gui_app STATIC ${GUI_APP_SRC})
|
||||
|
||||
# Link dependencies between the new libraries
|
||||
target_link_libraries(yaze_gui_core PUBLIC yaze_util ImGui nlohmann_json::nlohmann_json)
|
||||
target_link_libraries(yaze_canvas PUBLIC yaze_gui_core yaze_gfx)
|
||||
target_link_libraries(yaze_gui_widgets PUBLIC yaze_gui_core yaze_gfx)
|
||||
target_link_libraries(yaze_gui_automation PUBLIC yaze_gui_core)
|
||||
target_link_libraries(yaze_gui_app PUBLIC yaze_gui_core yaze_gui_widgets yaze_gui_automation)
|
||||
|
||||
set(GUI_SUB_LIBS
|
||||
yaze_gui_core
|
||||
yaze_canvas
|
||||
yaze_gui_widgets
|
||||
yaze_gui_automation
|
||||
yaze_gui_app
|
||||
)
|
||||
|
||||
# Apply common properties to all new sub-libraries
|
||||
foreach(LIB ${GUI_SUB_LIBS})
|
||||
target_precompile_headers(${LIB} PRIVATE
|
||||
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/yaze_pch.h>"
|
||||
)
|
||||
target_include_directories(${LIB} PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/incl
|
||||
${CMAKE_SOURCE_DIR}/src/app/gui
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${PROJECT_BINARY_DIR}
|
||||
)
|
||||
set_target_properties(${LIB} PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_compile_definitions(${LIB} PRIVATE linux stricmp=strcasecmp)
|
||||
elseif(APPLE)
|
||||
target_compile_definitions(${LIB} PRIVATE MACOS)
|
||||
elseif(WIN32)
|
||||
target_compile_definitions(${LIB} PRIVATE WINDOWS)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# 3. Create Aggregate INTERFACE library
|
||||
add_library(yaze_gui INTERFACE)
|
||||
target_link_libraries(yaze_gui INTERFACE
|
||||
yaze_gui_core
|
||||
yaze_canvas
|
||||
yaze_gui_widgets
|
||||
yaze_gui_automation
|
||||
yaze_gui_app
|
||||
# Link original public dependencies so downstream targets receive them
|
||||
yaze_gfx
|
||||
yaze_util
|
||||
yaze_common
|
||||
@@ -72,19 +118,4 @@ target_link_libraries(yaze_gui PUBLIC
|
||||
${SDL_TARGETS}
|
||||
)
|
||||
|
||||
set_target_properties(yaze_gui PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
)
|
||||
|
||||
# Platform-specific compile definitions
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_compile_definitions(yaze_gui PRIVATE linux stricmp=strcasecmp)
|
||||
elseif(APPLE)
|
||||
target_compile_definitions(yaze_gui PRIVATE MACOS)
|
||||
elseif(WIN32)
|
||||
target_compile_definitions(yaze_gui PRIVATE WINDOWS)
|
||||
endif()
|
||||
|
||||
message(STATUS "✓ yaze_gui library configured")
|
||||
message(STATUS "✓ yaze_gui library refactored and configured")
|
||||
|
||||
Reference in New Issue
Block a user