Now hides the input cursor when a widget gets hidden

This commit is contained in:
Markus Gans 2020-10-05 04:24:14 +02:00
parent 37f238eef7
commit adccd6ae3b
12 changed files with 53 additions and 28 deletions

View File

@ -1,3 +1,6 @@
2020-10-05 Markus Gans <guru.mail@muenster.de>
* Now hides the input cursor when a widget gets hidden
2020-10-04 Markus Gans <guru.mail@muenster.de> 2020-10-04 Markus Gans <guru.mail@muenster.de>
* Replaces some C-style arrays with std::array * Replaces some C-style arrays with std::array
* Now you can use the arrow keys to move a window into the visible area * Now you can use the arrow keys to move a window into the visible area

View File

@ -82,7 +82,7 @@ CheckList::CheckList (finalcut::FWidget* parent)
FDialog::setText (L"Shopping list"); FDialog::setText (L"Shopping list");
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0; const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
FDialog::setSize (FSize{28 + nf_offset, 13} ); FDialog::setSize (FSize{28 + nf_offset, 13} );
setShadow(); setShadow(); // Instead of the transparent window shadow
listview.ignorePadding(); listview.ignorePadding();
listview.setGeometry ( FPoint{1 + int(nf_offset), 2} listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
, FSize{getWidth() - nf_offset, getHeight() - 1} ); , FSize{getWidth() - nf_offset, getHeight() - 1} );

View File

@ -65,7 +65,7 @@ int main (int argc, char* argv[])
finalcut::FDialog dgl{&app}; finalcut::FDialog dgl{&app};
dgl.setText ("Data input"); dgl.setText ("Data input");
dgl.setGeometry (FPoint{4, 2}, FSize{37, 22}); dgl.setGeometry (FPoint{4, 2}, FSize{37, 22});
dgl.setShadow(); dgl.setShadow(); // Instead of the transparent window shadow
// Create input fields // Create input fields
finalcut::FLineEdit name_field {&dgl}; finalcut::FLineEdit name_field {&dgl};

View File

@ -167,7 +167,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
Mandelbrot mb{&app}; Mandelbrot mb{&app};
mb.setGeometry (FPoint{6, 1}, FSize{70, 23}); mb.setGeometry (FPoint{6, 1}, FSize{70, 23});
mb.setShadow(); mb.setShadow(); // Instead of the transparent window shadow
// Set the mandelbrot object as main widget // Set the mandelbrot object as main widget
finalcut::FWidget::setMainWidget(&mb); finalcut::FWidget::setMainWidget(&mb);

View File

@ -139,8 +139,8 @@ void RotoZoomer::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void RotoZoomer::rotozoomer (double cx, double cy, double r, double a) void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
{ {
const int Cols = int(getClientWidth()); const auto Cols = int(getClientWidth());
const int Lines = int(getClientHeight()); const auto Lines = int(getClientHeight());
auto Ax = int(4096.0 * (cx + r * std::cos(a))); auto Ax = int(4096.0 * (cx + r * std::cos(a)));
auto Ay = int(4096.0 * (cy + r * std::sin(a))); auto Ay = int(4096.0 * (cy + r * std::sin(a)));
auto Bx = int(4096.0 * (cx + r * std::cos(a + 2.02358))); auto Bx = int(4096.0 * (cx + r * std::cos(a + 2.02358)));
@ -323,7 +323,7 @@ int main (int argc, char* argv[])
if ( benchmark ) if ( benchmark )
roto.setGeometry (FPoint{1, 1}, FSize{80, 24}); roto.setGeometry (FPoint{1, 1}, FSize{80, 24});
roto.setShadow(); roto.setShadow(); // Instead of the transparent window shadow
// Set the RotoZoomer object as main widget // Set the RotoZoomer object as main widget
finalcut::FWidget::setMainWidget(&roto); finalcut::FWidget::setMainWidget(&roto);

View File

@ -499,7 +499,7 @@ int main (int argc, char* argv[])
// the parent object "app" (FObject destructor). // the parent object "app" (FObject destructor).
AttribDlg dialog{&app}; AttribDlg dialog{&app};
dialog.setSize (FSize{69, 21}); dialog.setSize (FSize{69, 21});
dialog.setShadow(); dialog.setShadow(); // Instead of the transparent window shadow
// Create the attribute demo widget as a child object from the dialog // Create the attribute demo widget as a child object from the dialog
AttribDemo demo(&dialog); AttribDemo demo(&dialog);

View File

@ -1067,7 +1067,7 @@ int main (int argc, char* argv[])
MyDialog d{&app}; MyDialog d{&app};
d.setText (title); d.setText (title);
d.setSize (FSize{56, app.getHeight() - 4}); d.setSize (FSize{56, app.getHeight() - 4});
d.setShadow(); d.setShadow(); // Instead of the transparent window shadow
// Set the dialog object d as the main widget of the application. // Set the dialog object d as the main widget of the application.
// When you close the main widget, the application will be closed. // When you close the main widget, the application will be closed.

View File

@ -800,23 +800,23 @@ void FVTerm::removeArea (FTermArea*& area)
{ {
// remove the virtual window // remove the virtual window
if ( area != nullptr ) if ( area == nullptr )
return;
if ( area->changes != nullptr )
{ {
if ( area->changes != nullptr ) delete[] area->changes;
{ area->changes = nullptr;
delete[] area->changes;
area->changes = nullptr;
}
if ( area->data != nullptr )
{
delete[] area->data;
area->data = nullptr;
}
delete area;
area = nullptr;
} }
if ( area->data != nullptr )
{
delete[] area->data;
area->data = nullptr;
}
delete area;
area = nullptr;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -876,7 +876,7 @@ bool FVTerm::updateVTermCursor (const FTermArea* area) const
if ( ! area ) if ( ! area )
return false; return false;
if ( area != active_area ) if ( ! isActive(area) )
return false; return false;
if ( ! area->visible ) if ( ! area->visible )

View File

@ -638,7 +638,7 @@ bool FWidget::setCursorPos (const FPoint& pos)
widget_cursor_position.setPoint(pos); widget_cursor_position.setPoint(pos);
if ( ! flags.focus || isWindowWidget() ) if ( ! flags.focus || flags.hidden || isWindowWidget() )
return false; return false;
if ( ! FWindow::getWindowWidget(this) ) if ( ! FWindow::getWindowWidget(this) )
@ -999,6 +999,11 @@ void FWidget::hide()
{ {
flags.shown = false; flags.shown = false;
if ( flags.visible_cursor && FWidget::getFocusWidget() == this )
{
getPrintArea()->input_cursor_visible = false;
}
if ( ! isDialogWidget() if ( ! isDialogWidget()
&& FWidget::getFocusWidget() == this && FWidget::getFocusWidget() == this
&& ! focusPrevChild() ) && ! focusPrevChild() )

View File

@ -278,8 +278,17 @@ void FWindow::show()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::hide() void FWindow::hide()
{ {
const auto& virtual_win = getVWin();
if ( isActive(virtual_win)
&& virtual_win->visible
&& virtual_win->input_cursor_visible )
{
hideVTermCursor();
}
if ( isVirtualWindow() ) if ( isVirtualWindow() )
getVWin()->visible = false; virtual_win->visible = false;
FWidget::hide(); FWidget::hide();
const auto& t_geometry = getTermGeometryWithShadow(); const auto& t_geometry = getTermGeometryWithShadow();
@ -681,7 +690,6 @@ void FWindow::switchToPrevWindow (const FWidget* widget)
const bool is_activated = activatePrevWindow(); const bool is_activated = activatePrevWindow();
auto active_win = static_cast<FWindow*>(getActiveWindow()); auto active_win = static_cast<FWindow*>(getActiveWindow());
if ( ! is_activated if ( ! is_activated
&& getWindowList() && getWindowList()->size() > 1 ) && getWindowList() && getWindowList()->size() > 1 )
{ {

View File

@ -145,7 +145,7 @@ class FSystemImpl : public FSystem
{ {
va_list args{}; va_list args{};
va_start (args, flags); va_start (args, flags);
mode_t mode = static_cast<mode_t>(va_arg (args, int)); auto mode = static_cast<mode_t>(va_arg (args, int));
int ret = ::open (pathname, flags, mode); int ret = ::open (pathname, flags, mode);
va_end (args); va_end (args);
return ret; return ret;

View File

@ -292,6 +292,7 @@ class FVTerm
void setActiveArea (FTermArea*) const; void setActiveArea (FTermArea*) const;
// Inquiries // Inquiries
bool isActive (const FTermArea*) const;
bool hasPrintArea() const; bool hasPrintArea() const;
bool hasChildPrintArea() const; bool hasChildPrintArea() const;
bool isVirtualWindow() const; bool isVirtualWindow() const;
@ -307,6 +308,7 @@ class FVTerm
static void removeArea (FTermArea*&); static void removeArea (FTermArea*&);
static void restoreVTerm (const FRect&); static void restoreVTerm (const FRect&);
bool updateVTermCursor (const FTermArea*) const; bool updateVTermCursor (const FTermArea*) const;
void hideVTermCursor() const;
static void setAreaCursor ( const FPoint& static void setAreaCursor ( const FPoint&
, bool, FTermArea* ); , bool, FTermArea* );
static void getArea (const FPoint&, const FTermArea*); static void getArea (const FPoint&, const FTermArea*);
@ -966,6 +968,10 @@ inline void FVTerm::setChildPrintArea (FTermArea* area)
inline void FVTerm::setActiveArea (FTermArea* area) const inline void FVTerm::setActiveArea (FTermArea* area) const
{ active_area = area; } { active_area = area; }
//----------------------------------------------------------------------
inline bool FVTerm::isActive (const FTermArea* area) const
{ return bool( area == active_area ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FVTerm::hasPrintArea() const inline bool FVTerm::hasPrintArea() const
{ return print_area; } { return print_area; }
@ -982,6 +988,9 @@ inline bool FVTerm::isVirtualWindow() const
inline bool FVTerm::isCursorHideable() const inline bool FVTerm::isCursorHideable() const
{ return cursor_hideable; } { return cursor_hideable; }
//----------------------------------------------------------------------
inline void FVTerm::hideVTermCursor() const
{ vterm->input_cursor_visible = false; }
} // namespace finalcut } // namespace finalcut