# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: Copyright (C) 2026 Max A. Vilkki a.k.a. codise
#
# ui: ImGui panels, fonts and theme, and the frame scheduling of the event-driven UI.
# ImGui only: the SDL window, GL context and event loop live in the app, which also carries
# out what the panels ask for on the player.

include(flipsid_embed)

add_library(flipsid_ui STATIC
    about_window.cpp
    browser_panel.cpp
    browser_tree.cpp
    context.cpp
    device_list.cpp
    engine_controls.cpp
    filter_curves_panel.cpp
    fonts.cpp
    format.cpp
    frame_scheduler.cpp
    hardsid_setup_window.cpp
    hvsc_window.cpp
    main_window.cpp
    player_frames.cpp
    player_panels.cpp
    playlist_m3u.cpp
    playlist_panel.cpp
    search_format.cpp
    search_panel.cpp
    selection.cpp
    settings_window.cpp
    theme.cpp
    theme_editor.cpp
    theme_file.cpp
    top_bar.cpp
    tune_details.cpp
    tune_info_panel.cpp
    widgets.cpp
)
add_library(flipsid::ui ALIAS flipsid_ui)

target_include_directories(flipsid_ui PUBLIC include)
# The panels show the player's snapshots and settings; they don't drive it themselves
# (main_window.h), so only its types are used.
target_link_libraries(flipsid_ui PUBLIC ext::imgui flipsid::player flipsid::engines flipsid::output)
# The filter curve graphs (#248): ImPlot stays an implementation detail of the module.
target_link_libraries(flipsid_ui PRIVATE ext::implot)
# The Settings window edits the settings struct; the app loads and saves it.
target_link_libraries(flipsid_ui PUBLIC flipsid::settings)
# The library's panels draw its index, searches and filters; the app runs the library.
target_link_libraries(flipsid_ui PUBLIC flipsid::library)
# The Engine panel edits SID profiles; the app loads, saves and resolves them.
target_link_libraries(flipsid_ui PUBLIC flipsid::profiles)
# Liked Songs: the Browser's folder and the hearts.
target_link_libraries(flipsid_ui PUBLIC flipsid::playlist)
# A mixer row's fader, by the mixer's own fader law (#432).
target_link_libraries(flipsid_ui PRIVATE flipsid::mixer)

# About 106 KB of font data in the binary (DESIGN §5.5).
set(fontDir "${PROJECT_SOURCE_DIR}/assets/fonts")
flipsid_embed_files(flipsid_ui
    NAMESPACE flipsid::ui::embedded
    HEADER flipsid/ui/embedded_fonts.h
    FILES
        interRegular=${fontDir}/Inter-Regular.ttf
        interSemiBold=${fontDir}/Inter-SemiBold.ttf
        jetBrainsMonoRegular=${fontDir}/JetBrainsMono-Regular.ttf
)

flipsid_configure_target(flipsid_ui)
