Generalize hide() method

This commit is contained in:
Markus Gans 2019-01-11 22:16:59 +01:00
parent 60e64be37b
commit 016f15c860
15 changed files with 68 additions and 224 deletions

View File

@ -1,3 +1,6 @@
2019-01-11 Markus Gans <guru.mail@muenster.de>
* Generalize hide() method
2019-01-09 Markus Gans <guru.mail@muenster.de>
* Improvement in widget focusing
* Better widget visibility handling with the methods hide() and show()

View File

@ -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());
}
//----------------------------------------------------------------------

View File

@ -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);
}
//----------------------------------------------------------------------

View File

@ -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());
}
//----------------------------------------------------------------------

View File

@ -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 )

View File

@ -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);

View File

@ -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();

View File

@ -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
}
//----------------------------------------------------------------------

View File

@ -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

View File

@ -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());
}
//----------------------------------------------------------------------

View File

@ -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());
}
//----------------------------------------------------------------------

View File

@ -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()
{

View File

@ -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&

View File

@ -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);

View File

@ -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];