diff --git a/ChangeLog b/ChangeLog index fe8c3f0d..f8a3ba4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-01-11 Markus Gans + * Generalize hide() method + 2019-01-09 Markus Gans * Improvement in widget focusing * Better widget visibility handling with the methods hide() and show() diff --git a/src/flabel.cpp b/src/flabel.cpp index 4092ab08..0221e21f 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-2019 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 * @@ -233,33 +233,8 @@ void FLabel::setText (const FString& txt) //---------------------------------------------------------------------- void FLabel::hide() { - FColor fg, bg; - std::size_t size; - auto parent_widget = getParentWidget(); - FWidget::hide(); - - if ( parent_widget ) - { - fg = parent_widget->getForegroundColor(); - bg = parent_widget->getBackgroundColor(); - } - else - { - fg = wc.dialog_fg; - bg = wc.dialog_bg; - } - - setColor (fg, bg); - size = getWidth(); - - if ( size == 0 ) - return; - - auto blank = createBlankArray(size + 1); - setPrintPos (1, 1); - print (blank); - destroyBlankArray (blank); + hideSize (getWidth(), getHeight()); } //---------------------------------------------------------------------- diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 7fc6c3bf..87ccb982 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -271,42 +271,12 @@ void FLineEdit::setLabelOrientation(const label_o o) //---------------------------------------------------------------------- void FLineEdit::hide() { - std::size_t s, size; - FColor fg, bg; - auto parent_widget = getParentWidget(); - - FWidget::hide(); - - if ( parent_widget ) - { - fg = parent_widget->getForegroundColor(); - bg = parent_widget->getBackgroundColor(); - } - else - { - fg = wc.dialog_fg; - bg = wc.dialog_bg; - } - - setColor (fg, bg); - s = hasShadow() ? 1 : 0; - size = getWidth() + s; - - if ( size == 0 ) - return; - - auto blank = createBlankArray(size + 1); - - for (std::size_t y = 0; y < getHeight() + s; y++) - { - setPrintPos (1, 1 + int(y)); - print (blank); - } - - destroyBlankArray(blank); - if ( label ) label->hide(); + + FWidget::hide(); + std::size_t s = hasShadow() ? 1 : 0; + hideSize (getWidth() + s, getHeight() + s); } //---------------------------------------------------------------------- diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 69fb1d5b..23627d0b 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -214,38 +214,8 @@ void FListBox::setText (const FString& txt) //---------------------------------------------------------------------- void FListBox::hide() { - std::size_t n, size; - FColor fg, bg; - auto parent_widget = getParentWidget(); FWidget::hide(); - - if ( parent_widget ) - { - fg = parent_widget->getForegroundColor(); - bg = parent_widget->getBackgroundColor(); - } - else - { - fg = wc.dialog_fg; - bg = wc.dialog_bg; - } - - setColor (fg, bg); - n = isNewFont() ? 1 : 0; - size = getWidth() + n; - - if ( size == 0 ) - return; - - auto blank = createBlankArray(size + 1); - - for (int y = 0; y < int(getHeight()); y++) - { - setPrintPos (1, 1 + y); - print (blank); - } - - destroyBlankArray (blank); + hideSize (getWidth(), getHeight()); } //---------------------------------------------------------------------- diff --git a/src/flistview.cpp b/src/flistview.cpp index 425601e9..f0d58cfa 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -752,6 +752,13 @@ int FListView::addColumn (const FString& label, int width) return int(std::distance(header.begin(), header.end())); } +//---------------------------------------------------------------------- +void FListView::hide() +{ + FWidget::hide(); + hideSize (getWidth(), getHeight()); +} + //---------------------------------------------------------------------- FObject::FObjectIterator FListView::insert ( FListViewItem* item , FObjectIterator parent_iter ) diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 899d6b88..0d398bd4 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -437,7 +437,6 @@ void FMenu::init(FWidget* parent) setTransparentShadow(); setMenuWidget(); hide(); - //unsetVisible(); setForegroundColor (wc.menu_active_fg); setBackgroundColor (wc.menu_active_bg); @@ -586,7 +585,6 @@ void FMenu::openSubMenu (FMenu* sub_menu, bool select) sub_menu->getSelectedItem()->setFocus(); } - //sub_menu->setVisible(); sub_menu->show(); opened_sub_menu = sub_menu; raiseWindow (sub_menu); diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 5d3d7d36..aba452e2 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -273,7 +273,6 @@ void FMenuItem::openMenu() createDialogList (dd_menu); setOpenMenu(dd_menu); - //dd_menu->setVisible(); dd_menu->show(); dd_menu->raiseWindow(); dd_menu->redraw(); diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index f3ebad85..ab9d9f9f 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -98,40 +98,11 @@ bool FProgressbar::setShadow (bool enable) //---------------------------------------------------------------------- void FProgressbar::hide() { - FColor fg, bg; - auto parent_widget = getParentWidget(); - FWidget::hide(); - - if ( parent_widget ) - { - fg = parent_widget->getForegroundColor(); - bg = parent_widget->getBackgroundColor(); - } - else - { - fg = wc.dialog_fg; - bg = wc.dialog_bg; - } - - setColor (fg, bg); std::size_t s = hasShadow() ? 1 : 0; - auto size = getWidth() + s; - - if ( size == 0 ) - return; - - auto blank = createBlankArray(size + 1); - - for (std::size_t y = 0; y < getHeight() + s; y++) - { - setPrintPos (1, 1 + int(y)); - print (blank); - } - - destroyBlankArray (blank); + hideSize (getWidth() + s, getHeight() + s); setPrintPos (int(getWidth()) - 4, 0); - print (" "); // hide percentage + print (" "); // hide percentage } //---------------------------------------------------------------------- diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index a1412a10..5d5bc56f 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -368,7 +368,7 @@ void FScrollView::scrollTo (int x, int y) if ( update_scrollbar ) { hbar->setValue (xoffset); - drawHBar(); + hbar->drawBar(); } } @@ -381,7 +381,7 @@ void FScrollView::scrollTo (int x, int y) if ( update_scrollbar ) { vbar->setValue (yoffset); - drawVBar(); + vbar->drawBar(); } } @@ -422,8 +422,8 @@ void FScrollView::draw() setViewportPrint(); copy2area(); - redrawVBar(); - redrawHBar(); + vbar->redraw(); + hbar->redraw(); } //---------------------------------------------------------------------- @@ -981,36 +981,4 @@ void FScrollView::cb_HBarChange (FWidget*, FDataPtr) update_scrollbar = true; } -//---------------------------------------------------------------------- -inline void FScrollView::redrawHBar() -{ - child_print_area = nullptr; - hbar->redraw(); - child_print_area = viewport; -} - -//---------------------------------------------------------------------- -inline void FScrollView::redrawVBar() -{ - child_print_area = nullptr; - vbar->redraw(); - child_print_area = viewport; -} - -//---------------------------------------------------------------------- -inline void FScrollView::drawHBar() -{ - child_print_area = nullptr; - hbar->drawBar(); - child_print_area = viewport; -} - -//---------------------------------------------------------------------- -inline void FScrollView::drawVBar() -{ - child_print_area = nullptr; - vbar->drawBar(); - child_print_area = viewport; -} - } // namespace finalcut diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 89ba4e8f..09d4e936 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -157,7 +157,7 @@ void FTextView::scrollTo (int x, int y) if ( update_scrollbar ) { hbar->setValue (xoffset); - hbar->drawBar();; + hbar->drawBar(); } } @@ -186,38 +186,8 @@ void FTextView::scrollTo (int x, int y) //---------------------------------------------------------------------- void FTextView::hide() { - FColor fg, bg; - auto parent_widget = getParentWidget(); FWidget::hide(); - - if ( parent_widget ) - { - fg = parent_widget->getForegroundColor(); - bg = parent_widget->getBackgroundColor(); - } - else - { - fg = wc.dialog_fg; - bg = wc.dialog_bg; - } - - setColor (fg, bg); - std::size_t n = isNewFont() ? 1 : 0; - auto size = getWidth() + n; - - if ( size == 0 ) - return; - - auto blank = createBlankArray(size + 1); - - for (std::size_t y = 0; y < getHeight(); y++) - { - setPrintPos (1, 1 + int(y)); - print (blank); - } - - destroyBlankArray (blank); - flush_out(); + hideSize (getWidth(), getHeight()); } //---------------------------------------------------------------------- diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 6a9246b8..cba850a6 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-2019 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 * @@ -202,32 +202,8 @@ void FToggleButton::setText (const FString& txt) //---------------------------------------------------------------------- void FToggleButton::hide() { - std::size_t size; - FColor fg, bg; - auto parent_widget = getParentWidget(); FWidget::hide(); - - if ( parent_widget ) - { - fg = parent_widget->getForegroundColor(); - bg = parent_widget->getBackgroundColor(); - } - else - { - fg = wc.dialog_fg; - bg = wc.dialog_bg; - } - - setColor (fg, bg); - size = getWidth(); - - if ( size == 0 ) - return; - - auto blank = createBlankArray(size + 1); - setPrintPos (1, 1); - print (blank); - destroyBlankArray (blank); + hideSize (getWidth(), getHeight()); } //---------------------------------------------------------------------- diff --git a/src/fwidget.cpp b/src/fwidget.cpp index cf29470a..97bd279c 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1613,6 +1613,42 @@ void FWidget::adjustSizeGlobal() } } +//---------------------------------------------------------------------- +void FWidget::hideSize (std::size_t width, std::size_t height) +{ + if ( width == 0 || height == 0 ) + return; + + FColor fg, bg; + auto parent_widget = getParentWidget(); + + if ( parent_widget ) + { + fg = parent_widget->getForegroundColor(); + bg = parent_widget->getBackgroundColor(); + } + else + { + fg = wc.dialog_fg; + bg = wc.dialog_bg; + } + + setColor (fg, bg); + auto blank = createBlankArray(width); + + if ( blank == 0 ) + return; + + for (int y = 0; y < int(height); y++) + { + setPrintPos (1, 1 + y); + print (blank); + } + + destroyBlankArray (blank); + flush_out(); +} + //---------------------------------------------------------------------- bool FWidget::focusNextChild() { diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 758fdfde..0f34ab58 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -315,6 +315,7 @@ class FListView : public FWidget // Methods virtual int addColumn (const FString&, int = USE_MAX_SIZE); + virtual void hide() override; FObjectIterator insert (FListViewItem*); FObjectIterator insert (FListViewItem*, FObjectIterator); FObjectIterator insert ( const FStringList& diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index 85ba7b90..4f26c674 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -171,10 +171,6 @@ class FScrollView : public FWidget void setHorizontalScrollBarVisibility(); void setVerticalScrollBarVisibility(); void setViewportCursor(); - void redrawHBar(); - void redrawVBar(); - void drawHBar(); - void drawVBar(); // Callback methods void cb_VBarChange (FWidget*, FDataPtr); diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index 94660118..65104014 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -380,6 +380,7 @@ class FWidget : public FVTerm, public FObject // Methods virtual void adjustSize(); void adjustSizeGlobal(); + void hideSize (std::size_t, std::size_t); virtual bool focusNextChild(); // Change child... virtual bool focusPrevChild(); // ...focus @@ -1019,6 +1020,9 @@ inline char* createBlankArray (std::size_t size) { char* blank; + if ( size == 0 ) + return 0; + try { blank = new char[size + 1];