diff --git a/ChangeLog b/ChangeLog index 197dde74..438413f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2021-03-30 Markus Gans + * Stops terminal refresh during dialog resizing until all + child widgets have been redrawn + 2021-03-28 Markus Gans * Widget now have the virtual method initLayout() to set the widget layouts automatically before the first drawing diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 100f0c8e..77fcdf9d 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -324,6 +324,9 @@ inline void Brushes::setBackground (FColor color) class MouseDraw final : public finalcut::FDialog { public: + // Using-declaration + using FWidget::setGeometry; + // Constructor explicit MouseDraw (finalcut::FWidget* = nullptr); diff --git a/examples/treeview.cpp b/examples/treeview.cpp index 102d6b8d..01234f8f 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -195,7 +195,7 @@ struct Treeview::TreeItem { return &name; } const char* const* end() const - { return reinterpret_cast(&child_element); } + { return &density + 1; } // Data members const char* name; diff --git a/src/fapplication.cpp b/src/fapplication.cpp index b3929edd..af919e92 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2013-2020 Markus Gans * +* Copyright 2013-2021 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -168,7 +168,7 @@ void FApplication::setLog (const FLogPtr& log) //---------------------------------------------------------------------- bool FApplication::isQuit() { - return ( internal::var::app_object ) ? quit_now : true; + return internal::var::app_object ? quit_now : true; } //---------------------------------------------------------------------- diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 02444057..3b58f39d 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -359,6 +359,7 @@ void FDialog::setSize (const FSize& size, bool adjust) const auto d_width = std::size_t(dw); const auto d_height = std::size_t(dh); + setTerminalUpdates (FVTerm::TerminalUpdate::Stop); // restoring the non-covered terminal areas if ( dw > 0 ) @@ -377,6 +378,8 @@ void FDialog::setSize (const FSize& size, bool adjust) // set the cursor to the focus widget setCursorToFocusWidget(); + + setTerminalUpdates (FVTerm::TerminalUpdate::Start); } //---------------------------------------------------------------------- diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index ac8ab0af..efbea2f3 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -282,7 +282,7 @@ inline FKey FKeyboard::getTermcapKey() for (auto&& entry : *key_map) { const char* kstr = entry.string; - const std::size_t len = ( kstr ) ? std::strlen(kstr) : 0; + const std::size_t len = kstr ? std::strlen(kstr) : 0; if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index c46effad..232488c6 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2014-2020 Markus Gans * +* Copyright 2014-2021 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -996,7 +996,7 @@ inline void FListBox::setLineAttributes ( int y { setColor ( wc->current_element_focus_fg , wc->current_element_focus_bg ); - const int b = ( lineHasBrackets ) ? 1: 0; + const int b = lineHasBrackets ? 1 : 0; if ( inc_len > 0 ) // incremental search { diff --git a/src/flistview.cpp b/src/flistview.cpp index 9ccc0fc5..5a2a6056 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1618,7 +1618,7 @@ void FListView::drawList() const bool is_current_line( iter == current_iter ); const auto& item = static_cast(*iter); const int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0; - const int checkbox_offset = ( item->isCheckable() ) ? 1 : 0; + const int checkbox_offset = item->isCheckable() ? 1 : 0; path_end = getListEnd(item); print() << FPoint{2, 2 + int(y)}; diff --git a/src/fmenu.cpp b/src/fmenu.cpp index ef5d4424..d91b682d 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -373,7 +373,7 @@ bool FMenu::isSubMenu() const bool FMenu::isDialogMenu() const { const auto& super = getSuperMenu(); - return ( super ) ? super->isDialogWidget() : false; + return super ? super->isDialogWidget() : false; } //---------------------------------------------------------------------- @@ -1350,7 +1350,7 @@ inline void FMenu::drawMenuText (MenuText& data) //---------------------------------------------------------------------- inline void FMenu::drawSubMenuIndicator (std::size_t& startpos) { - const std::size_t c = ( has_checkable_items ) ? 1 : 0; + const std::size_t c = has_checkable_items ? 1 : 0; const std::size_t len = max_item_width - (startpos + c + 3); if ( len > 0 ) @@ -1367,7 +1367,7 @@ inline void FMenu::drawSubMenuIndicator (std::size_t& startpos) inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key) { const FString accel_name {FTerm::getKeyName(accel_key)}; - const std::size_t c = ( has_checkable_items ) ? 1 : 0; + const std::size_t c = has_checkable_items ? 1 : 0; const std::size_t accel_len = accel_name.getLength(); const std::size_t plain_text_length = startpos + accel_len + c + 2; @@ -1384,7 +1384,7 @@ inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key) //---------------------------------------------------------------------- inline void FMenu::drawTrailingSpaces (std::size_t startpos) { - const std::size_t c = ( has_checkable_items ) ? 1 : 0; + const std::size_t c = has_checkable_items ? 1 : 0; // Print trailing blank space for (std::size_t i = startpos + c; i < max_item_width - 1; i++) diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 6e47dd59..57180975 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -451,13 +451,13 @@ void FMenuItem::onFocusOut (FFocusEvent*) //---------------------------------------------------------------------- bool FMenuItem::isDialog (const FWidget* w) const { - return ( w ) ? w->isDialogWidget() : false; + return w ? w->isDialogWidget() : false; } //---------------------------------------------------------------------- bool FMenuItem::isMenuBar (const FWidget* w) const { - return ( w ) ? w->isInstanceOf("FMenuBar") : false; + return w ? w->isInstanceOf("FMenuBar") : false; } //---------------------------------------------------------------------- @@ -580,7 +580,7 @@ void FMenuItem::updateSuperMenuDimensions() } //---------------------------------------------------------------------- -void FMenuItem::updateMenubarDimensions() +void FMenuItem::updateMenubarDimensions() const { FWidget* parent = getParentWidget(); diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index 718ba2da..e7f7e172 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -403,7 +403,7 @@ void FMessageBox::adjustButtons() std::size_t max_width; const auto& root_widget = getRootWidget(); setWidth(btn_width + 5); - max_width = ( root_widget ) ? root_widget->getClientWidth() : 80; + max_width = root_widget ? root_widget->getClientWidth() : 80; setX (int((max_width - getWidth()) / 2)); } diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 63fd37e1..f131ff95 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -914,7 +914,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time if ( ! move_xy.empty() ) { - std::strncpy ( reinterpret_cast(move_buf) + std::strncpy ( static_cast(move_buf) , move_xy.data(), BUF_SIZE - 1 ); move_buf[BUF_SIZE - 1] = '\0'; move_time = F_cursor_address.duration; diff --git a/src/fstring.cpp b/src/fstring.cpp index df5509b8..b460d2ae 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -159,10 +159,10 @@ FString::FString (const char c) FString::~FString() // destructor { if ( string ) - delete[](string); + delete[] string; if ( c_string ) - delete[](c_string); + delete[] c_string; } @@ -182,10 +182,10 @@ FString& FString::operator = (FString&& s) noexcept if ( &s != this ) { if ( string ) - delete[](string); + delete[] string; if ( c_string ) - delete[](c_string); + delete[] c_string; string = s.string; length = s.length; @@ -348,7 +348,7 @@ const FString& FString::operator () () const FString FString::clear() { if ( string ) - delete[](string); + delete[] string; length = 0; bufsize = 0; @@ -1231,7 +1231,7 @@ void FString::_assign (const wchar_t s[]) if ( ! string || new_length > capacity() ) { if ( string ) - delete[](string); + delete[] string; bufsize = FWDBUFFER + new_length + 1; @@ -1258,7 +1258,7 @@ void FString::_insert (std::size_t len, const wchar_t s[]) return; if ( string ) - delete[](string); + delete[] string; length = len; bufsize = FWDBUFFER + length + 1; @@ -1312,7 +1312,7 @@ void FString::_insert ( std::size_t pos try { - sptr = new wchar_t[bufsize]; // generate new string + sptr = new wchar_t[bufsize]; // generate new string } catch (const std::bad_alloc&) { @@ -1332,7 +1332,7 @@ void FString::_insert ( std::size_t pos sptr[y++] = string[x]; length += len; - delete[](string); // delete old string + delete[] string; // delete old string string = sptr; } } @@ -1356,7 +1356,7 @@ void FString::_remove (std::size_t pos, std::size_t len) try { - sptr = new wchar_t[bufsize]; // generate new string + sptr = new wchar_t[bufsize]; // generate new string } catch (const std::bad_alloc&) { @@ -1367,13 +1367,13 @@ void FString::_remove (std::size_t pos, std::size_t len) std::size_t x{}; std::size_t y{}; - for (x = 0; x < pos; x++) // left side + for (x = 0; x < pos; x++) // left side sptr[y++] = string[x]; for (x = pos + len; x < length + 1; x++) // right side + '\0' sptr[y++] = string[x]; - delete[](string); // delete old string + delete[] string; // delete old string string = sptr; length -= len; } @@ -1425,7 +1425,7 @@ inline const char* FString::_to_cstring (const wchar_t s[]) const if ( mblength == static_cast(-1) && errno != EILSEQ ) { - delete[](c_string); + delete[] c_string; c_string = nullptr; return ""; } @@ -1503,7 +1503,7 @@ inline const wchar_t* FString::_extractToken ( wchar_t* rest[] , const wchar_t s[] , const wchar_t delim[] ) const { - wchar_t* token = ( s ) ? const_cast(s) : *rest; + wchar_t* token = s ? const_cast(s) : *rest; if ( ! token ) return nullptr; diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index cd4c1145..335e2bd8 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -133,49 +133,49 @@ FTermcap::Status FTermcap::paddingPrint ( const std::string& string auto iter = string.begin(); using iter_type = decltype(iter); - auto read_digits = [] (iter_type& iter, int& number) + auto read_digits = [] (iter_type& it, int& number) { - while ( std::isdigit(int(*iter)) && number < 1000 ) + while ( std::isdigit(int(*it)) && number < 1000 ) { - number = number * 10 + (*iter - '0'); - ++iter; + number = number * 10 + (*it - '0'); + ++it; } number *= 10; }; - auto decimal_point = [] (iter_type& iter, int& number) + auto decimal_point = [] (iter_type& it, int& number) { - if ( *iter == '.' ) + if ( *it == '.' ) { - ++iter; + ++it; - if ( std::isdigit(int(*iter)) ) + if ( std::isdigit(int(*it)) ) { - number += (*iter - '0'); // Position after decimal point - ++iter; + number += (*it - '0'); // Position after decimal point + ++it; } - while ( std::isdigit(int(*iter)) ) - ++iter; + while ( std::isdigit(int(*it)) ) + ++it; } }; - auto asterisk_slash = [&affcnt, &has_delay] (iter_type& iter, int& number) + auto asterisk_slash = [&affcnt, &has_delay] (iter_type& it, int& number) { - while ( *iter == '*' || *iter == '/' ) + while ( *it == '*' || *it == '/' ) { - if ( *iter == '*' ) + if ( *it == '*' ) { // Padding is proportional to the number of affected lines (suffix '*') number *= affcnt; - ++iter; + ++it; } else { // Padding is mandatory (suffix '/') has_delay = true; - ++iter; + ++it; } } }; @@ -444,7 +444,7 @@ std::string FTermcap::encodeParams ( const std::string& cap auto str = ::tparm ( C_STR(cap.data()), params[0], params[1] , params[2], params[3], params[4], params[5] , params[6], params[7], params[8] ); - return ( str ) ? str : std::string(); + return str ? str : std::string(); } diff --git a/src/ftooltip.cpp b/src/ftooltip.cpp index 2f5f0759..fb48762d 100644 --- a/src/ftooltip.cpp +++ b/src/ftooltip.cpp @@ -124,8 +124,8 @@ void FToolTip::init() void FToolTip::draw() { bool border = hasBorder(); - int y{( border ) ? 2 : 1}; - int x{( border ) ? 3 : 2}; + int y{border ? 2 : 1}; + int x{border ? 3 : 2}; setColor(); clearArea(); @@ -160,8 +160,8 @@ void FToolTip::calculateDimensions() int x{}; int y{}; bool border = hasBorder(); - const std::size_t h = ( border ) ? text_num_lines + 2 : text_num_lines; - const std::size_t w = ( border ) ? max_line_width + 4 : max_line_width + 2; + const std::size_t h = border ? text_num_lines + 2 : text_num_lines; + const std::size_t w = border ? max_line_width + 4 : max_line_width + 2; const auto& r = getRootWidget(); if ( r ) diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 743472ee..63f59069 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -233,7 +233,7 @@ void FVTerm::setNonBlockingRead (bool enable) } #endif - uInt64 blocking_time = (enable) ? 5000 : 100000; // 5 or 100 ms + uInt64 blocking_time = enable ? 5000 : 100000; // 5 or 100 ms FKeyboard::setReadBlockingTime (blocking_time); } @@ -1925,7 +1925,7 @@ void FVTerm::init_combined_character() } //---------------------------------------------------------------------- -void FVTerm::finish() +void FVTerm::finish() const { // Show the input cursor showCursor(); @@ -2907,7 +2907,7 @@ inline void FVTerm::flushTimeAdjustment() const } else { - uInt64 usec = diff.tv_usec; + auto usec = uInt64(diff.tv_usec); if ( usec < MIN_FLUSH_WAIT ) usec = MIN_FLUSH_WAIT; diff --git a/src/include/final/fmenuitem.h b/src/include/final/fmenuitem.h index eabd9b77..a69d08a4 100644 --- a/src/include/final/fmenuitem.h +++ b/src/include/final/fmenuitem.h @@ -159,7 +159,7 @@ class FMenuItem : public FWidget void init(); void calculateTextDimensions(); void updateSuperMenuDimensions(); - void updateMenubarDimensions(); + void updateMenubarDimensions() const; void processEnable() const; void processDisable() const; void processActivate() const; diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 1f8ac306..e802b6ab 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -380,7 +380,7 @@ class FVTerm void init(); static void init_characterLengths(); static void init_combined_character(); - void finish(); + void finish() const; static void putAreaLine (const FChar&, FChar&, std::size_t); static void putAreaCharacter ( const FPoint&, const FTermArea* , const FChar&, FChar& );