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>
* Refactoring FSwitch::drawCheckButton
* Refactoring FWidget::redraw

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -330,7 +330,7 @@ bool FMenuBar::selectNextItem()
if ( next == *iter )
return false;
updateTerminal(false);
updateTerminal (FVTerm::stop_refresh);
unselectItem();
next->setSelected();
setSelectedItem(next);
@ -354,7 +354,7 @@ bool FMenuBar::selectNextItem()
getStatusBar()->drawMessage();
redraw();
updateTerminal(true);
updateTerminal (FVTerm::start_refresh);
break;
}
@ -397,7 +397,7 @@ bool FMenuBar::selectPrevItem()
if ( prev == *iter )
return false;
updateTerminal(false);
updateTerminal (FVTerm::stop_refresh);
unselectItem();
prev->setSelected();
prev->setFocus();
@ -421,7 +421,7 @@ bool FMenuBar::selectPrevItem()
setSelectedItem(prev);
redraw();
updateTerminal(true);
updateTerminal (FVTerm::stop_refresh);
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();
}

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -719,6 +719,11 @@ bool FWindow::zoomWindow()
void FWindow::switchToPrevWindow()
{
// switch to previous window
// Disable terminal updates to avoid flickering
// when redrawing the focused widget
updateTerminal (FVTerm::stop_refresh);
bool is_activated = activatePrevWindow();
FWindow* active_window = getActiveWindow();
@ -765,6 +770,9 @@ void FWindow::switchToPrevWindow()
focus_widget->redraw();
}
}
// Enable terminal updates again
updateTerminal (FVTerm::continue_refresh);
}
//----------------------------------------------------------------------