aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-glwidgets/glw-widget.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-09-26 23:50:24 -0400
committerKen Moore <ken@ixsystems.com>2017-09-26 23:50:24 -0400
commit823e3aa950cf52eb4902a70e606f073af3c92795 (patch)
tree3e98794fde3856db638134635fc85ecc8e81305b /src-qt5/src-glwidgets/glw-widget.cpp
parentUpdate some more of the GL widget set and the test (diff)
downloadlumina-823e3aa950cf52eb4902a70e606f073af3c92795.tar.gz
lumina-823e3aa950cf52eb4902a70e606f073af3c92795.tar.bz2
lumina-823e3aa950cf52eb4902a70e606f073af3c92795.zip
More updates for the GL widget set.
Now all the mouse tracking/hovering is working - with one exception: All the mouse hover detection is based around mouse **movement** - so programmatic changes to a window will not detect the change in what is directly under the mouse without manual intervention in the code.
Diffstat (limited to 'src-qt5/src-glwidgets/glw-widget.cpp')
-rw-r--r--src-qt5/src-glwidgets/glw-widget.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src-qt5/src-glwidgets/glw-widget.cpp b/src-qt5/src-glwidgets/glw-widget.cpp
index d07c0431..e6c98d74 100644
--- a/src-qt5/src-glwidgets/glw-widget.cpp
+++ b/src-qt5/src-glwidgets/glw-widget.cpp
@@ -10,7 +10,6 @@
// --- PUBLIC ---
GLW_Widget::GLW_Widget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){
glw_base = 0;
- this->setMouseTracking(true);
draggable = false;
drag_offset = QPoint();
}
@@ -25,10 +24,7 @@ QRect GLW_Widget::widgetRect(){
}
bool GLW_Widget::mouseOverWidget(){
- QPoint pos = this->mapFromGlobal(QCursor::pos());
- QRect geom(QPoint(0,0), this->size());
- return geom.contains(pos) || (draggable && !drag_offset.isNull());
-
+ return (glw_base->mouseOverWidget()==this);
}
void GLW_Widget::setGLBase(GLW_Base *base){
@@ -63,6 +59,16 @@ void GLW_Widget::paintChildren(QStylePainter *painter, QPaintEvent *ev){
// --- PROTECTED ---
+void GLW_Widget::enterEvent(QEvent*){
+ if(!mouseOverWidget()){ glw_base->setMouseOverWidget(this); }
+ this->update();
+}
+
+void GLW_Widget::leaveEvent(QEvent*){
+ if(mouseOverWidget()){ glw_base->setMouseOverWidget(0); }
+ this->update();
+}
+
void GLW_Widget::mousePressEvent(QMouseEvent *ev){
if(!draggable){ QWidget::mousePressEvent(ev); return; }
if(ev->button()==Qt::LeftButton){
@@ -78,6 +84,7 @@ void GLW_Widget::mouseReleaseEvent(QMouseEvent *ev){
}
void GLW_Widget::mouseMoveEvent(QMouseEvent *ev){
+ if(!mouseOverWidget()){ glw_base->setMouseOverWidget(this); }
if(!draggable){ QWidget::mouseMoveEvent(ev); return; }
if(!drag_offset.isNull()){
this->move( this->mapTo(glw_base, ev->pos()-drag_offset) );
bgstack15