Reactivate the event queue

This commit is contained in:
Markus Gans 2018-12-17 02:06:22 +01:00
parent ae38a45a5e
commit 554d26ca00
15 changed files with 17 additions and 56 deletions

View File

@ -1,6 +1,7 @@
2018-12-17 Markus Gans <guru.mail@muenster.de>
* Improve FButton mouse click animation
* Minor data type corrections
* Reactivate the event queue
2018-12-15 Markus Gans <guru.mail@muenster.de>
* Use of the C++11 auto specifier in the program code

View File

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

View File

@ -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<const FEvent>(*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<eventQueue>();
}
catch (const std::bad_alloc& ex)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -428,13 +428,6 @@ void FMenuItem::onAccel (FAccelEvent* ev)
mbar->selected_item = this;
openMenu();
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
if ( focused_widget && focused_widget->isWidget() )
{
FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out);
}
menu->unselectItem();
menu->selectFirstItem();

View File

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

View File

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

View File

@ -62,6 +62,7 @@
#include <getopt.h>
#include <deque>
#include <memory>
#include <string>
#include <utility>
@ -125,8 +126,9 @@ class FApplication : public FWidget
private:
// Typedefs and Enumerations
typedef std::pair<const FObject*, const FEvent*> eventPair;
typedef std::pair<const FObject*, std::shared_ptr<const FEvent> > eventPair;
typedef std::deque<eventPair> eventQueue;
typedef std::shared_ptr<eventQueue> 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;