Reactivate the event queue
This commit is contained in:
parent
ae38a45a5e
commit
554d26ca00
|
@ -1,6 +1,7 @@
|
||||||
2018-12-17 Markus Gans <guru.mail@muenster.de>
|
2018-12-17 Markus Gans <guru.mail@muenster.de>
|
||||||
* Improve FButton mouse click animation
|
* Improve FButton mouse click animation
|
||||||
* Minor data type corrections
|
* Minor data type corrections
|
||||||
|
* Reactivate the event queue
|
||||||
|
|
||||||
2018-12-15 Markus Gans <guru.mail@muenster.de>
|
2018-12-15 Markus Gans <guru.mail@muenster.de>
|
||||||
* Use of the C++11 auto specifier in the program code
|
* Use of the C++11 auto specifier in the program code
|
||||||
|
|
|
@ -124,7 +124,7 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
// Scroll to the focused child element
|
// Scroll to the focused child element
|
||||||
finalcut::FFocusEvent cfi (finalcut::fc::ChildFocusIn_Event);
|
finalcut::FFocusEvent cfi (finalcut::fc::ChildFocusIn_Event);
|
||||||
finalcut::FApplication::sendEvent(&checkButtonGroup, &cfi);
|
finalcut::FApplication::queueEvent(&checkButtonGroup, &cfi);
|
||||||
|
|
||||||
// Create a OK button
|
// Create a OK button
|
||||||
finalcut::FButton ok("&OK", &dgl);
|
finalcut::FButton ok("&OK", &dgl);
|
||||||
|
|
|
@ -51,7 +51,7 @@ int FApplication::loop_level = 0; // event loop level
|
||||||
int FApplication::quit_code = 0;
|
int FApplication::quit_code = 0;
|
||||||
bool FApplication::quit_now = false;
|
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
|
FApplication::~FApplication() // destructor
|
||||||
{
|
{
|
||||||
if ( event_queue )
|
//if ( event_queue )
|
||||||
delete event_queue;
|
// delete event_queue;
|
||||||
|
|
||||||
app_object = nullptr;
|
app_object = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -233,22 +233,18 @@ void FApplication::queueEvent ( const FObject* receiver
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// queue this event
|
// queue this event
|
||||||
eventPair Event (receiver, event);
|
eventPair send_event (receiver, std::make_shared<const FEvent>(*event));
|
||||||
event_queue->push_back(Event);
|
event_queue->push_back(send_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::sendQueuedEvents()
|
void FApplication::sendQueuedEvents()
|
||||||
{
|
{
|
||||||
if ( ! eventInQueue() )
|
while ( eventInQueue() )
|
||||||
return;
|
|
||||||
|
|
||||||
auto events = event_queue;
|
|
||||||
|
|
||||||
while ( ! eventInQueue() )
|
|
||||||
{
|
{
|
||||||
sendEvent(events->front().first, events->front().second);
|
sendEvent( event_queue->front().first,
|
||||||
events->pop_front();
|
event_queue->front().second.get() );
|
||||||
|
event_queue->pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +389,8 @@ void FApplication::init (long key_time, long dblclick_time)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
event_queue = new eventQueue;
|
//event_queue = new eventQueue;
|
||||||
|
event_queue = std::make_shared<eventQueue>();
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -292,8 +292,6 @@ void FButton::onMouseDown (FMouseEvent* ev)
|
||||||
if ( ! hasFocus() )
|
if ( ! hasFocus() )
|
||||||
{
|
{
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
@ -360,8 +358,6 @@ void FButton::onAccel (FAccelEvent* ev)
|
||||||
|
|
||||||
if ( focused_widget && focused_widget->isWidget() )
|
if ( focused_widget && focused_widget->isWidget() )
|
||||||
{
|
{
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
|
|
||||||
|
|
|
@ -618,8 +618,6 @@ void FButtonGroup::directFocus()
|
||||||
{
|
{
|
||||||
found_checked = true;
|
found_checked = true;
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
toggle_button->setFocus();
|
toggle_button->setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
@ -641,8 +639,6 @@ void FButtonGroup::directFocus()
|
||||||
if ( ! found_checked )
|
if ( ! found_checked )
|
||||||
{
|
{
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
focusFirstChild();
|
focusFirstChild();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
|
|
@ -295,8 +295,6 @@ void FLabel::onMouseDown (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
// focus the accelerator widget
|
// focus the accelerator widget
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
accel_widget->setFocus();
|
accel_widget->setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
@ -325,8 +323,6 @@ void FLabel::onAccel (FAccelEvent* ev)
|
||||||
|
|
||||||
if ( focused_widget && focused_widget->isWidget() )
|
if ( focused_widget && focused_widget->isWidget() )
|
||||||
{
|
{
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
accel_widget->setFocus();
|
accel_widget->setFocus();
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
accel_widget->redraw();
|
accel_widget->redraw();
|
||||||
|
|
|
@ -396,8 +396,6 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
|
||||||
if ( ! hasFocus() )
|
if ( ! hasFocus() )
|
||||||
{
|
{
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
@ -562,8 +560,6 @@ void FLineEdit::onAccel (FAccelEvent* ev)
|
||||||
|
|
||||||
if ( focused_widget && focused_widget->isWidget() )
|
if ( focused_widget && focused_widget->isWidget() )
|
||||||
{
|
{
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
|
@ -1268,8 +1268,6 @@ inline void FListBox::getWidgetFocus()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
|
|
@ -983,8 +983,6 @@ void FListView::onMouseDown (FMouseEvent* ev)
|
||||||
if ( ! hasFocus() )
|
if ( ! hasFocus() )
|
||||||
{
|
{
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
|
|
@ -722,8 +722,6 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed)
|
||||||
|
|
||||||
unselectItem();
|
unselectItem();
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
m_item->setSelected();
|
m_item->setSelected();
|
||||||
setSelectedItem(m_item);
|
setSelectedItem(m_item);
|
||||||
m_item->setFocus();
|
m_item->setFocus();
|
||||||
|
@ -836,8 +834,6 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms)
|
||||||
|
|
||||||
// Mouse pointer over item
|
// Mouse pointer over item
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
m_item->setSelected();
|
m_item->setSelected();
|
||||||
setSelectedItem(m_item);
|
setSelectedItem(m_item);
|
||||||
m_item->setFocus();
|
m_item->setFocus();
|
||||||
|
|
|
@ -736,8 +736,6 @@ void FMenuBar::selectMenuItem (FMenuItem* item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
item->setSelected();
|
item->setSelected();
|
||||||
item->setFocus();
|
item->setFocus();
|
||||||
|
|
||||||
|
|
|
@ -428,13 +428,6 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
||||||
mbar->selected_item = this;
|
mbar->selected_item = this;
|
||||||
openMenu();
|
openMenu();
|
||||||
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
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->unselectItem();
|
||||||
menu->selectFirstItem();
|
menu->selectFirstItem();
|
||||||
|
|
||||||
|
|
|
@ -396,8 +396,6 @@ void FTextView::onMouseDown (FMouseEvent* ev)
|
||||||
if ( ! hasFocus() )
|
if ( ! hasFocus() )
|
||||||
{
|
{
|
||||||
FWidget* focused_widget = getFocusWidget();
|
FWidget* focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
|
|
@ -240,8 +240,6 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
|
@ -305,8 +303,6 @@ void FToggleButton::onAccel (FAccelEvent* ev)
|
||||||
|
|
||||||
if ( focused_widget && focused_widget->isWidget() )
|
if ( focused_widget && focused_widget->isWidget() )
|
||||||
{
|
{
|
||||||
FFocusEvent out (fc::FocusOut_Event);
|
|
||||||
FApplication::queueEvent(focused_widget, &out);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
@ -125,8 +126,9 @@ class FApplication : public FWidget
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Typedefs and Enumerations
|
// 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::deque<eventPair> eventQueue;
|
||||||
|
typedef std::shared_ptr<eventQueue> eventQueuePtr;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
static const int NEED_MORE_DATA = -1; // parseKeyString return value
|
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 key_timeout{100000}; // 100 ms
|
||||||
long dblclick_interval{500000}; // 500 ms
|
long dblclick_interval{500000}; // 500 ms
|
||||||
static FMouseControl* mouse;
|
static FMouseControl* mouse;
|
||||||
static eventQueue* event_queue;
|
static eventQueuePtr event_queue;
|
||||||
static int quit_code;
|
static int quit_code;
|
||||||
static bool quit_now;
|
static bool quit_now;
|
||||||
static int loop_level;
|
static int loop_level;
|
||||||
|
|
Loading…
Reference in New Issue