commit
eeb78aaea7
|
@ -1,3 +1,8 @@
|
||||||
|
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>
|
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
|
||||||
* Code reduction by using of Range-based for loop
|
* Code reduction by using of Range-based for loop
|
||||||
|
|
|
@ -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 )
|
||||||
|
@ -345,10 +343,6 @@ void FButton::onMouseMove (FMouseEvent* ev)
|
||||||
void FButton::onTimer (FTimerEvent* ev)
|
void FButton::onTimer (FTimerEvent* ev)
|
||||||
{
|
{
|
||||||
delTimer(ev->timerId());
|
delTimer(ev->timerId());
|
||||||
|
|
||||||
if ( hasShadow() )
|
|
||||||
clearShadow();
|
|
||||||
|
|
||||||
setUp();
|
setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,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();
|
||||||
|
|
|
@ -295,9 +295,9 @@ void FListBox::remove (std::size_t item)
|
||||||
element_count = getCount();
|
element_count = getCount();
|
||||||
max_line_width = 0;
|
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 )
|
if ( len > max_line_width )
|
||||||
max_line_width = len;
|
max_line_width = len;
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ void FProgressbar::hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
setColor (fg, bg);
|
setColor (fg, bg);
|
||||||
auto s = hasShadow() ? 1 : 0;
|
std::size_t s = hasShadow() ? 1 : 0;
|
||||||
auto size = getWidth() + s;
|
auto size = getWidth() + s;
|
||||||
|
|
||||||
if ( size == 0 )
|
if ( size == 0 )
|
||||||
|
|
|
@ -203,7 +203,7 @@ void FTextView::hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
setColor (fg, bg);
|
setColor (fg, bg);
|
||||||
auto n = isNewFont() ? 1 : 0;
|
std::size_t n = isNewFont() ? 1 : 0;
|
||||||
auto size = getWidth() + n;
|
auto size = getWidth() + n;
|
||||||
|
|
||||||
if ( size == 0 )
|
if ( size == 0 )
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1486,8 +1486,8 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
|
||||||
if ( area->changes[y].trans_count == 0 )
|
if ( area->changes[y].trans_count == 0 )
|
||||||
{
|
{
|
||||||
// Line has only covered characters
|
// Line has only covered characters
|
||||||
auto ac = &area->text[y * line_len + ol];
|
ac = &area->text[y * line_len + ol];
|
||||||
auto tc = &vterm->text[(ay + y) * vterm->width + ax];
|
tc = &vterm->text[(ay + y) * vterm->width + ax];
|
||||||
putAreaLine (ac, tc, length);
|
putAreaLine (ac, tc, length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1317,7 +1317,7 @@ void FWidget::drawFlatBorder()
|
||||||
// left line (on right side)
|
// left line (on right side)
|
||||||
print (fc::NF_border_line_left);
|
print (fc::NF_border_line_left);
|
||||||
|
|
||||||
setPrintPos (x2, y1 + y + 2);
|
setPrintPos (x2, y1 + int(y) + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPrintPos (x1, y1);
|
setPrintPos (x1, y1);
|
||||||
|
|
|
@ -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