33* *
44* This file is part of the FINAL CUT widget toolkit *
55* *
6- * Copyright 2021-2024 Markus Gans *
6+ * Copyright 2021-2025 Markus Gans *
77* *
88* FINAL CUT is free software; you can redistribute it and/or modify *
99* it under the terms of the GNU Lesser General Public License as *
@@ -133,34 +133,6 @@ constexpr std::array<const char*, 97> saturn_xpm = \
133133 " "
134134}};
135135
136- struct restoreOverlaid : public fc ::FVTerm
137- {
138- ~restoreOverlaid () override ;
139-
140- void operator () (fc::FVTerm& obj) const
141- {
142- const auto * win_list = getWindowList ();
143-
144- if ( ! win_list || win_list->empty () )
145- return ;
146-
147- auto obj_vwin = obj.getVWin ();
148- bool overlaid{false };
149-
150- for (const auto * window : *win_list)
151- {
152- const auto * win = static_cast <const fc::FWidget*>(window);
153- const auto * win_vwin = win->getVWin ();
154-
155- if ( overlaid && win_vwin && win_vwin->visible )
156- putArea (win->getTermPos (), win_vwin);
157- else if ( obj_vwin == win_vwin )
158- overlaid = true ;
159- }
160- }
161- };
162-
163- restoreOverlaid::~restoreOverlaid () = default ;
164136
165137template <>
166138struct std ::hash<fc::FPoint>
@@ -206,7 +178,6 @@ void TextWindow::setPos (const fc::FPoint& pos, bool)
206178{
207179 fc::FWindow::setPos (pos, false );
208180 putArea (getTermPos (), getVWin ());
209- restoreOverlaid{}(*this );
210181}
211182
212183// ----------------------------------------------------------------------
@@ -272,7 +243,6 @@ void SpaceWindow::setPos (const fc::FPoint& pos, bool)
272243{
273244 fc::FWindow::setPos (pos, false );
274245 putArea (getTermPos (), getVWin ());
275- restoreOverlaid{}(*this );
276246}
277247
278248// ----------------------------------------------------------------------
@@ -323,26 +293,42 @@ void SpaceWindow::adjustSize()
323293// ----------------------------------------------------------------------
324294// class PictureSpaceWindow
325295// ----------------------------------------------------------------------
326- class PictureSpaceWindow final : public SpaceWindow
296+ class PictureSpaceWindow final : public fc::FWindow
327297{
328298 public:
329299 // Constructor
330- explicit PictureSpaceWindow (fc::FColor, fc::FColor, fc::FWidget* = nullptr );
300+ explicit PictureSpaceWindow (fc::FWidget* = nullptr );
301+ void setPos (const fc::FPoint&, bool = true ) override ;
331302
332303 private:
333304 // Method
334305 void draw () override ;
306+ void initLayout () override ;
307+ void adjustSize () override ;
335308};
336309
337310// ----------------------------------------------------------------------
338- PictureSpaceWindow::PictureSpaceWindow (fc::FColor fg, fc::FColor bg, fc::FWidget* parent)
339- : SpaceWindow{fg, bg, parent}
340- { }
311+ PictureSpaceWindow::PictureSpaceWindow (fc::FWidget* parent)
312+ : fc::FWindow{parent}
313+ {
314+ fc::FWidget::setForegroundColor (fc::FColor::White);
315+ fc::FWidget::setBackgroundColor (fc::FColor::Black);
316+ }
317+
318+ // ----------------------------------------------------------------------
319+ void PictureSpaceWindow::setPos (const fc::FPoint& pos, bool )
320+ {
321+ fc::FWindow::setPos (pos, false );
322+ putArea (getTermPos (), getVWin ());
323+ }
341324
342325// ----------------------------------------------------------------------
343326void PictureSpaceWindow::draw ()
344327{
345- SpaceWindow::draw ();
328+ setColor ();
329+ setTransparent ();
330+ clearArea ();
331+ unsetTransparent ();
346332
347333 if ( fc::FVTerm::getFOutput ()->getMaxColor () < 16 )
348334 return ;
@@ -362,6 +348,20 @@ void PictureSpaceWindow::draw()
362348 copyArea (getVWin (), fc::FPoint (10 , 10 ), planet.get ());
363349}
364350
351+ // ----------------------------------------------------------------------
352+ void PictureSpaceWindow::initLayout ()
353+ {
354+ auto term_size = fc::FSize ({getDesktopWidth (), getDesktopHeight ()});
355+ setSize (term_size, false );
356+ fc::FWidget::initLayout ();
357+ }
358+
359+ // ----------------------------------------------------------------------
360+ void PictureSpaceWindow::adjustSize ()
361+ {
362+ fc::FWindow::adjustSize ();
363+ initLayout ();
364+ }
365365
366366// ----------------------------------------------------------------------
367367// class ParallaxScrolling
@@ -385,13 +385,14 @@ class ParallaxScrolling final : public fc::FWidget
385385 void onClose (fc::FCloseEvent*) override ;
386386
387387 // Data members
388- TextWindow text_layer{fc::FColor::Yellow, fc::FColor::Black, this };
389388 SpaceWindow layer1_lhs{fc::FColor::DarkGray, fc::FColor::Black, this };
390389 SpaceWindow layer1_rhs{fc::FColor::DarkGray, fc::FColor::Black, this };
391390 SpaceWindow layer2_lhs{fc::FColor::LightGray, fc::FColor::Black, this };
392391 SpaceWindow layer2_rhs{fc::FColor::LightGray, fc::FColor::Black, this };
393392 SpaceWindow layer3_lhs{fc::FColor::White, fc::FColor::Black, this };
394- PictureSpaceWindow layer3_rhs{fc::FColor::White, fc::FColor::Black, this };
393+ SpaceWindow layer3_rhs{fc::FColor::White, fc::FColor::Black, this };
394+ PictureSpaceWindow picture{this };
395+ TextWindow text_layer{fc::FColor::Yellow, fc::FColor::Black, this };
395396 int timer1{-1 };
396397 int timer2{-1 };
397398 int timer3{-1 };
@@ -427,6 +428,7 @@ void ParallaxScrolling::initLayout()
427428 setGeometry ({1 , 1 }, term_size, false );
428429 auto lhs_pos = fc::FPoint{1 , 1 };
429430 auto rhs_pos = fc::FPoint{int (getDesktopWidth () + 1 ), 1 };
431+ picture.setPos (rhs_pos, false );
430432 layer1_lhs.setPos (lhs_pos, false );
431433 layer2_lhs.setPos (lhs_pos, false );
432434 layer3_lhs.setPos (lhs_pos, false );
@@ -478,6 +480,7 @@ void ParallaxScrolling::onTimer (fc::FTimerEvent* ev)
478480 else if ( timer3 == timer_id )
479481 {
480482 scrollLeft (layer3_lhs, layer3_rhs);
483+ picture.setPos (layer3_rhs.getPos ());
481484 }
482485
483486 forceTerminalUpdate ();
0 commit comments