Better widget visibility handling with the methods hide() and show()

This commit is contained in:
Markus Gans 2019-01-09 20:05:29 +01:00
parent 6a91738f48
commit 60e64be37b
19 changed files with 248 additions and 243 deletions

View File

@ -1,3 +1,7 @@
2019-01-09 Markus Gans <guru.mail@muenster.de>
* Improvement in widget focusing
* Better widget visibility handling with the methods hide() and show()
2019-01-05 Markus Gans <guru.mail@muenster.de>
* Use of initializer_list for FListBox, FListView and FTextView

View File

@ -651,7 +651,7 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, FDataPtr)
{
toggle_button->unsetChecked();
if ( toggle_button->isVisible() && toggle_button->isShown() )
if ( toggle_button->isShown() )
toggle_button->redraw();
}

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2012-2018 Markus Gans *
* Copyright 2012-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 *
@ -350,7 +350,7 @@ void FDialog::setSize (std::size_t w, std::size_t h, bool adjust)
// set the cursor to the focus widget
auto focus = FWidget::getFocusWidget();
if ( focus
&& focus->isVisible()
&& focus->isShown()
&& focus->hasVisibleCursor() )
{
FPoint cursor_pos = focus->getCursorPos();
@ -511,7 +511,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{
// Click on titlebar menu button
if ( ms.mouse_x < 4 && ms.mouse_y == 1
&& dialog_menu->isVisible() )
&& dialog_menu->isShown() )
leaveMenu(); // close menu
cancelMouseResize(); // Cancel resize
@ -561,7 +561,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
// Click on titlebar menu button
if ( ms.mouse_x < 4
&& ms.mouse_y == 1
&& dialog_menu->isVisible()
&& dialog_menu->isShown()
&& ! dialog_menu->hasSelectedItem() )
{
// Sets focus to the first item
@ -679,7 +679,7 @@ void FDialog::onAccel (FAccelEvent*)
//----------------------------------------------------------------------
void FDialog::onWindowActive (FEvent*)
{
if ( isVisible() && isShown() )
if ( isShown() )
drawTitleBar();
if ( ! FWidget::getFocusWidget() )
@ -687,7 +687,6 @@ void FDialog::onWindowActive (FEvent*)
auto win_focus = getWindowFocusWidget();
if ( win_focus
&& win_focus->isVisible()
&& win_focus->isShown() )
{
win_focus->setFocus();
@ -706,10 +705,10 @@ void FDialog::onWindowActive (FEvent*)
//----------------------------------------------------------------------
void FDialog::onWindowInactive (FEvent*)
{
if ( dialog_menu && ! dialog_menu->isVisible() )
if ( dialog_menu && ! dialog_menu->isShown() )
FWindow::setPreviousWindow(this);
if ( isVisible() && isEnabled() )
if ( isShown() && isEnabled() )
drawTitleBar();
if ( hasFocus() )
@ -719,7 +718,7 @@ void FDialog::onWindowInactive (FEvent*)
//----------------------------------------------------------------------
void FDialog::onWindowRaised (FEvent*)
{
if ( ! (isVisible() && isShown()) )
if ( ! (isShown() && isShown()) )
return;
putArea (getTermPos(), vwin);
@ -1016,7 +1015,7 @@ void FDialog::drawBarButton()
// Print the title button
setPrintPos (1, 1);
if ( dialog_menu && dialog_menu->isVisible() )
if ( dialog_menu && dialog_menu->isShown() )
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);
else
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
@ -1138,7 +1137,7 @@ void FDialog::drawTextBar()
if ( getMaxColor() < 16 )
setBold();
if ( isWindowActive() || (dialog_menu && dialog_menu->isVisible()) )
if ( isWindowActive() || (dialog_menu && dialog_menu->isShown()) )
setColor (wc.titlebar_active_fg, wc.titlebar_active_bg);
else
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
@ -1202,7 +1201,7 @@ void FDialog::setCursorToFocusWidget()
auto focus = FWidget::getFocusWidget();
if ( focus
&& focus->isVisible()
&& focus->isShown()
&& focus->hasVisibleCursor() )
{
FPoint cursor_pos = focus->getCursorPos();
@ -1238,7 +1237,7 @@ void FDialog::openMenu()
if ( ! dialog_menu )
return;
if ( dialog_menu->isVisible() )
if ( dialog_menu->isShown() )
{
leaveMenu();
drawTitleBar();
@ -1248,10 +1247,10 @@ void FDialog::openMenu()
setOpenMenu(dialog_menu);
dialog_menu->setPos (getX(), getY() + 1);
dialog_menu->setVisible();
drawTitleBar();
dialog_menu->show();
dialog_menu->raiseWindow();
dialog_menu->redraw();
drawTitleBar();
}
}
@ -1372,7 +1371,6 @@ inline void FDialog::passEventToSubMenu ( const mouseStates& ms
{
// Mouse event handover to the dialog menu
if ( ! ms.mouse_over_menu
|| ! dialog_menu->isVisible()
|| ! dialog_menu->isShown() )
return;

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 *
@ -118,9 +118,7 @@ void FListBox::setCurrentItem (std::size_t index)
yoffset = 0;
adjustSize();
vbar->setValue(yoffset);
if ( isVisible() )
redraw();
redraw();
}
//----------------------------------------------------------------------
@ -155,8 +153,8 @@ void FListBox::showInsideBrackets ( std::size_t index
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
hbar->setValue (xoffset);
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( ! hbar->isShown() )
hbar->show();
}
}
}
@ -289,7 +287,7 @@ void FListBox::remove (std::size_t item)
hbar->setMaximum (hmax);
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
if ( hbar->isVisible() && max_line_width < getWidth() - nf_offset - 3 )
if ( hbar->isShown() && isHorizontallyScrollable() )
hbar->hide();
int vmax = ( element_count > getHeight() - 2 )
@ -298,7 +296,7 @@ void FListBox::remove (std::size_t item)
vbar->setMaximum (vmax);
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
if ( vbar->isVisible() && element_count < getHeight() - 1 )
if ( vbar->isShown() && isVerticallyScrollable() )
vbar->hide();
if ( current >= item && current > 1 )
@ -490,12 +488,12 @@ void FListBox::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() == fc::RightButton )
multiSelection(current);
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -558,12 +556,12 @@ void FListBox::onMouseMove (FMouseEvent* ev)
multiSelectionUpTo(current);
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -637,12 +635,12 @@ void FListBox::onTimer (FTimerEvent*)
multiSelectionUpTo(current);
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -685,12 +683,12 @@ void FListBox::onWheel (FWheelEvent* ev)
processSelect();
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -770,15 +768,15 @@ void FListBox::adjustSize()
hbar->setWidth (width + nf_offset, false);
hbar->resize();
if ( element_count <= height )
vbar->hide();
if ( isHorizontallyScrollable() )
hbar->show();
else
vbar->setVisible();
if ( max_line_width < width - 1 )
hbar->hide();
if ( isVerticallyScrollable() )
vbar->show();
else
hbar->setVisible();
vbar->hide();
}
@ -792,20 +790,10 @@ inline FString& FListBox::getString (listBoxItems::iterator iter)
//----------------------------------------------------------------------
void FListBox::init()
{
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
try
{
vbar = std::make_shared<FScrollbar>(fc::vertical, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
}
catch (const std::bad_alloc& ex)
{
@ -813,7 +801,13 @@ void FListBox::init()
return;
}
setGeometry (1, 1, 5, 4, false); // initialize geometry values
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
vbar->addCallback
(
@ -827,6 +821,9 @@ void FListBox::init()
F_METHOD_CALLBACK (this, &FListBox::cb_HBarChange)
);
setGeometry (1, 1, 5, 4, false); // initialize geometry values
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
@ -850,7 +847,7 @@ void FListBox::draw()
else
drawBorder();
if ( isNewFont() && ! vbar->isVisible() )
if ( isNewFont() && ! vbar->isShown() )
{
setColor();
@ -866,12 +863,8 @@ void FListBox::draw()
if ( isMonochron() )
setReverse(false);
if ( vbar->isVisible() )
vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw();
vbar->redraw();
hbar->redraw();
drawList();
if ( flags.focus && getStatusBar() )
@ -1185,17 +1178,17 @@ inline void FListBox::unsetAttributes()
//----------------------------------------------------------------------
inline void FListBox::updateDrawing (bool draw_vbar, bool draw_hbar)
{
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && draw_vbar )
if ( draw_vbar )
vbar->drawBar();
hbar->setValue (xoffset);
if ( hbar->isVisible() && draw_hbar )
if ( draw_hbar )
hbar->drawBar();
updateTerminal();
@ -1222,8 +1215,10 @@ void FListBox::recalculateHorizontalBar (std::size_t len, bool has_brackets)
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( isHorizontallyScrollable() )
hbar->show();
else
hbar->hide();
}
}
@ -1237,8 +1232,10 @@ void FListBox::recalculateVerticalBar (std::size_t element_count)
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
vbar->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 )
vbar->setVisible();
if ( isVerticallyScrollable() )
vbar->show();
else
vbar->hide();
}
//----------------------------------------------------------------------
@ -1823,7 +1820,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
std::size_t len = iter->text.getLength();
recalculateHorizontalBar (len, hasBrackets(iter));
if ( hbar->isVisible() )
if ( hbar->isShown() )
hbar->redraw();
}
@ -1878,7 +1875,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
processSelect();
}
if ( isVisible() )
if ( isShown() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
@ -1886,7 +1883,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
{
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -1939,7 +1936,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
if ( xoffset_before != xoffset )
inc_search.clear();
if ( isVisible() )
if ( isShown() )
{
drawList();
updateTerminal();
@ -1951,7 +1948,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
if ( xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();

View File

@ -1018,13 +1018,12 @@ void FListView::onMouseDown (FMouseEvent* ev)
}
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1069,7 +1068,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
adjustSize();
if ( isVisible() )
if ( isShown() )
draw();
}
}
@ -1085,7 +1084,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
{
item->setChecked(! item->isChecked());
if ( isVisible() )
if ( isShown() )
draw();
}
}
@ -1121,13 +1120,12 @@ void FListView::onMouseMove (FMouseEvent* ev)
if ( new_pos < int(getCount()) )
setRelativePosition (mouse_y - 2);
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1171,7 +1169,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
adjustSize();
if ( isVisible() )
if ( isShown() )
draw();
}
@ -1208,13 +1206,12 @@ void FListView::onTimer (FTimerEvent*)
break;
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1248,13 +1245,12 @@ void FListView::onWheel (FWheelEvent* ev)
if ( position_before != current_iter.getPosition() )
processChanged();
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1350,15 +1346,15 @@ void FListView::adjustSize()
hbar->setWidth (width, false);
hbar->resize();
if ( element_count <= height )
vbar->hide();
if ( isHorizontallyScrollable() )
hbar->show();
else
vbar->setVisible();
if ( max_line_width <= width )
hbar->hide();
if ( isVerticallyScrollable() )
vbar->show();
else
hbar->setVisible();
vbar->hide();
}
@ -1366,24 +1362,10 @@ void FListView::adjustSize()
//----------------------------------------------------------------------
void FListView::init()
{
selflist.push_back(this);
root = selflist.begin();
null_iter = selflist.end();
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
try
{
vbar = std::make_shared<FScrollbar>(fc::vertical, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
}
catch (const std::bad_alloc& ex)
{
@ -1391,7 +1373,13 @@ void FListView::init()
return;
}
setGeometry (1, 1, 5, 4, false); // initialize geometry values
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
vbar->addCallback
(
@ -1405,6 +1393,12 @@ void FListView::init()
F_METHOD_CALLBACK (this, &FListView::cb_HBarChange)
);
selflist.push_back(this);
root = selflist.begin();
null_iter = selflist.end();
setGeometry (1, 1, 5, 4, false); // initialize geometry values
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
@ -1466,7 +1460,7 @@ void FListView::draw()
else
drawBorder();
if ( isNewFont() && ! vbar->isVisible() )
if ( isNewFont() && ! vbar->isShown() )
{
setColor();
@ -1482,12 +1476,8 @@ void FListView::draw()
if ( isMonochron() )
setReverse(false);
if ( vbar->isVisible() )
vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw();
vbar->redraw();
hbar->redraw();
drawList();
if ( flags.focus && getStatusBar() )
@ -1869,17 +1859,17 @@ void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter
//----------------------------------------------------------------------
void FListView::updateDrawing (bool draw_vbar, bool draw_hbar)
{
if ( isVisible() )
if ( isShown() )
draw();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() && draw_vbar )
if ( draw_vbar )
vbar->drawBar();
hbar->setValue (xoffset);
if ( hbar->isVisible() && draw_hbar )
if ( draw_hbar )
hbar->drawBar();
updateTerminal();
@ -1964,8 +1954,10 @@ void FListView::recalculateHorizontalBar (std::size_t len)
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset) - 4);
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( isHorizontallyScrollable() )
hbar->show();
else
hbar->hide();
}
}
@ -1979,8 +1971,10 @@ void FListView::recalculateVerticalBar (std::size_t element_count)
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
vbar->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 )
vbar->setVisible();
if ( isVerticallyScrollable() )
vbar->show();
else
vbar->hide();
}
//----------------------------------------------------------------------
@ -2014,7 +2008,7 @@ void FListView::mouseHeaderClicked()
sort();
if ( isVisible() )
if ( isShown() )
updateDrawing (true, false);
break;
@ -2533,7 +2527,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
break;
}
if ( isVisible() )
if ( isShown() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
@ -2541,8 +2535,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
{
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -2593,7 +2586,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
break;
}
if ( isVisible() )
if ( isShown() )
{
drawHeadlines();
drawList();
@ -2606,7 +2599,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
if ( xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();

View File

@ -437,6 +437,7 @@ void FMenu::init(FWidget* parent)
setTransparentShadow();
setMenuWidget();
hide();
//unsetVisible();
setForegroundColor (wc.menu_active_fg);
setBackgroundColor (wc.menu_active_bg);
@ -574,7 +575,7 @@ void FMenu::openSubMenu (FMenu* sub_menu, bool select)
if ( ! sub_menu )
return;
if ( sub_menu->isVisible() )
if ( sub_menu->isShown() )
return;
if ( select )
@ -585,7 +586,7 @@ void FMenu::openSubMenu (FMenu* sub_menu, bool select)
sub_menu->getSelectedItem()->setFocus();
}
sub_menu->setVisible();
//sub_menu->setVisible();
sub_menu->show();
opened_sub_menu = sub_menu;
raiseWindow (sub_menu);
@ -737,7 +738,7 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed)
if ( m_item->hasMenu() )
{
auto sub_menu = m_item->getMenu();
if ( ! sub_menu->isVisible() )
if ( ! sub_menu->isShown() )
shown_sub_menu = sub_menu;
}
}
@ -766,7 +767,7 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
if ( (*iter)->hasMenu() )
{
auto sub_menu = (*iter)->getMenu();
if ( ! sub_menu->isVisible() )
if ( ! sub_menu->isShown() )
openSubMenu (sub_menu, SELECT_ITEM);
else if ( opened_sub_menu )
{
@ -851,7 +852,7 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms)
{
auto sub_menu = m_item->getMenu();
if ( ! sub_menu->isVisible() )
if ( ! sub_menu->isShown() )
shown_sub_menu = sub_menu;
}
else if ( opened_sub_menu )
@ -1045,7 +1046,7 @@ bool FMenu::selectNextItem()
}
while ( ! next->isEnabled()
|| ! next->acceptFocus()
|| ! next->isVisible()
|| ! next->isShown()
|| next->isSeparator() );
if ( next == *iter )
@ -1095,7 +1096,7 @@ bool FMenu::selectPrevItem()
}
while ( ! prev->isEnabled()
|| ! prev->acceptFocus()
|| ! prev->isVisible()
|| ! prev->isShown()
|| prev->isSeparator() );
if ( prev == *iter )
@ -1575,7 +1576,7 @@ inline void FMenu::keyRight (FKeyEvent* ev)
{
auto sub_menu = getSelectedItem()->getMenu();
if ( ! sub_menu->isVisible() )
if ( ! sub_menu->isShown() )
openSubMenu (sub_menu, SELECT_ITEM);
else
keypressMenuBar(ev); // select next menu

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2018 Markus Gans *
* Copyright 2015-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 *
@ -301,7 +301,7 @@ bool FMenuBar::selectNextItem()
next = static_cast<FMenuItem*>(*next_element);
} while ( ! next->isEnabled()
|| ! next->acceptFocus()
|| ! next->isVisible()
|| ! next->isShown()
|| next->isSeparator() );
if ( next == *iter )
@ -365,7 +365,7 @@ bool FMenuBar::selectPrevItem()
}
while ( ! prev->isEnabled()
|| ! prev->acceptFocus()
|| ! prev->isVisible()
|| ! prev->isShown()
|| prev->isSeparator() );
if ( prev == *iter )
@ -737,6 +737,7 @@ void FMenuBar::selectMenuItem (FMenuItem* item)
return;
auto focused_widget = getFocusWidget();
unselectItem();
item->setSelected();
item->setFocus();

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2018 Markus Gans *
* Copyright 2015-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 *
@ -258,7 +258,7 @@ void FMenuItem::openMenu()
auto dd_menu = getMenu(); // Drop-down menu
if ( dd_menu->isVisible() )
if ( dd_menu->isShown() )
return;
auto openmenu = static_cast<FMenu*>(getOpenMenu());
@ -273,7 +273,7 @@ void FMenuItem::openMenu()
createDialogList (dd_menu);
setOpenMenu(dd_menu);
dd_menu->setVisible();
//dd_menu->setVisible();
dd_menu->show();
dd_menu->raiseWindow();
dd_menu->redraw();

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 *
@ -56,7 +56,7 @@ void FProgressbar::setPercentage (std::size_t percentage_value)
else
percentage = percentage_value;
if ( isVisible() )
if ( isShown() )
{
drawPercentage();
drawBar();
@ -139,7 +139,7 @@ void FProgressbar::reset()
{
percentage = NOT_SET;
if ( isVisible() )
if ( isShown() )
{
drawPercentage();
drawBar();

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2012-2018 Markus Gans *
* Copyright 2012-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 *
@ -188,7 +188,8 @@ void FScrollbar::resize()
//----------------------------------------------------------------------
void FScrollbar::redraw()
{
draw();
if ( isShown() )
draw();
}
//----------------------------------------------------------------------
@ -348,6 +349,9 @@ void FScrollbar::drawHorizontalBar()
//----------------------------------------------------------------------
void FScrollbar::drawBar()
{
if ( ! isShown() )
return;
if ( slider_pos == current_slider_pos || length < 3 )
return;

View File

@ -4,7 +4,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2017-2018 Markus Gans *
* Copyright 2017-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 *
@ -356,7 +356,7 @@ void FScrollView::scrollTo (int x, int y)
changeX = bool(xoffset_before != xoffset);
changeY = bool(yoffset_before != yoffset);
if ( ! isVisible() || ! viewport || ! (changeX || changeY) )
if ( ! isShown() || ! viewport || ! (changeX || changeY) )
return;
if ( changeX )
@ -719,9 +719,6 @@ inline FPoint FScrollView::getViewportCursorPos()
//----------------------------------------------------------------------
void FScrollView::init (FWidget* parent)
{
int xoffset_end;
int yoffset_end;
assert ( parent != 0 );
assert ( ! parent->isInstanceOf("FScrollView") );
@ -730,14 +727,13 @@ void FScrollView::init (FWidget* parent)
init_scrollbar();
setGeometry (1, 1, 4, 4);
setMinimumSize (4, 4);
xoffset_end = int(getScrollWidth() - getViewportWidth());
yoffset_end = int(getScrollHeight() - getViewportHeight());
int xoffset_end = int(getScrollWidth() - getViewportWidth());
int yoffset_end = int(getScrollHeight() - getViewportHeight());
nf_offset = isNewFont() ? 1 : 0;
setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
FPoint no_shadow(0, 0);
std::size_t w = getViewportWidth();
std::size_t h = getViewportHeight();
@ -765,14 +761,7 @@ void FScrollView::init_scrollbar()
try
{
vbar = std::make_shared<FScrollbar>(fc::vertical, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
}
catch (const std::bad_alloc& ex)
{
@ -780,6 +769,17 @@ void FScrollView::init_scrollbar()
return;
}
term_area* area = getPrintArea();
vbar->setPrintArea(area);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar->setPrintArea(area);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
vbar->addCallback
(
"change-value",
@ -821,7 +821,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
{
case fc::Auto:
if ( getScrollWidth() > getViewportWidth() )
hbar->setVisible();
hbar->show();
else
hbar->hide();
break;
@ -831,7 +831,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
break;
case fc::Scroll:
hbar->setVisible();
hbar->show();
break;
}
}
@ -843,7 +843,7 @@ void FScrollView::setVerticalScrollBarVisibility()
{
case fc::Auto:
if ( getScrollHeight() > getViewportHeight() )
vbar->setVisible();
vbar->show();
else
vbar->hide();
break;
@ -853,7 +853,7 @@ void FScrollView::setVerticalScrollBarVisibility()
break;
case fc::Scroll:
vbar->setVisible();
vbar->show();
break;
}
}
@ -985,10 +985,7 @@ void FScrollView::cb_HBarChange (FWidget*, FDataPtr)
inline void FScrollView::redrawHBar()
{
child_print_area = nullptr;
if ( hbar->isVisible() )
hbar->redraw();
hbar->redraw();
child_print_area = viewport;
}
@ -996,10 +993,7 @@ inline void FScrollView::redrawHBar()
inline void FScrollView::redrawVBar()
{
child_print_area = nullptr;
if ( vbar->isVisible() )
vbar->redraw();
vbar->redraw();
child_print_area = viewport;
}
@ -1007,10 +1001,7 @@ inline void FScrollView::redrawVBar()
inline void FScrollView::drawHBar()
{
child_print_area = nullptr;
if ( hbar->isVisible() )
hbar->drawBar();
hbar->drawBar();
child_print_area = viewport;
}
@ -1018,10 +1009,7 @@ inline void FScrollView::drawHBar()
inline void FScrollView::drawVBar()
{
child_print_area = nullptr;
if ( vbar->isVisible() )
vbar->drawBar();
vbar->drawBar();
child_print_area = viewport;
}

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 *
@ -495,8 +495,7 @@ void FStatusBar::cb_statuskey_activated (FWidget* widget, FDataPtr)
}
}
if ( isVisible() && isShown() )
redraw();
redraw();
}

View File

@ -140,7 +140,7 @@ void FTextView::scrollTo (int x, int y)
bool changeX = bool(x != xoffset);
bool changeY = bool(y != yoffset);
if ( ! isVisible() || ! (changeX || changeY) )
if ( ! isShown() || ! (changeX || changeY) )
return;
if ( changeX && isHorizontallyScrollable() )
@ -157,7 +157,7 @@ void FTextView::scrollTo (int x, int y)
if ( update_scrollbar )
{
hbar->setValue (xoffset);
drawHBar();
hbar->drawBar();;
}
}
@ -175,7 +175,7 @@ void FTextView::scrollTo (int x, int y)
if ( update_scrollbar )
{
vbar->setValue (yoffset);
drawVBar();
vbar->drawBar();
}
}
@ -264,8 +264,8 @@ void FTextView::insert (const FString& str, int pos)
hbar->setPageSize (int(maxLineWidth), int(getTextWidth()));
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( ! hbar->isShown() )
hbar->show();
}
}
}
@ -278,10 +278,10 @@ void FTextView::insert (const FString& str, int pos)
vbar->setPageSize (int(getRows()), int(getTextHeight()));
vbar->calculateSliderValues();
if ( ! vbar->isVisible() && getRows() > getTextHeight() )
vbar->setVisible();
if ( ! vbar->isShown() && getRows() > getTextHeight() )
vbar->show();
if ( vbar->isVisible() && getRows() <= getTextHeight() )
if ( vbar->isShown() && getRows() <= getTextHeight() )
vbar->hide();
processChanged();
@ -462,11 +462,8 @@ void FTextView::onMouseUp (FMouseEvent* ev)
}
}
if ( vbar->isVisible() )
vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw();
vbar->redraw();
hbar->redraw();
}
//----------------------------------------------------------------------
@ -518,7 +515,7 @@ void FTextView::onWheel (FWheelEvent* ev)
break;
}
if ( isVisible() )
if ( isShown() )
drawText();
updateTerminal();
@ -593,12 +590,12 @@ void FTextView::adjustSize()
if ( last_line < int(height) + nf_offset - 1 )
vbar->hide();
else
vbar->setVisible();
vbar->show();
if ( max_width < int(width) - nf_offset - 1 )
hbar->hide();
else
hbar->setVisible();
hbar->show();
}
@ -618,20 +615,10 @@ std::size_t FTextView::getTextWidth()
//----------------------------------------------------------------------
void FTextView::init()
{
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
try
{
vbar = std::make_shared<FScrollbar>(fc::vertical, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
}
catch (const std::bad_alloc& ex)
{
@ -639,6 +626,14 @@ void FTextView::init()
return;
}
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
vbar->addCallback
(
"change-value",
@ -651,6 +646,8 @@ void FTextView::init()
F_METHOD_CALLBACK (this, &FTextView::cb_HBarChange)
);
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
@ -687,10 +684,10 @@ void FTextView::draw()
if ( isMonochron() )
setReverse(false);
if ( vbar->isVisible() )
if ( vbar->isShown() )
vbar->redraw();
if ( hbar->isVisible() )
if ( hbar->isShown() )
hbar->redraw();
drawText();
@ -768,20 +765,6 @@ void FTextView::processChanged()
emitCallback("changed");
}
//----------------------------------------------------------------------
inline void FTextView::drawHBar()
{
if ( hbar->isVisible() )
hbar->drawBar();
}
//----------------------------------------------------------------------
inline void FTextView::drawVBar()
{
if ( vbar->isVisible() )
vbar->drawBar();
}
//----------------------------------------------------------------------
void FTextView::cb_VBarChange (FWidget*, FDataPtr)
{

View File

@ -247,6 +247,12 @@ void FWidget::setMainWidget (FWidget* obj)
app_object->focusFirstChild();
}
//----------------------------------------------------------------------
bool FWidget::setVisible (bool enable)
{
return (flags.visible = enable);
}
//----------------------------------------------------------------------
bool FWidget::setEnable (bool enable)
{
@ -754,7 +760,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
auto widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled()
&& widget->isVisible()
&& widget->isShown()
&& ! widget->isWindowWidget()
&& widget->getTermGeometry().contains(x, y) )
{
@ -785,7 +791,7 @@ int FWidget::numOfFocusableChildren()
{
auto widget = static_cast<FWidget*>(*iter);
if ( widget->isVisible()
if ( widget->isShown()
&& widget->acceptFocus()
&& ! widget->isWindowWidget() )
num++;
@ -981,7 +987,7 @@ void FWidget::redraw()
setColor (wc.term_fg, wc.term_bg);
clearArea (vdesktop);
}
else if ( ! isVisible() )
else if ( ! isShown() )
return;
draw();
@ -1050,6 +1056,7 @@ void FWidget::show()
}
draw();
flags.hidden = false;
flags.shown = true;
if ( hasChildren() )
@ -1062,7 +1069,9 @@ void FWidget::show()
if ( (*iter)->isWidget() )
{
auto widget = static_cast<FWidget*>(*iter);
widget->show();
if ( ! widget->flags.hidden )
widget->show();
}
++iter;
@ -1084,9 +1093,10 @@ void FWidget::show()
//----------------------------------------------------------------------
void FWidget::hide()
{
flags.hidden = true;
if ( isVisible() )
{
flags.visible = false;
flags.shown = false;
if ( ! isDialogWidget()
@ -1652,7 +1662,7 @@ bool FWidget::focusNextChild()
} while ( ! next
|| ! next->isEnabled()
|| ! next->acceptFocus()
|| ! next->isVisible()
|| ! next->isShown()
|| next->isWindowWidget() );
bool accpt = changeFocus (next, parent, fc::FocusNextWidget);
@ -1713,7 +1723,7 @@ bool FWidget::focusPrevChild()
} while ( ! prev
|| ! prev->isEnabled()
|| ! prev->acceptFocus()
|| ! prev->isVisible()
|| ! prev->isShown()
|| prev->isWindowWidget() );
bool accpt = changeFocus (prev, parent, fc::FocusPreviousWidget);
@ -2137,7 +2147,7 @@ void FWidget::drawWindows()
while ( iter != last )
{
if ( (*iter)->isVisible() )
if ( (*iter)->isShown() )
{
auto win = (*iter)->getVWin();
int w = win->width + win->right_shadow;
@ -2167,7 +2177,7 @@ void FWidget::drawChildren()
{
auto widget = static_cast<FWidget*>(*iter);
if ( widget->isVisible() && ! widget->isWindowWidget() )
if ( widget->isShown() && ! widget->isWindowWidget() )
widget->redraw();
}

View File

@ -255,6 +255,10 @@ class FListBox : public FWidget
// Accessors
static FString& getString (listBoxItems::iterator);
// Inquiry
bool isHorizontallyScrollable();
bool isVerticallyScrollable();
// Methods
void init();
virtual void draw() override;
@ -523,6 +527,14 @@ void FListBox::insert ( const ItemT& item
insert (listItem);
}
//----------------------------------------------------------------------
inline bool FListBox::isHorizontallyScrollable()
{ return bool( max_line_width >= getClientWidth() - 1 ); }
//----------------------------------------------------------------------
inline bool FListBox::isVerticallyScrollable()
{ return bool( getCount() > getClientHeight() ); }
//----------------------------------------------------------------------
inline FListBox::listBoxItems::iterator \
FListBox::index2iterator (std::size_t index)

View File

@ -378,6 +378,10 @@ class FListView : public FWidget
// Constants
static constexpr int USE_MAX_SIZE = -1;
// Inquiry
bool isHorizontallyScrollable();
bool isVerticallyScrollable();
// Methods
void init();
template <typename Compare>
@ -616,6 +620,14 @@ inline FObject::FObjectIterator FListView::beginOfList()
inline FObject::FObjectIterator FListView::endOfList()
{ return itemlist.end(); }
//----------------------------------------------------------------------
inline bool FListView::isHorizontallyScrollable()
{ return bool( max_line_width > getClientWidth() ); }
//----------------------------------------------------------------------
inline bool FListView::isVerticallyScrollable()
{ return bool( getCount() > getClientHeight() ); }
//----------------------------------------------------------------------
inline void FListView::scrollTo (const FPoint& pos)
{ scrollTo(pos.getX(), pos.getY()); }

View File

@ -150,8 +150,6 @@ class FTextView : public FWidget
virtual void draw() override;
void drawText();
void processChanged();
void drawHBar();
void drawVBar();
// Callback methods
void cb_VBarChange (FWidget*, FDataPtr);

View File

@ -321,6 +321,7 @@ class FVTerm
FTerm::initializationValues& getInitValues();
// Mutators
void setPrintArea (term_area*);
static void setInsertCursor (bool);
static void setInsertCursor();
static void unsetInsertCursor();
@ -451,9 +452,6 @@ class FVTerm
static constexpr uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768;
// Buffer size for character output on the terminal
// Mutators
void setPrintArea (term_area*);
// Methods
void init (bool);
static void init_characterLengths (FOptiMove*);
@ -1063,6 +1061,10 @@ inline char* FVTerm::moveCursor (int xold, int yold, int xnew, int ynew)
inline void FVTerm::printMoveDurations()
{ return FTerm::printMoveDurations(); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area)
{ print_area = area; }
//----------------------------------------------------------------------
inline std::size_t FVTerm::getLineNumber()
{ return FTerm::getLineNumber(); }
@ -1143,10 +1145,6 @@ inline void FVTerm::changeTermSizeFinished()
inline void FVTerm::exitWithMessage (const FString& message)
{ FTerm::exitWithMessage(message); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area)
{ print_area = area; }
} // namespace finalcut
#endif // FVTERM_H

View File

@ -149,6 +149,7 @@ class FWidget : public FVTerm, public FObject
uInt32 active : 1;
uInt32 visible : 1;
uInt32 shown : 1;
uInt32 hidden : 1;
uInt32 focus : 1;
uInt32 focusable : 1;
uInt32 scrollable : 1;
@ -161,7 +162,7 @@ class FWidget : public FVTerm, public FObject
uInt32 always_on_top : 1;
uInt32 flat : 1;
uInt32 no_underline : 1;
uInt32 : 15; // padding bits
uInt32 : 14; // padding bits
};
// Constructor
@ -229,7 +230,9 @@ class FWidget : public FVTerm, public FObject
static void setActiveWindow (FWidget*);
static void setOpenMenu (FWidget*);
virtual void setStatusbarMessage (const FString&);
bool setVisible (bool);
bool setVisible();
bool unsetVisible();
virtual bool setEnable (bool);
virtual bool setEnable();
virtual bool unsetEnable();
@ -721,7 +724,11 @@ inline void FWidget::setStatusbarMessage (const FString& msg)
//----------------------------------------------------------------------
inline bool FWidget::setVisible()
{ return (flags.visible = true); }
{ return setVisible(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetVisible()
{ return setVisible(false); }
//----------------------------------------------------------------------
inline bool FWidget::setEnable()