Merge pull request #30 from gansm/master

merge
This commit is contained in:
Markus Gans 2018-12-17 02:35:21 +01:00 committed by GitHub
commit eeb78aaea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 28 additions and 67 deletions

View File

@ -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>
* Use of the C++11 auto specifier in the program code
* Code reduction by using of Range-based for loop

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

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

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

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

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

View File

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

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

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

View File

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

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;