Bugfix in FDialog::setSize()
This commit is contained in:
parent
44d6d8cdb9
commit
d10e2888ac
|
@ -1,3 +1,7 @@
|
|||
2020-09-22 Markus Gans <guru.mail@muenster.de>
|
||||
* Bugfix in FDialog::setSize(): Automatic size adjustment and
|
||||
simultaneous widget movement are now possible.
|
||||
|
||||
2020-09-18 Markus Gans <guru.mail@muenster.de>
|
||||
* The generic data type FDataPtr is now deprecated and was
|
||||
completely replaced by the template class FData
|
||||
|
|
|
@ -1236,19 +1236,12 @@ class dialogWidget : public FDialog
|
|||
FDialog::adjustSize();
|
||||
// Centers the dialog in the terminal
|
||||
centerDialog();
|
||||
}
|
||||
|
||||
void setSize (const FSize& size, bool) override
|
||||
{
|
||||
// Calling super class methods setSize() + adjustSize()
|
||||
FDialog::setSize (size, false);
|
||||
FDialog::adjustSize();
|
||||
// Adjust widgets before drawing
|
||||
adjustWidgets();
|
||||
}
|
||||
|
||||
void draw() override
|
||||
{
|
||||
adjustWidgets(); // Adjust widgets before drawing
|
||||
|
||||
// Calling super class method draw()
|
||||
FDialog::draw();
|
||||
|
||||
|
|
|
@ -312,6 +312,29 @@ void FApplication::setDarkTheme()
|
|||
setColorTheme<default16ColorDarkTheme>();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setLogFile (const FString& filename)
|
||||
{
|
||||
auto& log_stream = getStartOptions().logfile_stream;
|
||||
log_stream.open(filename, std::ofstream::out);
|
||||
|
||||
if ( log_stream.is_open() )
|
||||
{
|
||||
// Get the global logger object
|
||||
FLog& log = *FApplication::getLog();
|
||||
log.setOutputStream(log_stream);
|
||||
log.enableTimestamp();
|
||||
log.setLineEnding (finalcut::FLog::LF);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ftermdata = FTerm::getFTermData();
|
||||
ftermdata->setExitMessage ( "Could not open log file \""
|
||||
+ filename + "\"" );
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setKeyboardWidget (FWidget* widget)
|
||||
{
|
||||
|
@ -416,29 +439,6 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setLogFile (const FString& filename)
|
||||
{
|
||||
auto& log_stream = getStartOptions().logfile_stream;
|
||||
log_stream.open(filename, std::ofstream::out);
|
||||
|
||||
if ( log_stream.is_open() )
|
||||
{
|
||||
// Get the global logger object
|
||||
FLog& log = *FApplication::getLog();
|
||||
log.setOutputStream(log_stream);
|
||||
log.enableTimestamp();
|
||||
log.setLineEnding (finalcut::FLog::LF);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ftermdata = FTerm::getFTermData();
|
||||
ftermdata->setExitMessage ( "Could not open log file \""
|
||||
+ filename + "\"" );
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::cmd_options (const int& argc, char* argv[])
|
||||
{
|
||||
|
|
|
@ -323,7 +323,7 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
|||
const int dw = int(getWidth()) - int(size.getWidth());
|
||||
const int dh = int(getHeight()) - int(size.getHeight());
|
||||
const auto& shadow = getShadow();
|
||||
FWindow::setSize (size, adjust);
|
||||
FWindow::setSize (size, false);
|
||||
|
||||
// get adjust width and height
|
||||
const std::size_t w = getWidth() + shadow.getWidth();
|
||||
|
@ -346,6 +346,9 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
|||
if ( dh > 0 )
|
||||
restoreVTerm ({x, y + int(h), w + d_width, d_height}); // restore bottom
|
||||
|
||||
if ( adjust ) // Adjust the size after restoreVTerm(),
|
||||
adjustSize(); // because adjustSize() can also change x and y
|
||||
|
||||
redraw();
|
||||
|
||||
// handle overlaid windows
|
||||
|
@ -1069,13 +1072,13 @@ inline void FDialog::drawRestoreSizeButton()
|
|||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
print ('[');
|
||||
print (fc::BlackDownPointingTriangle); // ▼
|
||||
print (fc::BlackDiamondSuit); // ◆
|
||||
print (']');
|
||||
}
|
||||
else
|
||||
{
|
||||
print (' ');
|
||||
print (fc::BlackDownPointingTriangle); // ▼
|
||||
print (fc::BlackDiamondSuit); // ◆
|
||||
print (' ');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2015,7 +2015,7 @@ void FWidget::destroyColorTheme()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::removeQueuedEvent()
|
||||
void FWidget::removeQueuedEvent() const
|
||||
{
|
||||
auto app_object = FApplication::getApplicationObject();
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ class FApplication : public FWidget
|
|||
void initTerminal() override;
|
||||
static void setDefaultTheme();
|
||||
static void setDarkTheme();
|
||||
static void setLogFile (const FString&);
|
||||
static void setKeyboardWidget (FWidget*);
|
||||
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
|
||||
|
||||
|
@ -154,7 +155,6 @@ class FApplication : public FWidget
|
|||
// Methods
|
||||
void init();
|
||||
static void setTerminalEncoding (const FString&);
|
||||
static void setLogFile (const FString&);
|
||||
static void cmd_options (const int&, char*[]);
|
||||
static FStartOptions& getStartOptions();
|
||||
static void showParameterUsage();
|
||||
|
|
|
@ -452,7 +452,7 @@ class FWidget : public FVTerm, public FObject
|
|||
static bool isDefaultTheme();
|
||||
static void initColorTheme();
|
||||
void destroyColorTheme();
|
||||
void removeQueuedEvent();
|
||||
void removeQueuedEvent() const;
|
||||
void setStatusbarText (bool) const;
|
||||
|
||||
// Data members
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***********************************************************************
|
||||
* fdata-test.cpp - FCallback unit tests *
|
||||
* fdata-test.cpp - FData unit tests *
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
|
|
|
@ -394,6 +394,19 @@ void FObjectTest::addTest()
|
|||
CPPUNIT_ASSERT ( child->hasParent() );
|
||||
CPPUNIT_ASSERT ( child->getParent() == obj );
|
||||
|
||||
// Switch of the parent by a second addChild
|
||||
auto obj2 = new finalcut::FObject();
|
||||
obj2->addChild(child);
|
||||
CPPUNIT_ASSERT ( child->hasParent() );
|
||||
CPPUNIT_ASSERT ( ! obj->hasChildren() );
|
||||
CPPUNIT_ASSERT ( obj->numOfChildren() == 0 );
|
||||
CPPUNIT_ASSERT ( ! obj->isChild(child) );
|
||||
CPPUNIT_ASSERT ( child->getParent() != obj );
|
||||
CPPUNIT_ASSERT ( obj2->hasChildren() );
|
||||
CPPUNIT_ASSERT ( obj2->numOfChildren() == 1 );
|
||||
CPPUNIT_ASSERT ( obj2->isChild(child) );
|
||||
CPPUNIT_ASSERT ( child->getParent() == obj2 );
|
||||
|
||||
delete obj; // also deletes the child object
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue