Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Widgets|libappfw: Added focus indicator and Focusable flag
The focus will be used for keyboard navigation.
- Loading branch information
Showing
13 changed files
with
221 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/focuswidget.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** @file focuswidget.h Input focus indicator. | ||
* | ||
* @authors Copyright (c) 2016 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* LGPL: http://www.gnu.org/licenses/lgpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
* General Public License for more details. You should have received a copy of | ||
* the GNU Lesser General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef LIBAPPFW_FOCUSWIDGET_H | ||
#define LIBAPPFW_FOCUSWIDGET_H | ||
|
||
#include <de/LabelWidget> | ||
|
||
namespace de { | ||
|
||
/** | ||
* Input focus indicator. | ||
* | ||
* GuiRootWidget owns an instance of FocusWidget to show where the input focus | ||
* is currently. | ||
*/ | ||
class LIBAPPFW_PUBLIC FocusWidget : public LabelWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
FocusWidget(de::String const &name = "focus"); | ||
|
||
void startFlashing(); | ||
void stopFlashing(); | ||
|
||
protected slots: | ||
void updateFlash(); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
} // namespace de | ||
|
||
#endif // LIBAPPFW_FOCUSWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** @file focuswidget.cpp Input focus indicator. | ||
* | ||
* @authors Copyright (c) 2016 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* LGPL: http://www.gnu.org/licenses/lgpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
* General Public License for more details. You should have received a copy of | ||
* the GNU Lesser General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "de/FocusWidget" | ||
|
||
#include <QTimer> | ||
|
||
namespace de { | ||
|
||
static TimeDelta FLASH_SPAN = .1; | ||
|
||
DENG2_PIMPL(FocusWidget) | ||
{ | ||
QTimer flashing; | ||
|
||
Instance(Public *i) : Base(i) | ||
{ | ||
self.set(Background(Background::GradientFrame, | ||
Style::get().colors().colorf("accent"), 6)); | ||
|
||
flashing.setInterval(FLASH_SPAN.asMilliSeconds()); | ||
flashing.setSingleShot(false); | ||
} | ||
|
||
void flash() | ||
{ | ||
if(self.opacity().target() == 0) | ||
{ | ||
self.setOpacity(.8f, FLASH_SPAN + .1, .1); | ||
} | ||
else if(self.opacity().target() > .5f) | ||
{ | ||
self.setOpacity(.2f, FLASH_SPAN); | ||
} | ||
else | ||
{ | ||
self.setOpacity(.8f, FLASH_SPAN); | ||
} | ||
} | ||
}; | ||
|
||
FocusWidget::FocusWidget(String const &name) | ||
: LabelWidget(name) | ||
, d(new Instance(this)) | ||
{ | ||
connect(&d->flashing, SIGNAL(timeout()), this, SLOT(updateFlash())); | ||
} | ||
|
||
void FocusWidget::startFlashing() | ||
{ | ||
setOpacity(0); | ||
show(); | ||
d->flashing.start(); | ||
} | ||
|
||
void FocusWidget::stopFlashing() | ||
{ | ||
d->flashing.stop(); | ||
hide(); | ||
} | ||
|
||
void FocusWidget::updateFlash() | ||
{ | ||
d->flash(); | ||
} | ||
|
||
} // namespace de | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.