From 757902063bba9c6691e0de698c96fddeb1bf1f98 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Sun, 3 May 2026 18:32:46 -0500 Subject: [PATCH] First commit --- .gitignore | 1 + CMakeLists.txt | 82 ++++++++++ include/bigscreen.hpp | 254 +++++++++++++++++++++++++++++ include/font.h | 12 ++ src/bigscreenplayer.cpp | 143 ++++++++++++++++ src/bigscreenwindow.cpp | 217 ++++++++++++++++++++++++ src/button.cpp | 204 +++++++++++++++++++++++ src/clipper.cpp | 47 ++++++ src/font.cpp | 274 +++++++++++++++++++++++++++++++ src/hgrid.cpp | 353 ++++++++++++++++++++++++++++++++++++++++ src/main.cpp | 57 +++++++ src/text.cpp | 85 ++++++++++ src/vgrid.cpp | 353 ++++++++++++++++++++++++++++++++++++++++ tmp/file.tcross | 13 ++ 14 files changed, 2095 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 include/bigscreen.hpp create mode 100644 include/font.h create mode 100644 src/bigscreenplayer.cpp create mode 100644 src/bigscreenwindow.cpp create mode 100644 src/button.cpp create mode 100644 src/clipper.cpp create mode 100644 src/font.cpp create mode 100644 src/hgrid.cpp create mode 100644 src/main.cpp create mode 100644 src/text.cpp create mode 100644 src/vgrid.cpp create mode 100644 tmp/file.tcross diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8a5e28a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 3.16) + +project(bigscreen) + + + +set(CMAKE_CXX_STANDARD 17) + +include(FetchContent) +find_package(PkgConfig REQUIRED) +pkg_check_modules(MPV REQUIRED mpv) + +# 1. Fetch SDL2 +FetchContent_Declare( + SDL2 + GIT_REPOSITORY https://github.com/libsdl-org/SDL.git + GIT_TAG release-2.32.10 # Use latest stable tag + GIT_SHALLOW TRUE +) +set(BUILD_SHARED_LIBS OFF) +set(SDLTTF_VENDORED ON) +set(SDLIMAGE_VENDORED ON) +FetchContent_MakeAvailable(SDL2) + +# 2. Configure SDL2_image +FetchContent_Declare( + SDL2_image + GIT_REPOSITORY https://github.com/libsdl-org/SDL_image.git + GIT_TAG release-2.8.12 # Use latest stable tag + GIT_SHALLOW TRUE +) +# Critical: Disable installation to avoid header path conflicts +set(SDL2IMAGE_INSTALL OFF) +# Critical: Set BUILD_SHARED_LIBS to FALSE if you want static linking, or TRUE for shared + +FetchContent_MakeAvailable(SDL2_image) + +# 3. Configure SDL2_ttf +FetchContent_Declare( + SDL2_ttf + GIT_REPOSITORY https://github.com/libsdl-org/SDL_ttf.git + GIT_TAG release-2.24.0 # Use latest stable tag + GIT_SHALLOW TRUE +) +# Critical: Disable installation to avoid header path conflicts +set(SDL2TTF_INSTALL OFF) +# Note: SDL2_ttf may also respect BUILD_SHARED_LIBS +FetchContent_MakeAvailable(SDL2_ttf) + + +FetchContent_Declare( + TessesCrossLang + GIT_REPOSITORY https://git.tesses.org/tesses50/crosslang + GIT_SHALLOW TRUE +) + +set(TESSESFRAMEWORK_ENABLE_STATIC ON) +set(TESSESFRAMEWORK_ENABLE_SHARED OFF) +set(TESSESFRAMEWORK_ENABLE_APPS OFF) +set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF) +set(CROSSLANG_ENABLE_BINARIES OFF) + +FetchContent_MakeAvailable(TessesCrossLang) + +add_executable(${PROJECT_NAME} src/main.cpp src/bigscreenwindow.cpp src/bigscreenplayer.cpp src/button.cpp src/vgrid.cpp src/hgrid.cpp src/clipper.cpp src/font.cpp src/text.cpp) + +target_link_libraries(${PROJECT_NAME} PUBLIC crosslang_static) + +target_include_directories(${PROJECT_NAME} PUBLIC include) + +target_link_libraries(${PROJECT_NAME} PUBLIC + SDL2::SDL2main + SDL2::SDL2-static + SDL2_image::SDL2_image-static + SDL2_ttf::SDL2_ttf-static +) + +target_include_directories(${PROJECT_NAME} PRIVATE ${MPV_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${MPV_LIBRARIES}) + +# Ensure linker flags are added (important for some systems) +target_link_options(${PROJECT_NAME} PRIVATE ${MPV_LDFLAGS}) \ No newline at end of file diff --git a/include/bigscreen.hpp b/include/bigscreen.hpp new file mode 100644 index 0000000..50578b5 --- /dev/null +++ b/include/bigscreen.hpp @@ -0,0 +1,254 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include + + +namespace Tesses::BigScreen { + + constexpr int GRID_STRETCH_SZ(int ammount) + { + return -ammount; + } + constexpr int GRID_STRETCH = GRID_STRETCH_SZ(1); + /* + --bg-dark: hsl(136 100% 0%); + --bg: hsl(133 100% 2%); + --bg-light: hsl(134 100% 4%); + --text: hsl(127 100% 90%); + --text-muted: hsl(128 34% 64%); + --highlight: hsl(144 100% 15%); + --border: hsl(133 100% 9%); + --border-muted: hsl(131 100% 4%); + --primary: hsl(134 57% 56%); + --secondary: hsl(301 74% 72%); + --danger: hsl(7 94% 66%); + --warning: hsl(53 100% 24%); + --success: hsl(163 100% 26%); + --info: hsl(217 100% 70%); + */ + + constexpr SDL_Color COLOR_BGDARK = {.r = 0,.g=0,.b=0,.a=255}; + + constexpr SDL_Color COLOR_BG = {.r = 0,.g=10,.b=2,.a=255}; + + constexpr SDL_Color COLOR_BGLIGHT = {.r = 0,.g=20,.b=5,.a=255}; + + constexpr SDL_Color COLOR_TEXT = {.r = 204,.g=255,.b=210,.a=255}; + + constexpr SDL_Color COLOR_TEXTMUTED = {.r = 132,.g=194,.b=140,.a=255}; + /* #004D1F*/ + constexpr SDL_Color COLOR_HIGHLIGHT = {.r = 0,.g=77,.b=31,.a=255}; + /* #002E0A */ + constexpr SDL_Color COLOR_BORDER = {.r = 0,.g=46,.b=10,.a=255}; + constexpr SDL_Color COLOR_BORDERMUTED = {.r = 0,.g=20,.b=4,.a=255}; + constexpr SDL_Color COLOR_PRIMARY = {.r = 79,.g=207,.b=109,.a=255}; + + + + class BigScreenWindow; + + enum class EventResult { + Ignored, + Handled, + ParentDo + }; + + enum class LastDirection { + North, + South, + East, + West + }; + + class Widget { + public: + std::weak_ptr parent; + virtual EventResult Event(SDL_Event& event, SDL_Rect& rect) = 0; + virtual void Draw(SDL_Rect& rect)=0; + virtual std::shared_ptr GetRoot(); + virtual ~Widget() = default; + + virtual bool CanFocus(); + + virtual int MinHeight(); + virtual int MinWidth(); + }; + + class VGrid : public Widget, public std::enable_shared_from_this + { + std::vector, int>> widgets; + public: + void AddChild(std::shared_ptr widget, int height); + EventResult Event(SDL_Event& event,SDL_Rect& rect); + void Draw(SDL_Rect& rect); + ~VGrid() = default; + + int MinWidth(); + + int MinHeight(); + }; + class HGrid : public Widget, public std::enable_shared_from_this + { + std::vector, int>> widgets; + public: + void AddChild(std::shared_ptr widget, int width); + EventResult Event(SDL_Event& event,SDL_Rect& rect); + void Draw(SDL_Rect& rect); + ~HGrid() = default; + + int MinWidth(); + + int MinHeight(); + }; + class Text : public Widget + { + private: + std::string text; + SDL_Color color; + public: + Text(std::string text); + Text(std::string text, std::string color); + Text(std::string text, SDL_Color color); + bool CanFocus(); + + SDL_Color GetColor(); + void SetColor(SDL_Color color); + void SetColor(std::string color); + std::string GetText(); + void SetText(std::string text); + + EventResult Event(SDL_Event& event,SDL_Rect& rect); + void Draw(SDL_Rect& rect); + + + int MinWidth(); + + int MinHeight(); + }; + class Button : public Widget, public std::enable_shared_from_this