From 6a74b3d26c660f0f52561f9024c302ad3b699b77 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:03:20 +0200 Subject: [PATCH 1/3] optimize videowindow (black bg) --- client/windows/GUIClasses.cpp | 9 +++++++-- client/windows/GUIClasses.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index ea9e7a77f..3832defb1 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -34,6 +34,7 @@ #include "../widgets/TextControls.h" #include "../widgets/ObjectLists.h" #include "../widgets/VideoWidget.h" +#include "../widgets/GraphicalPrimitiveCanvas.h" #include "../render/Canvas.h" #include "../render/IRenderHandler.h" @@ -1618,6 +1619,7 @@ VideoWindow::VideoWindow(VideoPath video, ImagePath rim, bool showBackground, fl if(!rim.empty()) { + setBackground(rim); videoPlayer = std::make_shared(Point(80, 186), video, true, [this](){ exit(false); }); pos = center(Rect(0, 0, 800, 600)); } @@ -1630,8 +1632,11 @@ VideoWindow::VideoWindow(VideoPath video, ImagePath rim, bool showBackground, fl if(showBackground) backgroundAroundWindow = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y)); - if(!rim.empty()) - setBackground(rim); + if(rim.empty()) + { + blackBackground = std::make_shared(Rect(0, 0, pos.w, pos.h)); + blackBackground->addBox(Point(0, 0), Point(pos.w, pos.h), Colors::BLACK); + } } void VideoWindow::exit(bool skipped) diff --git a/client/windows/GUIClasses.h b/client/windows/GUIClasses.h index 4c7b68a75..5e58ad6d2 100644 --- a/client/windows/GUIClasses.h +++ b/client/windows/GUIClasses.h @@ -44,6 +44,7 @@ class CFilledTexture; class IImage; class VideoWidget; class VideoWidgetOnce; +class GraphicalPrimitiveCanvas; enum class EUserEvent; @@ -506,6 +507,7 @@ class VideoWindow : public CWindowObject { std::shared_ptr videoPlayer; std::shared_ptr backgroundAroundWindow; + std::shared_ptr blackBackground; std::function closeCb; From 8907dc936229fefda001aa03c39e646768b35aa8 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:15:54 +0200 Subject: [PATCH 2/3] improvement --- client/windows/GUIClasses.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 3832defb1..0bbcfcec3 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1617,6 +1617,9 @@ VideoWindow::VideoWindow(VideoPath video, ImagePath rim, bool showBackground, fl addUsedEvents(LCLICK | KEYBOARD); + if(showBackground) + backgroundAroundWindow = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, GH.screenDimensions().x, GH.screenDimensions().y)); + if(!rim.empty()) { setBackground(rim); @@ -1625,18 +1628,15 @@ VideoWindow::VideoWindow(VideoPath video, ImagePath rim, bool showBackground, fl } else { + blackBackground = std::make_shared(Rect(0, 0, pos.w, pos.h)); + blackBackground->addBox(Point(0, 0), Point(pos.w, pos.h), Colors::BLACK); videoPlayer = std::make_shared(Point(0, 0), video, true, scaleFactor, [this](){ exit(false); }); pos = center(Rect(0, 0, videoPlayer->pos.w, videoPlayer->pos.h)); } - if(showBackground) - backgroundAroundWindow = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y)); + if(backgroundAroundWindow) + backgroundAroundWindow->pos.moveTo(Point(0, 0)); - if(rim.empty()) - { - blackBackground = std::make_shared(Rect(0, 0, pos.w, pos.h)); - blackBackground->addBox(Point(0, 0), Point(pos.w, pos.h), Colors::BLACK); - } } void VideoWindow::exit(bool skipped) From b7b42770432741d607222ff4083e41694f74f8b3 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:20:43 +0200 Subject: [PATCH 3/3] fix for smaller window --- client/windows/GUIClasses.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 0bbcfcec3..46a9775e5 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1628,10 +1628,10 @@ VideoWindow::VideoWindow(VideoPath video, ImagePath rim, bool showBackground, fl } else { - blackBackground = std::make_shared(Rect(0, 0, pos.w, pos.h)); - blackBackground->addBox(Point(0, 0), Point(pos.w, pos.h), Colors::BLACK); + blackBackground = std::make_shared(Rect(0, 0, GH.screenDimensions().x, GH.screenDimensions().y)); videoPlayer = std::make_shared(Point(0, 0), video, true, scaleFactor, [this](){ exit(false); }); pos = center(Rect(0, 0, videoPlayer->pos.w, videoPlayer->pos.h)); + blackBackground->addBox(Point(0, 0), Point(pos.x, pos.y), Colors::BLACK); } if(backgroundAroundWindow)