From 9f60e7e5262a47694d8fcb238f9d11a3ba90d3a6 Mon Sep 17 00:00:00 2001 From: Till Theato Date: Fri, 15 Oct 2010 12:51:24 +0000 Subject: [PATCH] Add on-monitor GUI for c0rners effect. (Work in progress) svn path=/trunk/kdenlive/; revision=5007 --- effects/frei0r_c0rners.xml | 24 ++- effects/frei0r_curves.xml | 5 +- src/CMakeLists.txt | 3 + src/cornerswidget.cpp | 198 +++++++++++++++++++ src/cornerswidget.h | 94 +++++++++ src/effectstackedit.cpp | 34 ++++ src/geometrywidget.cpp | 2 +- src/geometrywidget.h | 2 + src/onmonitoritems/onmonitorcornersitem.cpp | 160 +++++++++++++++ src/onmonitoritems/onmonitorcornersitem.h | 54 +++++ src/widgets/cornerswidget_ui.ui | 206 ++++++++++++++++++++ 11 files changed, 770 insertions(+), 12 deletions(-) create mode 100644 src/cornerswidget.cpp create mode 100644 src/cornerswidget.h create mode 100644 src/onmonitoritems/onmonitorcornersitem.cpp create mode 100644 src/onmonitoritems/onmonitorcornersitem.h create mode 100644 src/widgets/cornerswidget_ui.ui diff --git a/effects/frei0r_c0rners.xml b/effects/frei0r_c0rners.xml index 49acb230..0b4de3a2 100644 --- a/effects/frei0r_c0rners.xml +++ b/effects/frei0r_c0rners.xml @@ -3,40 +3,44 @@ C0rners Four corners geometry engine Marko Cebokli - - + + + + Corners widget + + + Corner 1 X - + Corner 1 Y - + Corner 2 X - + Corner 2 Y - + Corner 3 X - + Corner 3 Y - + Corner 4 X - + Corner 4 Y - Enable Stretch diff --git a/effects/frei0r_curves.xml b/effects/frei0r_curves.xml index 69a29278..9e8d4d58 100644 --- a/effects/frei0r_curves.xml +++ b/effects/frei0r_curves.xml @@ -9,9 +9,12 @@ Luma formula - + + + Curve Widget + Number of curve points diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 367e0475..27e5e965 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,6 +103,7 @@ kde4_add_ui_files(kdenlive_UI widgets/geometrywidget_ui.ui widgets/stopmotion_ui.ui widgets/monitorscenecontrolwidget_ui.ui + widgets/cornerswidget_ui.ui ) set(kdenlive_SRCS @@ -229,7 +230,9 @@ set(kdenlive_SRCS stopmotion/stopmotion.cpp onmonitoritems/abstractonmonitoritem.cpp onmonitoritems/onmonitorrectitem.cpp + onmonitoritems/onmonitorcornersitem.cpp monitorscenecontrolwidget.cpp + cornerswidget.cpp ) diff --git a/src/cornerswidget.cpp b/src/cornerswidget.cpp new file mode 100644 index 00000000..c919ec4a --- /dev/null +++ b/src/cornerswidget.cpp @@ -0,0 +1,198 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "cornerswidget.h" +#include "monitor.h" +#include "monitorscene.h" +#include "monitorscenecontrolwidget.h" +#include "onmonitoritems/onmonitorcornersitem.h" +#include "renderer.h" + +#include +#include + +#include + +CornersWidget::CornersWidget(Monitor* monitor, int clipPos, bool isEffect, int factor, QWidget* parent) : + QWidget(parent), + m_monitor(monitor), + m_clipPos(clipPos), + m_inPoint(0), + m_outPoint(1), + m_isEffect(isEffect), + m_showScene(true), + m_factor(factor) +{ + m_ui.setupUi(this); + + m_scene = monitor->getEffectScene(); + + m_item = new OnMonitorCornersItem(m_scene); + m_scene->addItem(m_item); + + m_config = new MonitorSceneControlWidget(m_scene, m_ui.frameConfig); + QHBoxLayout *layout = new QHBoxLayout(m_ui.frameConfig); + layout->addWidget(m_config->getShowHideButton()); + layout->addWidget(m_config); + + int width = m_monitor->render->frameRenderWidth(); + int height = m_monitor->render->renderHeight(); + + m_ui.spinX1->setRange(-width, width * 2); + m_ui.spinX2->setRange(-width, width * 2); + m_ui.spinX3->setRange(-width, width * 2); + m_ui.spinX4->setRange(-width, width * 2); + m_ui.spinY1->setRange(-height, height * 2); + m_ui.spinY2->setRange(-height, height * 2); + m_ui.spinY3->setRange(-height, height * 2); + m_ui.spinY4->setRange(-height, height * 2); + + m_ui.toolReset1->setIcon(KIcon("edit-undo")); + m_ui.toolReset1->setToolTip(i18n("Reset Corner 1")); + m_ui.toolReset2->setIcon(KIcon("edit-undo")); + m_ui.toolReset2->setToolTip(i18n("Reset Corner 2")); + m_ui.toolReset3->setIcon(KIcon("edit-undo")); + m_ui.toolReset3->setToolTip(i18n("Reset Corner 3")); + m_ui.toolReset4->setIcon(KIcon("edit-undo")); + m_ui.toolReset4->setToolTip(i18n("Reset Corner 4")); + + connect(m_ui.spinX1, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + connect(m_ui.spinX2, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + connect(m_ui.spinX3, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + connect(m_ui.spinX4, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + connect(m_ui.spinY1, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + connect(m_ui.spinY2, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + connect(m_ui.spinY3, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + connect(m_ui.spinY4, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateItem())); + + connect(m_config, SIGNAL(showScene(bool)), this, SLOT(slotShowScene(bool))); + connect(m_monitor, SIGNAL(renderPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); + connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateProperties())); +} + +CornersWidget::~CornersWidget() +{ + delete m_config; + m_scene->removeItem(m_item); + delete m_item; + if (m_monitor) + m_monitor->slotEffectScene(false); +} + +void CornersWidget::setRange(int minframe, int maxframe) +{ + m_inPoint = minframe; + m_outPoint = maxframe; + slotCheckMonitorPosition(m_monitor->render->seekFramePosition()); +} + +void CornersWidget::slotUpdateItem() +{ + QPointF c1(m_ui.spinX1->value(), m_ui.spinY1->value()); + QPointF c2(m_ui.spinX2->value(), m_ui.spinY2->value()); + QPointF c3(m_ui.spinX3->value(), m_ui.spinY3->value()); + QPointF c4(m_ui.spinX4->value(), m_ui.spinY4->value()); + + m_item->setPolygon(QPolygonF() << c1 << c2 << c3 << c4); + + emit parameterChanged(); +} + +void CornersWidget::slotUpdateProperties(bool changed) +{ + QPolygon pol = m_item->polygon().toPolygon(); + blockSignals(true); + m_ui.spinX1->setValue(pol.at(0).x()); + m_ui.spinX2->setValue(pol.at(1).x()); + m_ui.spinX3->setValue(pol.at(2).x()); + m_ui.spinX4->setValue(pol.at(3).x()); + m_ui.spinY1->setValue(pol.at(0).y()); + m_ui.spinY2->setValue(pol.at(1).y()); + m_ui.spinY3->setValue(pol.at(2).y()); + m_ui.spinY4->setValue(pol.at(3).y()); + blockSignals(false); + + if (changed) + emit parameterChanged(); +} + + +QPolygon CornersWidget::getValue() +{ + qreal width = m_monitor->render->frameRenderWidth(); + qreal height = m_monitor->render->renderHeight(); + QPolygon corners = m_item->polygon().toPolygon(); + QPolygon points; + QPoint p; + for (int i = 0; i < 4; ++i) { + p = corners.at(i); + p.setX((p.x() / width + 1) / 3.0 * m_factor); + p.setY((p.y() / height + 1) / 3.0 * m_factor); + points << p; + } + return points; +} + +void CornersWidget::setValue(const QPolygon& points) +{ + int width = m_monitor->render->frameRenderWidth(); + int height = m_monitor->render->renderHeight(); + QPolygonF corners; + QPoint p; + for (int i = 0; i < 4; ++i) { + p = points.at(i); + p.setX((p.x() / (qreal)m_factor * 3 - 1) * width); + p.setY((p.y() / (qreal)m_factor * 3 - 1) * height); + corners << p; + } + m_item->setPolygon(corners); + + slotUpdateProperties(false); +} + +void CornersWidget::slotCheckMonitorPosition(int renderPos) +{ + if (m_showScene) { + /* + We do only get the position in timeline if this geometry belongs to a transition, + therefore we need two ways here. + */ + if (m_isEffect) { + emit checkMonitorPosition(renderPos); + } else { + if (renderPos >= m_clipPos && renderPos <= m_clipPos + m_outPoint - m_inPoint) { + if (!m_scene->views().at(0)->isVisible()) + m_monitor->slotEffectScene(true); + } else { + m_monitor->slotEffectScene(false); + } + } + } +} + +void CornersWidget::slotShowScene(bool show) +{ + m_showScene = show; + if (!m_showScene) + m_monitor->slotEffectScene(false); + else + slotCheckMonitorPosition(m_monitor->render->seekFramePosition()); +} + +#include "cornerswidget.moc" diff --git a/src/cornerswidget.h b/src/cornerswidget.h new file mode 100644 index 00000000..add06ae6 --- /dev/null +++ b/src/cornerswidget.h @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef CORNERSWIDGET_H +#define CORNERSWIDGET_H + +#include "ui_cornerswidget_ui.h" + +#include + +class QDomElement; +class Monitor; +class MonitorScene; +class OnMonitorCornersItem; +class MonitorSceneControlWidget; + + +class CornersWidget : public QWidget +{ + Q_OBJECT +public: + /** @brief Sets up the UI and connects it. + * @param monitor Project monitor + * @param clipPos Position of the clip in timeline + * @param isEffect true if used in an effect, false if used in a transition + * @param factor Factor by which the parameters differ from the range 0-1 + * @param parent (optional) Parent widget */ + CornersWidget(Monitor *monitor, int clipPos, bool isEffect, int factor, QWidget* parent = 0); + virtual ~CornersWidget(); + + /** @brief Returns a polygon representing the corners in the range 0 - factor. */ + QPolygon getValue(); + + /** @brief Takes a polygon @param points in the range 0 - factor and converts it into range (- frame width|height) - (2*frame width|height). */ + void setValue(const QPolygon &points); + + /** @brief Takes in and outpoint of the clip to know when to show the on-monitor scene. + * @param minframe In point of the clip + * @param maxframe Out point of the clip */ + void setRange(int minframe, int maxframe); + +private: + Ui::CornersWidget_UI m_ui; + Monitor *m_monitor; + /** Position of the clip in timeline. */ + int m_clipPos; + /** In point of the clip (crop from start). */ + int m_inPoint; + /** Out point of the clip (crop from end). */ + int m_outPoint; + bool m_isEffect; + MonitorScene *m_scene; + OnMonitorCornersItem *m_item; + bool m_showScene; + MonitorSceneControlWidget *m_config; + int m_factor; + +private slots: + /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible. + * @param renderPos Postion of the Monitor / Timeline cursor */ + void slotCheckMonitorPosition(int renderPos); + + /** @brief Switches from normal monitor to monitor scene according to @param show. */ + void slotShowScene(bool show = true); + + /** @brief Updates the on-monitor item according to the spinboxes. */ + void slotUpdateItem(); + /** @brief Updates the spinboxes according to the on-monitor item. + * @param changed (default = true) Whether to emit parameterChanged */ + void slotUpdateProperties(bool changed = true); + +signals: + void parameterChanged(); + void checkMonitorPosition(int); +}; + +#endif diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index 24bf4916..c127c3ab 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -33,6 +33,7 @@ #include "geometrywidget.h" #include "colortools.h" #include "doubleparameterwidget.h" +#include "cornerswidget.h" #include #include @@ -350,6 +351,28 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in QString depends = pa.attribute("depends"); if (!depends.isEmpty()) meetDependency(paramName, type, EffectsList::parameter(e, depends)); + } else if (type == "corners") { + CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this); + connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); + if (minFrame == maxFrame) + corners->setRange(m_in, m_out); + else + corners->setRange(minFrame, maxFrame); + + QString xName = pa.attribute("xpoints"); + QString yName = pa.attribute("ypoints"); + QPolygon points; + int x, y; + for (int j = 1; j <= 4; ++j) { + x = EffectsList::parameter(e, QString(xName).replace("%i", QString::number(j))).toInt(); + y = EffectsList::parameter(e, QString(yName).replace("%i", QString::number(j))).toInt(); + points << QPoint(x, y); + } + corners->setValue(points); + + m_vbox->addWidget(corners); + connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); + m_valueItems[paramName] = corners; } else if (type == "wipe") { Wipeval *wpval = new Wipeval; wpval->setupUi(toFillin); @@ -604,6 +627,17 @@ void EffectStackEdit::collectAllParameters() QString depends = pa.attributes().namedItem("depends").nodeValue(); if (!depends.isEmpty()) meetDependency(paramName, type, EffectsList::parameter(newparam, depends)); + } else if (type == "corners") { + CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName)); + QString xName = pa.attributes().namedItem("xpoints").nodeValue(); + QString yName = pa.attributes().namedItem("ypoints").nodeValue(); + QPolygon points = corners->getValue(); + QPoint p; + for (int j = 1; j <= 4; ++j) { + p = points.at(j - 1); + EffectsList::setParameter(newparam, QString(xName).replace("%i", QString::number(j)), QString::number(p.x())); + EffectsList::setParameter(newparam, QString(yName).replace("%i", QString::number(j)), QString::number(p.y())); + } } else if (type == "wipe") { Wipeval *wp = (Wipeval*)m_valueItems.value(paramName); wipeInfo info; diff --git a/src/geometrywidget.cpp b/src/geometrywidget.cpp index 157b9ad2..4fb69484 100644 --- a/src/geometrywidget.cpp +++ b/src/geometrywidget.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -141,6 +140,7 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, GeometryWidget::~GeometryWidget() { + m_scene->setEnabled(true); delete m_timePos; delete m_timeline; m_scene->removeItem(m_rect); diff --git a/src/geometrywidget.h b/src/geometrywidget.h index 8ffc0020..7c9fe33a 100644 --- a/src/geometrywidget.h +++ b/src/geometrywidget.h @@ -42,7 +42,9 @@ class GeometryWidget : public QWidget public: /** @brief Sets up the UI and connects it. * @param monitor Project monitor + * @param timecode Timecode needed by timecode display widget * @param clipPos Position of the clip in timeline + * @param isEffect true if used in an effect, false if used in a transition * @param parent (optional) Parent widget */ GeometryWidget(Monitor *monitor, Timecode timecode, int clipPos, bool isEffect, QWidget* parent = 0); virtual ~GeometryWidget(); diff --git a/src/onmonitoritems/onmonitorcornersitem.cpp b/src/onmonitoritems/onmonitorcornersitem.cpp new file mode 100644 index 00000000..419f6b60 --- /dev/null +++ b/src/onmonitoritems/onmonitorcornersitem.cpp @@ -0,0 +1,160 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "onmonitorcornersitem.h" +#include "kdenlivesettings.h" + +#include +#include +#include +#include + +OnMonitorCornersItem::OnMonitorCornersItem(MonitorScene* scene, QGraphicsItem* parent) : + AbstractOnMonitorItem(scene), + QGraphicsPolygonItem(parent) +{ + setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + + QPen framepen(Qt::SolidLine); + framepen.setColor(Qt::yellow); + setPen(framepen); + setBrush(Qt::transparent); +} + +cornersActions OnMonitorCornersItem::getMode(QPoint pos) +{ + /*pos = mapFromScene(pos).toPoint(); + // Item mapped coordinates + QPolygon pol(rect().normalized().toRect()); + + QPainterPath top(pol.point(0)); + top.lineTo(pol.point(1)); + QPainterPath bottom(pol.point(2)); + bottom.lineTo(pol.point(3)); + QPainterPath left(pol.point(0)); + left.lineTo(pol.point(3)); + QPainterPath right(pol.point(1)); + right.lineTo(pol.point(2)); + + QPainterPath mouseArea; + mouseArea.addRect(pos.x() - 4, pos.y() - 4, 8, 8); + + // Check for collisions between the mouse and the borders + if (mouseArea.contains(pol.point(0))) + return ResizeTopLeft; + else if (mouseArea.contains(pol.point(2))) + return ResizeBottomRight; + else if (mouseArea.contains(pol.point(1))) + return ResizeTopRight; + else if (mouseArea.contains(pol.point(3))) + return ResizeBottomLeft; + else if (top.intersects(mouseArea)) + return ResizeTop; + else if (bottom.intersects(mouseArea)) + return ResizeBottom; + else if (right.intersects(mouseArea)) + return ResizeRight; + else if (left.intersects(mouseArea)) + return ResizeLeft; + else if (rect().normalized().contains(pos)) + return Move; + else + return NoAction;*/ + return NoAction; +} + +void OnMonitorCornersItem::slotMousePressed(QGraphicsSceneMouseEvent* event) +{ + event->accept(); + + if (!isEnabled()) + return; + + m_clickPoint = event->scenePos(); + m_mode = getMode(m_clickPoint.toPoint()); +} + +void OnMonitorCornersItem::slotMouseMoved(QGraphicsSceneMouseEvent* event) +{ + event->accept(); + + if (!isEnabled()) { + emit requestCursor(QCursor(Qt::ArrowCursor)); + return; + } + + /*if (event->buttons() != Qt::NoButton && (event->screenPos() - m_screenClickPoint).manhattanLength() < QApplication::startDragDistance()) { + * event->accept(); + * return; + }*/ + + QPointF mousePos = event->scenePos(); + + if (event->buttons() & Qt::LeftButton) { + m_clickPoint = mousePos; + switch (m_mode) { + case Corner1: + + break; + case Corner2: + + break; + case Corner3: + + break; + case Corner4: + + break; + default: + break; + } + } else { + switch (getMode(event->scenePos().toPoint())) { + case NoAction: + emit requestCursor(QCursor(Qt::ArrowCursor)); + break; + default: + emit requestCursor(QCursor(Qt::OpenHandCursor)); + break; + } + } + if (m_modified && KdenliveSettings::monitorscene_directupdate()) { + emit actionFinished(); + m_modified = false; + } +} + +/*void OnMonitorRectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) +{ + Q_UNUSED(widget); + + painter->setPen(pen()); + painter->drawRect(option->rect); + + if (isEnabled()) { + double handleSize = 6 / painter->matrix().m11(); + double halfHandleSize = handleSize / 2; + painter->fillRect(-halfHandleSize, -halfHandleSize, handleSize, handleSize, QColor(Qt::yellow)); + painter->fillRect(option->rect.width() - halfHandleSize, -halfHandleSize, handleSize, handleSize, QColor(Qt::yellow)); + painter->fillRect(option->rect.width() - halfHandleSize, option->rect.height() - halfHandleSize, handleSize, handleSize, QColor(Qt::yellow)); + painter->fillRect(-halfHandleSize, option->rect.height() - halfHandleSize, handleSize, handleSize, QColor(Qt::yellow)); + } +}*/ + +#include "onmonitorcornersitem.moc" diff --git a/src/onmonitoritems/onmonitorcornersitem.h b/src/onmonitoritems/onmonitorcornersitem.h new file mode 100644 index 00000000..ed4ec288 --- /dev/null +++ b/src/onmonitoritems/onmonitorcornersitem.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef ONMONITORCORNERSITEM_H +#define ONMONITORCORNERSITEM_H + +#include "abstractonmonitoritem.h" + +#include +#include + +enum cornersActions { Corner1, Corner2, Corner3, Corner4, NoAction }; + +class OnMonitorCornersItem : public AbstractOnMonitorItem, public QGraphicsPolygonItem +{ + Q_OBJECT +public: + OnMonitorCornersItem(MonitorScene *scene, QGraphicsItem *parent = 0); + + /** @brief Gets The action mode for the area @param pos +- 4. */ + cornersActions getMode(QPoint pos); + + /** @brief Reimplemented to draw the handles. */ + //virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); + +public slots: + /** @brief Saves current mouse position and mode. */ + void slotMousePressed(QGraphicsSceneMouseEvent *event); + /** @brief Modifies item according to mouse position and mode. */ + void slotMouseMoved(QGraphicsSceneMouseEvent *event); + +private: + cornersActions m_mode; + QPointF m_clickPoint; +}; + +#endif diff --git a/src/widgets/cornerswidget_ui.ui b/src/widgets/cornerswidget_ui.ui new file mode 100644 index 00000000..06d97943 --- /dev/null +++ b/src/widgets/cornerswidget_ui.ui @@ -0,0 +1,206 @@ + + + CornersWidget_UI + + + + 0 + 0 + 291 + 184 + + + + Form + + + + + + + 75 + true + + + + Corner + + + + + + + + 75 + true + + + + X + + + + + + + + 75 + true + + + + Y + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + 3 + + + + + + + 4 + + + + + + + false + + + ... + + + true + + + + + + + false + + + ... + + + true + + + + + + + false + + + ... + + + true + + + + + + + false + + + ... + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 10 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + -- 2.39.2