diff --git a/ChangeLog b/ChangeLog index c1d00eda..22cc301d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-12-17 Markus Gans + * Improve FButton mouse click animation + * Minor data type corrections + * Reactivate the event queue + 2018-12-15 Markus Gans * Use of the C++11 auto specifier in the program code * Code reduction by using of Range-based for loop diff --git a/examples/choice.cpp b/examples/choice.cpp index ca0bee2d..1e8a8ae0 100644 --- a/examples/choice.cpp +++ b/examples/choice.cpp @@ -124,7 +124,7 @@ int main (int argc, char* argv[]) // Scroll to the focused child element finalcut::FFocusEvent cfi (finalcut::fc::ChildFocusIn_Event); - finalcut::FApplication::sendEvent(&checkButtonGroup, &cfi); + finalcut::FApplication::queueEvent(&checkButtonGroup, &cfi); // Create a OK button finalcut::FButton ok("&OK", &dgl); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 15b61f75..9b82037a 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -51,7 +51,7 @@ int FApplication::loop_level = 0; // event loop level int FApplication::quit_code = 0; bool FApplication::quit_now = false; -FApplication::eventQueue* FApplication::event_queue = nullptr; +FApplication::eventQueuePtr FApplication::event_queue = nullptr; //---------------------------------------------------------------------- @@ -84,8 +84,8 @@ FApplication::FApplication ( const int& _argc //---------------------------------------------------------------------- FApplication::~FApplication() // destructor { - if ( event_queue ) - delete event_queue; + //if ( event_queue ) + // delete event_queue; app_object = nullptr; } @@ -233,22 +233,18 @@ void FApplication::queueEvent ( const FObject* receiver return; // queue this event - eventPair Event (receiver, event); - event_queue->push_back(Event); + eventPair send_event (receiver, std::make_shared(*event)); + event_queue->push_back(send_event); } //---------------------------------------------------------------------- void FApplication::sendQueuedEvents() { - if ( ! eventInQueue() ) - return; - - auto events = event_queue; - - while ( ! eventInQueue() ) + while ( eventInQueue() ) { - sendEvent(events->front().first, events->front().second); - events->pop_front(); + sendEvent( event_queue->front().first, + event_queue->front().second.get() ); + event_queue->pop_front(); } } @@ -393,7 +389,8 @@ void FApplication::init (long key_time, long dblclick_time) try { - event_queue = new eventQueue; + //event_queue = new eventQueue; + event_queue = std::make_shared(); } catch (const std::bad_alloc& ex) { diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 37b8c0bb..5c6c5ba2 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -292,8 +292,6 @@ void FButton::onMouseDown (FMouseEvent* ev) if ( ! hasFocus() ) { auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); if ( focused_widget ) @@ -345,10 +343,6 @@ void FButton::onMouseMove (FMouseEvent* ev) void FButton::onTimer (FTimerEvent* ev) { delTimer(ev->timerId()); - - if ( hasShadow() ) - clearShadow(); - setUp(); } @@ -364,8 +358,6 @@ void FButton::onAccel (FAccelEvent* ev) if ( focused_widget && focused_widget->isWidget() ) { - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); focused_widget->redraw(); diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 169d47c4..4e801528 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -618,8 +618,6 @@ void FButtonGroup::directFocus() { found_checked = true; auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); toggle_button->setFocus(); if ( focused_widget ) @@ -641,8 +639,6 @@ void FButtonGroup::directFocus() if ( ! found_checked ) { auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); focusFirstChild(); if ( focused_widget ) diff --git a/src/flabel.cpp b/src/flabel.cpp index a197cc6d..7299322c 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -295,8 +295,6 @@ void FLabel::onMouseDown (FMouseEvent* ev) { // focus the accelerator widget auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); accel_widget->setFocus(); if ( focused_widget ) @@ -325,8 +323,6 @@ void FLabel::onAccel (FAccelEvent* ev) if ( focused_widget && focused_widget->isWidget() ) { - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); accel_widget->setFocus(); focused_widget->redraw(); accel_widget->redraw(); diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 2e526e12..bfd50ceb 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -396,8 +396,6 @@ void FLineEdit::onMouseDown (FMouseEvent* ev) if ( ! hasFocus() ) { auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); if ( focused_widget ) @@ -562,8 +560,6 @@ void FLineEdit::onAccel (FAccelEvent* ev) if ( focused_widget && focused_widget->isWidget() ) { - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); focused_widget->redraw(); redraw(); diff --git a/src/flistbox.cpp b/src/flistbox.cpp index cd6f64e7..21f40eb0 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -295,9 +295,9 @@ void FListBox::remove (std::size_t item) element_count = getCount(); max_line_width = 0; - for (auto&& item : itemlist) + for (auto&& listbox_item : itemlist) { - std::size_t len = item.getText().getLength(); + std::size_t len = listbox_item.getText().getLength(); if ( len > max_line_width ) max_line_width = len; @@ -1268,8 +1268,6 @@ inline void FListBox::getWidgetFocus() return; auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); if ( focused_widget ) diff --git a/src/flistview.cpp b/src/flistview.cpp index b539be43..1782d932 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -983,8 +983,6 @@ void FListView::onMouseDown (FMouseEvent* ev) if ( ! hasFocus() ) { auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); if ( focused_widget ) diff --git a/src/fmenu.cpp b/src/fmenu.cpp index e9491be5..91872f89 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -722,8 +722,6 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed) unselectItem(); auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); m_item->setSelected(); setSelectedItem(m_item); m_item->setFocus(); @@ -836,8 +834,6 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms) // Mouse pointer over item auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); m_item->setSelected(); setSelectedItem(m_item); m_item->setFocus(); diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 835643e3..70813575 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -736,8 +736,6 @@ void FMenuBar::selectMenuItem (FMenuItem* item) return; auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); item->setSelected(); item->setFocus(); diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index b618aada..f3fbc0e7 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -428,13 +428,6 @@ void FMenuItem::onAccel (FAccelEvent* ev) mbar->selected_item = this; openMenu(); auto focused_widget = static_cast(ev->focusedWidget()); - - if ( focused_widget && focused_widget->isWidget() ) - { - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); - } - menu->unselectItem(); menu->selectFirstItem(); diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 63c002af..d60aa106 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -115,7 +115,7 @@ void FProgressbar::hide() } setColor (fg, bg); - auto s = hasShadow() ? 1 : 0; + std::size_t s = hasShadow() ? 1 : 0; auto size = getWidth() + s; if ( size == 0 ) diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 962c838d..4c9689ef 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -203,7 +203,7 @@ void FTextView::hide() } setColor (fg, bg); - auto n = isNewFont() ? 1 : 0; + std::size_t n = isNewFont() ? 1 : 0; auto size = getWidth() + n; if ( size == 0 ) @@ -396,8 +396,6 @@ void FTextView::onMouseDown (FMouseEvent* ev) if ( ! hasFocus() ) { FWidget* focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); if ( focused_widget ) diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 9d935628..80f2d1d8 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -240,8 +240,6 @@ void FToggleButton::onMouseDown (FMouseEvent* ev) return; auto focused_widget = getFocusWidget(); - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); if ( focused_widget ) @@ -305,8 +303,6 @@ void FToggleButton::onAccel (FAccelEvent* ev) if ( focused_widget && focused_widget->isWidget() ) { - FFocusEvent out (fc::FocusOut_Event); - FApplication::queueEvent(focused_widget, &out); setFocus(); focused_widget->redraw(); } diff --git a/src/fvterm.cpp b/src/fvterm.cpp index a73be984..123aff64 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -1486,8 +1486,8 @@ void FVTerm::putArea (int ax, int ay, term_area* area) if ( area->changes[y].trans_count == 0 ) { // Line has only covered characters - auto ac = &area->text[y * line_len + ol]; - auto tc = &vterm->text[(ay + y) * vterm->width + ax]; + ac = &area->text[y * line_len + ol]; + tc = &vterm->text[(ay + y) * vterm->width + ax]; putAreaLine (ac, tc, length); } else diff --git a/src/fwidget.cpp b/src/fwidget.cpp index fdc9c1b3..0afa6f9f 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1317,7 +1317,7 @@ void FWidget::drawFlatBorder() // left line (on right side) print (fc::NF_border_line_left); - setPrintPos (x2, y1 + y + 2); + setPrintPos (x2, y1 + int(y) + 2); } setPrintPos (x1, y1); diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 8d432021..1d366af9 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -62,6 +62,7 @@ #include #include +#include #include #include @@ -125,8 +126,9 @@ class FApplication : public FWidget private: // Typedefs and Enumerations - typedef std::pair eventPair; + typedef std::pair > eventPair; typedef std::deque eventQueue; + typedef std::shared_ptr eventQueuePtr; // Constants static const int NEED_MORE_DATA = -1; // parseKeyString return value @@ -180,7 +182,7 @@ class FApplication : public FWidget long key_timeout{100000}; // 100 ms long dblclick_interval{500000}; // 500 ms static FMouseControl* mouse; - static eventQueue* event_queue; + static eventQueuePtr event_queue; static int quit_code; static bool quit_now; static int loop_level;