2012-07-27 05:58:21 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2012 Filip Wieladek <wattos@gmail.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "mouseclick.h"
|
2012-10-26 07:32:08 +00:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "mouseclickconfig.h"
|
2012-07-27 05:58:21 +00:00
|
|
|
|
2013-08-14 19:13:12 +00:00
|
|
|
#include <QAction>
|
2012-07-27 05:58:21 +00:00
|
|
|
#include <kwinglutils.h>
|
|
|
|
|
2012-11-02 19:49:09 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
|
|
#include <kwinxrenderutils.h>
|
2013-02-08 17:02:26 +00:00
|
|
|
#include <xcb/xcb.h>
|
|
|
|
#include <xcb/render.h>
|
2012-11-02 19:49:09 +00:00
|
|
|
#endif
|
|
|
|
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KGlobalAccel>
|
2012-07-27 05:58:21 +00:00
|
|
|
|
2013-06-21 13:52:44 +00:00
|
|
|
#include <QPainter>
|
|
|
|
|
2019-07-09 19:19:26 +00:00
|
|
|
#include <cmath>
|
2012-07-27 05:58:21 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
MouseClickEffect::MouseClickEffect()
|
|
|
|
{
|
2016-12-02 19:27:43 +00:00
|
|
|
initConfig<MouseClickConfig>();
|
2012-07-27 05:58:21 +00:00
|
|
|
m_enabled = false;
|
2013-08-14 19:13:12 +00:00
|
|
|
|
2013-12-10 10:45:33 +00:00
|
|
|
QAction* a = new QAction(this);
|
|
|
|
a->setObjectName(QStringLiteral("ToggleMouseClick"));
|
2014-06-24 07:39:03 +00:00
|
|
|
a->setText(i18n("Toggle Mouse Click Effect"));
|
2013-08-14 19:13:12 +00:00
|
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Asterisk);
|
|
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Asterisk);
|
2013-07-10 10:26:50 +00:00
|
|
|
effects->registerGlobalShortcut(Qt::META + Qt::Key_Asterisk, a);
|
2019-01-01 20:48:53 +00:00
|
|
|
connect(a, &QAction::triggered, this, &MouseClickEffect::toggleEnabled);
|
2013-08-14 19:13:12 +00:00
|
|
|
|
2012-07-27 05:58:21 +00:00
|
|
|
reconfigure(ReconfigureAll);
|
|
|
|
|
2015-04-17 12:56:58 +00:00
|
|
|
m_buttons[0] = new MouseButton(i18nc("Left mouse button", "Left"), Qt::LeftButton);
|
|
|
|
m_buttons[1] = new MouseButton(i18nc("Middle mouse button", "Middle"), Qt::MiddleButton);
|
|
|
|
m_buttons[2] = new MouseButton(i18nc("Right mouse button", "Right"), Qt::RightButton);
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseClickEffect::~MouseClickEffect()
|
|
|
|
{
|
2013-01-21 23:29:55 +00:00
|
|
|
if (m_enabled)
|
|
|
|
effects->stopMousePolling();
|
2015-03-25 00:02:24 +00:00
|
|
|
qDeleteAll(m_clicks);
|
2012-07-27 05:58:21 +00:00
|
|
|
m_clicks.clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < BUTTON_COUNT; ++i) {
|
|
|
|
delete m_buttons[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::reconfigure(ReconfigureFlags)
|
|
|
|
{
|
2014-03-25 15:29:03 +00:00
|
|
|
MouseClickConfig::self()->read();
|
2012-10-26 07:32:08 +00:00
|
|
|
m_colors[0] = MouseClickConfig::color1();
|
|
|
|
m_colors[1] = MouseClickConfig::color2();
|
|
|
|
m_colors[2] = MouseClickConfig::color3();
|
|
|
|
m_lineWidth = MouseClickConfig::lineWidth();
|
|
|
|
m_ringLife = MouseClickConfig::ringLife();
|
|
|
|
m_ringMaxSize = MouseClickConfig::ringSize();
|
|
|
|
m_ringCount = MouseClickConfig::ringCount();
|
|
|
|
m_showText = MouseClickConfig::showText();
|
|
|
|
m_font = MouseClickConfig::font();
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
foreach (MouseEvent* click, m_clicks) {
|
|
|
|
click->m_time += time;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < BUTTON_COUNT; ++i) {
|
|
|
|
if (m_buttons[i]->m_isPressed) {
|
|
|
|
m_buttons[i]->m_time += time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (m_clicks.size() > 0) {
|
|
|
|
MouseEvent* first = m_clicks[0];
|
|
|
|
if (first->m_time <= m_ringLife) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_clicks.pop_front();
|
|
|
|
delete first;
|
|
|
|
}
|
|
|
|
|
|
|
|
effects->prePaintScreen(data, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
|
|
|
effects->paintScreen(mask, region, data);
|
|
|
|
|
|
|
|
paintScreenSetup(mask, region, data);
|
|
|
|
foreach (const MouseEvent* click, m_clicks) {
|
|
|
|
for (int i = 0; i < m_ringCount; ++i) {
|
|
|
|
float alpha = computeAlpha(click, i);
|
|
|
|
float size = computeRadius(click, i);
|
|
|
|
if (size > 0 && alpha > 0) {
|
|
|
|
QColor color = m_colors[click->m_button];
|
|
|
|
color.setAlphaF(alpha);
|
|
|
|
drawCircle(color, click->m_pos.x(), click->m_pos.y(), size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_showText && click->m_frame) {
|
|
|
|
float frameAlpha = (click->m_time * 2.0f - m_ringLife) / m_ringLife;
|
|
|
|
frameAlpha = frameAlpha < 0 ? 1 : -(frameAlpha * frameAlpha) + 1;
|
|
|
|
click->m_frame->render(infiniteRegion(), frameAlpha, frameAlpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paintScreenFinish(mask, region, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::postPaintScreen()
|
|
|
|
{
|
|
|
|
effects->postPaintScreen();
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
float MouseClickEffect::computeRadius(const MouseEvent* click, int ring)
|
|
|
|
{
|
|
|
|
float ringDistance = m_ringLife / (m_ringCount * 3);
|
|
|
|
if (click->m_press) {
|
|
|
|
return ((click->m_time - ringDistance * ring) / m_ringLife) * m_ringMaxSize;
|
|
|
|
}
|
|
|
|
return ((m_ringLife - click->m_time - ringDistance * ring) / m_ringLife) * m_ringMaxSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
float MouseClickEffect::computeAlpha(const MouseEvent* click, int ring)
|
|
|
|
{
|
|
|
|
float ringDistance = m_ringLife / (m_ringCount * 3);
|
|
|
|
return (m_ringLife - (float)click->m_time - ringDistance * (ring)) / m_ringLife;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::slotMouseChanged(const QPoint& pos, const QPoint&,
|
|
|
|
Qt::MouseButtons buttons, Qt::MouseButtons oldButtons,
|
|
|
|
Qt::KeyboardModifiers, Qt::KeyboardModifiers)
|
|
|
|
{
|
2013-02-10 05:56:38 +00:00
|
|
|
if (buttons == oldButtons)
|
|
|
|
return;
|
|
|
|
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
MouseEvent* m = nullptr;
|
2015-03-25 00:02:24 +00:00
|
|
|
int i = BUTTON_COUNT;
|
|
|
|
while (--i >= 0) {
|
2012-07-27 05:58:21 +00:00
|
|
|
MouseButton* b = m_buttons[i];
|
|
|
|
if (isPressed(b->m_button, buttons, oldButtons)) {
|
|
|
|
m = new MouseEvent(i, pos, 0, createEffectFrame(pos, b->m_labelDown), true);
|
2015-03-25 00:02:24 +00:00
|
|
|
break;
|
2013-02-10 05:56:38 +00:00
|
|
|
} else if (isReleased(b->m_button, buttons, oldButtons) && (!b->m_isPressed || b->m_time > m_ringLife)) {
|
|
|
|
// we might miss a press, thus also check !b->m_isPressed, bug #314762
|
2012-07-27 05:58:21 +00:00
|
|
|
m = new MouseEvent(i, pos, 0, createEffectFrame(pos, b->m_labelUp), false);
|
2015-03-25 00:02:24 +00:00
|
|
|
break;
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
b->setPressed(b->m_button & buttons);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m) {
|
|
|
|
m_clicks.append(m);
|
|
|
|
}
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectFrame* MouseClickEffect::createEffectFrame(const QPoint& pos, const QString& text) {
|
|
|
|
if (!m_showText) {
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
return nullptr;
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
QPoint point(pos.x() + m_ringMaxSize, pos.y());
|
|
|
|
EffectFrame* frame = effects->effectFrame(EffectFrameStyled, false, point, Qt::AlignLeft);
|
|
|
|
frame->setFont(m_font);
|
|
|
|
frame->setText(text);
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::repaint()
|
|
|
|
{
|
|
|
|
if (m_clicks.size() > 0) {
|
2013-10-12 09:47:31 +00:00
|
|
|
QRegion dirtyRegion;
|
|
|
|
const int radius = m_ringMaxSize + m_lineWidth;
|
2012-07-27 05:58:21 +00:00
|
|
|
foreach (MouseEvent* click, m_clicks) {
|
2013-10-12 09:47:31 +00:00
|
|
|
dirtyRegion |= QRect(click->m_pos.x() - radius, click->m_pos.y() - radius, 2*radius, 2*radius);
|
2012-10-26 07:36:51 +00:00
|
|
|
if (click->m_frame) {
|
2013-10-12 09:47:31 +00:00
|
|
|
// we grant the plasma style 32px padding for stuff like shadows...
|
|
|
|
dirtyRegion |= click->m_frame->geometry().adjusted(-32,-32,32,32);
|
2012-10-26 07:36:51 +00:00
|
|
|
}
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
2013-10-12 09:47:31 +00:00
|
|
|
effects->addRepaint(dirtyRegion);
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MouseClickEffect::isReleased(Qt::MouseButtons button, Qt::MouseButtons buttons, Qt::MouseButtons oldButtons)
|
|
|
|
{
|
|
|
|
return !(button & buttons) && (button & oldButtons);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MouseClickEffect::isPressed(Qt::MouseButtons button, Qt::MouseButtons buttons, Qt::MouseButtons oldButtons)
|
|
|
|
{
|
|
|
|
return (button & buttons) && !(button & oldButtons);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::toggleEnabled()
|
|
|
|
{
|
|
|
|
m_enabled = !m_enabled;
|
2013-11-24 17:36:14 +00:00
|
|
|
|
|
|
|
if (m_enabled) {
|
2019-01-01 20:48:53 +00:00
|
|
|
connect(effects, &EffectsHandler::mouseChanged, this, &MouseClickEffect::slotMouseChanged);
|
2013-11-24 17:36:14 +00:00
|
|
|
effects->startMousePolling();
|
|
|
|
} else {
|
2019-01-01 20:48:53 +00:00
|
|
|
disconnect(effects, &EffectsHandler::mouseChanged, this, &MouseClickEffect::slotMouseChanged);
|
2013-11-24 17:36:14 +00:00
|
|
|
effects->stopMousePolling();
|
|
|
|
}
|
|
|
|
|
2015-03-25 00:02:24 +00:00
|
|
|
qDeleteAll(m_clicks);
|
2012-07-27 05:58:21 +00:00
|
|
|
m_clicks.clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < BUTTON_COUNT; ++i) {
|
|
|
|
m_buttons[i]->m_time = 0;
|
|
|
|
m_buttons[i]->m_isPressed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MouseClickEffect::isActive() const
|
|
|
|
{
|
|
|
|
return m_enabled && (m_clicks.size() > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::drawCircle(const QColor& color, float cx, float cy, float r)
|
|
|
|
{
|
2012-11-02 19:49:09 +00:00
|
|
|
if (effects->isOpenGLCompositing())
|
|
|
|
drawCircleGl(color, cx, cy, r);
|
|
|
|
if (effects->compositingType() == XRenderCompositing)
|
|
|
|
drawCircleXr(color, cx, cy, r);
|
2013-06-21 13:52:44 +00:00
|
|
|
if (effects->compositingType() == QPainterCompositing)
|
|
|
|
drawCircleQPainter(color, cx, cy, r);
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::paintScreenSetup(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
2012-11-02 19:49:09 +00:00
|
|
|
if (effects->isOpenGLCompositing())
|
|
|
|
paintScreenSetupGl(mask, region, data);
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::paintScreenFinish(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
2012-11-02 19:49:09 +00:00
|
|
|
if (effects->isOpenGLCompositing())
|
|
|
|
paintScreenFinishGl(mask, region, data);
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::drawCircleGl(const QColor& color, float cx, float cy, float r)
|
|
|
|
{
|
2014-09-27 18:30:49 +00:00
|
|
|
static const int num_segments = 80;
|
|
|
|
static const float theta = 2 * 3.1415926 / float(num_segments);
|
|
|
|
static const float c = cosf(theta); //precalculate the sine and cosine
|
|
|
|
static const float s = sinf(theta);
|
2012-07-27 05:58:21 +00:00
|
|
|
float t;
|
|
|
|
|
|
|
|
float x = r;//we start at angle = 0
|
|
|
|
float y = 0;
|
|
|
|
|
|
|
|
GLVertexBuffer* vbo = GLVertexBuffer::streamingBuffer();
|
|
|
|
vbo->reset();
|
|
|
|
vbo->setUseColor(true);
|
|
|
|
vbo->setColor(color);
|
|
|
|
QVector<float> verts;
|
|
|
|
verts.reserve(num_segments * 2);
|
|
|
|
|
|
|
|
for (int ii = 0; ii < num_segments; ++ii) {
|
|
|
|
verts << x + cx << y + cy;//output vertex
|
|
|
|
//apply the rotation matrix
|
|
|
|
t = x;
|
|
|
|
x = c * x - s * y;
|
|
|
|
y = s * t + c * y;
|
|
|
|
}
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
vbo->setData(verts.size() / 2, 2, verts.data(), nullptr);
|
2012-07-27 05:58:21 +00:00
|
|
|
vbo->render(GL_LINE_LOOP);
|
|
|
|
}
|
|
|
|
|
2012-11-02 19:49:09 +00:00
|
|
|
void MouseClickEffect::drawCircleXr(const QColor& color, float cx, float cy, float r)
|
|
|
|
{
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2013-02-08 17:02:26 +00:00
|
|
|
if (r <= m_lineWidth)
|
2012-11-02 19:49:09 +00:00
|
|
|
return;
|
2013-02-08 17:02:26 +00:00
|
|
|
|
|
|
|
int num_segments = r+8;
|
|
|
|
float theta = 2.0 * 3.1415926 / num_segments;
|
|
|
|
float cos = cosf(theta); //precalculate the sine and cosine
|
|
|
|
float sin = sinf(theta);
|
|
|
|
float x[2] = {r, r-m_lineWidth};
|
|
|
|
float y[2] = {0, 0};
|
|
|
|
|
|
|
|
#define DOUBLE_TO_FIXED(d) ((xcb_render_fixed_t) ((d) * 65536))
|
|
|
|
QVector<xcb_render_pointfix_t> strip;
|
|
|
|
strip.reserve(2*num_segments+2);
|
|
|
|
|
|
|
|
xcb_render_pointfix_t point;
|
|
|
|
point.x = DOUBLE_TO_FIXED(x[1]+cx);
|
|
|
|
point.y = DOUBLE_TO_FIXED(y[1]+cy);
|
|
|
|
strip << point;
|
|
|
|
|
|
|
|
for (int i = 0; i < num_segments; ++i) {
|
|
|
|
//apply the rotation matrix
|
|
|
|
const float h[2] = {x[0], x[1]};
|
|
|
|
x[0] = cos * x[0] - sin * y[0];
|
|
|
|
x[1] = cos * x[1] - sin * y[1];
|
|
|
|
y[0] = sin * h[0] + cos * y[0];
|
|
|
|
y[1] = sin * h[1] + cos * y[1];
|
|
|
|
|
|
|
|
point.x = DOUBLE_TO_FIXED(x[0]+cx);
|
|
|
|
point.y = DOUBLE_TO_FIXED(y[0]+cy);
|
|
|
|
strip << point;
|
|
|
|
|
|
|
|
point.x = DOUBLE_TO_FIXED(x[1]+cx);
|
|
|
|
point.y = DOUBLE_TO_FIXED(y[1]+cy);
|
|
|
|
strip << point;
|
2012-11-02 19:49:09 +00:00
|
|
|
}
|
2013-02-08 17:02:26 +00:00
|
|
|
|
|
|
|
const float h = x[0];
|
|
|
|
x[0] = cos * x[0] - sin * y[0];
|
|
|
|
y[0] = sin * h + cos * y[0];
|
|
|
|
|
|
|
|
point.x = DOUBLE_TO_FIXED(x[0]+cx);
|
|
|
|
point.y = DOUBLE_TO_FIXED(y[0]+cy);
|
|
|
|
strip << point;
|
|
|
|
|
|
|
|
XRenderPicture fill = xRenderFill(color);
|
2014-04-16 13:58:06 +00:00
|
|
|
xcb_render_tri_strip(xcbConnection(), XCB_RENDER_PICT_OP_OVER,
|
2013-02-08 17:02:26 +00:00
|
|
|
fill, effects->xrenderBufferPicture(), 0,
|
|
|
|
0, 0, strip.count(), strip.constData());
|
|
|
|
#undef DOUBLE_TO_FIXED
|
2013-02-21 17:21:46 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(color)
|
|
|
|
Q_UNUSED(cx)
|
|
|
|
Q_UNUSED(cy)
|
|
|
|
Q_UNUSED(r)
|
2012-11-02 19:49:09 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-06-21 13:52:44 +00:00
|
|
|
void MouseClickEffect::drawCircleQPainter(const QColor &color, float cx, float cy, float r)
|
|
|
|
{
|
|
|
|
QPainter *painter = effects->scenePainter();
|
|
|
|
painter->save();
|
|
|
|
painter->setPen(color);
|
|
|
|
painter->drawArc(cx - r, cy - r, r * 2, r * 2, 0, 5760);
|
|
|
|
painter->restore();
|
|
|
|
}
|
|
|
|
|
2015-11-27 08:50:39 +00:00
|
|
|
void MouseClickEffect::paintScreenSetupGl(int, QRegion, ScreenPaintData &data)
|
2012-07-27 05:58:21 +00:00
|
|
|
{
|
2015-11-27 08:50:39 +00:00
|
|
|
GLShader *shader = ShaderManager::instance()->pushShader(ShaderTrait::UniformColor);
|
|
|
|
shader->setUniform(GLShader::ModelViewProjectionMatrix, data.projectionMatrix());
|
2012-07-27 05:58:21 +00:00
|
|
|
|
|
|
|
glLineWidth(m_lineWidth);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MouseClickEffect::paintScreenFinishGl(int, QRegion, ScreenPaintData&)
|
|
|
|
{
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
2014-02-25 10:02:32 +00:00
|
|
|
ShaderManager::instance()->popShader();
|
2012-07-27 05:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|