Avoids flickering when redrawing a focused widget

This commit is contained in:
Markus Gans 2018-02-03 00:04:24 +01:00
parent 7424dd74b4
commit 2ef3d84829
7 changed files with 56 additions and 29 deletions

View File

@ -1,3 +1,6 @@
2017-02-02 Markus Gans <guru.mail@muenster.de>
* Avoids flickering when redrawing a focused widget
2017-01-31 Markus Gans <guru.mail@muenster.de> 2017-01-31 Markus Gans <guru.mail@muenster.de>
* Refactoring FSwitch::drawCheckButton * Refactoring FSwitch::drawCheckButton
* Refactoring FWidget::redraw * Refactoring FWidget::redraw

View File

@ -102,6 +102,13 @@ class FVTerm : public FTerm
fully_covered fully_covered
}; };
enum terminal_update
{
stop_refresh,
continue_refresh,
start_refresh
};
// Constructor // Constructor
explicit FVTerm (bool, bool = false); explicit FVTerm (bool, bool = false);
@ -220,7 +227,7 @@ class FVTerm : public FTerm
static void resizeVTerm (const FRect&); static void resizeVTerm (const FRect&);
static void resizeVTerm (int, int); static void resizeVTerm (int, int);
static void putVTerm(); static void putVTerm();
static void updateTerminal (bool); static void updateTerminal (terminal_update);
static void updateTerminal(); static void updateTerminal();
virtual void addPreprocessingHandler ( FVTerm* virtual void addPreprocessingHandler ( FVTerm*
, FPreprocessingHandler ); , FPreprocessingHandler );

View File

@ -1542,7 +1542,7 @@ int FApplication::processTimerEvent()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processCloseWidget() void FApplication::processCloseWidget()
{ {
updateTerminal(false); updateTerminal (FVTerm::stop_refresh);
if ( close_widget && ! close_widget->empty() ) if ( close_widget && ! close_widget->empty() )
{ {
@ -1558,7 +1558,7 @@ void FApplication::processCloseWidget()
close_widget->clear(); close_widget->clear();
} }
updateTerminal(true); updateTerminal (FVTerm::start_refresh);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -78,7 +78,7 @@ FMenu::~FMenu() // destructor
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); FApplication* fapp = static_cast<FApplication*>(getRootWidget());
if ( ! fapp->isQuit() ) if ( ! fapp->isQuit() )
switchToPrevWindow(); switchToPrevWindow(); // Switch to previous window
} }
@ -118,8 +118,9 @@ void FMenu::show()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::hide() void FMenu::hide()
{ {
if ( isVisible() ) if ( ! isVisible() )
{ return;
FWindow::hide(); FWindow::hide();
const FRect& t_geometry = getTermGeometryWithShadow(); const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry); restoreVTerm (t_geometry);
@ -137,7 +138,6 @@ void FMenu::hide()
} }
mouse_down = false; mouse_down = false;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2017 Markus Gans * * Copyright 2015-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -330,7 +330,7 @@ bool FMenuBar::selectNextItem()
if ( next == *iter ) if ( next == *iter )
return false; return false;
updateTerminal(false); updateTerminal (FVTerm::stop_refresh);
unselectItem(); unselectItem();
next->setSelected(); next->setSelected();
setSelectedItem(next); setSelectedItem(next);
@ -354,7 +354,7 @@ bool FMenuBar::selectNextItem()
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
redraw(); redraw();
updateTerminal(true); updateTerminal (FVTerm::start_refresh);
break; break;
} }
@ -397,7 +397,7 @@ bool FMenuBar::selectPrevItem()
if ( prev == *iter ) if ( prev == *iter )
return false; return false;
updateTerminal(false); updateTerminal (FVTerm::stop_refresh);
unselectItem(); unselectItem();
prev->setSelected(); prev->setSelected();
prev->setFocus(); prev->setFocus();
@ -421,7 +421,7 @@ bool FMenuBar::selectPrevItem()
setSelectedItem(prev); setSelectedItem(prev);
redraw(); redraw();
updateTerminal(true); updateTerminal (FVTerm::stop_refresh);
break; break;
} }
} }

View File

@ -230,11 +230,20 @@ void FVTerm::putVTerm()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateTerminal (bool on) void FVTerm::updateTerminal (terminal_update refresh_state)
{ {
stop_terminal_updates = bool(! on); switch ( refresh_state )
{
case stop_refresh:
stop_terminal_updates = true;
break;
if ( on ) case continue_refresh:
case start_refresh:
stop_terminal_updates = false;
}
if ( refresh_state == start_refresh )
updateTerminal(); updateTerminal();
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2017 Markus Gans * * Copyright 2015-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -719,6 +719,11 @@ bool FWindow::zoomWindow()
void FWindow::switchToPrevWindow() void FWindow::switchToPrevWindow()
{ {
// switch to previous window // switch to previous window
// Disable terminal updates to avoid flickering
// when redrawing the focused widget
updateTerminal (FVTerm::stop_refresh);
bool is_activated = activatePrevWindow(); bool is_activated = activatePrevWindow();
FWindow* active_window = getActiveWindow(); FWindow* active_window = getActiveWindow();
@ -765,6 +770,9 @@ void FWindow::switchToPrevWindow()
focus_widget->redraw(); focus_widget->redraw();
} }
} }
// Enable terminal updates again
updateTerminal (FVTerm::continue_refresh);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------