Ticket #791: new_ui_mouse_support.diff
File new_ui_mouse_support.diff, 5.8 KB (added by , 18 years ago) |
---|
-
mythmainwindow.cpp
29 29 30 30 //#include "screensaver.h" 31 31 32 #include "mythstroke.h" 33 32 34 #ifdef USE_LIRC 33 35 static void *SpawnLirc(void *param) 34 36 { … … 127 129 128 130 bool AllowInput; 129 131 132 MythStroke stroker; 133 130 134 QRegion repaintRegion; 131 135 }; 132 136 … … 197 201 d->escapekey = Key_Escape; 198 202 d->mainStack = NULL; 199 203 204 installEventFilter(this); 205 200 206 #ifdef USE_LIRC 201 207 pthread_t lirc_tid; 202 208 pthread_attr_t attr; … … 724 730 d->AllowInput = allow; 725 731 } 726 732 727 void MythMainWindow::keyPressEvent(QKeyEvent *e)733 bool MythMainWindow::eventFilter(QObject *o, QEvent *e) 728 734 { 735 736 MythGestureEvent *ge; 737 738 /* dont let anything through if input is disallowed. */ 729 739 if (!d->AllowInput) 730 return ;740 return true; 731 741 732 QValueVector<MythScreenStack *>::Iterator it;733 for (it = d->stackList.begin(); it != d->stackList.end(); ++it)742 /* filter mouse events */ 743 switch (e->type()) 734 744 { 735 MythScreenType *top = (*it)->GetTopScreen(); 736 if (top) 737 { 738 if (top->keyPressEvent(e)) 739 break; 740 } 745 case QEvent::KeyPress: 746 747 QValueVector<MythScreenStack *>::Iterator it; 748 for (it = d->stackList.begin(); it != d->stackList.end(); ++it) 749 { 750 MythScreenType *top = (*it)->GetTopScreen(); 751 if (top) 752 { 753 if (top->keyPressEvent(dynamic_cast<QKeyEvent*>(e))) 754 return true; 755 } 756 } 757 break; 758 759 case QEvent::MouseButtonPress: 760 761 d->stroker.start(); 762 d->stroker.record(dynamic_cast<QMouseEvent*>(e)->pos()); 763 return true; 764 765 case QEvent::MouseButtonRelease: 766 767 ge = d->stroker.complete(); 768 769 /* handle clicks separately */ 770 if (ge->gesture() == MythGestureEvent::Click) 771 { 772 MythUIType *clicked; 773 QValueVector<MythScreenStack *>::iterator it; 774 QPoint p = dynamic_cast<QMouseEvent*>(e)->pos(); 775 776 delete ge; 777 778 for (it = d->stackList.begin(); it != d->stackList.end(); it++) 779 { 780 MythScreenType *screen = (*it)->GetTopScreen(); 781 if ((clicked = screen->GetChildAt(p)) != NULL) 782 { 783 cout << "UI Type: " << clicked->name() << endl; 784 break; 785 } 786 } 787 } 788 else QApplication::postEvent(this, ge); 789 790 return true; 791 792 case QEvent::MouseMove: 793 794 d->stroker.record(dynamic_cast<QMouseEvent*>(e)->pos()); 795 return true; 796 797 default: 798 break; 741 799 } 800 801 return false; 742 802 } 743 803 744 void MythMainWindow::customEvent(QCustomEvent* /* ce */)804 void MythMainWindow::customEvent(QCustomEvent* ce) 745 805 { 806 807 if (ce->type() == MythGestureEventType) 808 { 809 MythGestureEvent *ge = dynamic_cast<MythGestureEvent*>(ce); 810 if (ge != NULL) 811 { 812 cout << "Gesture: " << QString(*ge) << endl; 813 } 814 } 815 816 746 817 #if 0 747 818 if (ce->type() == kExitToMainMenuEventType && d->exitingtomain) 748 819 { -
mythuitype.cpp
82 82 return &m_ChildrenList; 83 83 } 84 84 85 MythUIType *MythUIType::GetChildAt(const QPoint &p) 86 { 87 if (GetArea().contains(p)) { 88 89 /* assumes no selectible ui type will contain another 90 * selectible ui type. */ 91 if (CanTakeFocus() && IsVisible()) return this; 92 93 /* check all children */ 94 QValueVector<MythUIType*>::iterator it; 95 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) 96 { 97 MythUIType *child = (*it)->GetChildAt(p - GetArea().topLeft()); 98 if (child != NULL) 99 { 100 return child; 101 } 102 } 103 } 104 return NULL; 105 } 106 85 107 bool MythUIType::NeedsRedraw(void) 86 108 { 87 109 return m_NeedsRedraw; -
mythmainwindow.h
89 89 protected: 90 90 MythMainWindow(); 91 91 92 void keyPressEvent(QKeyEvent *e);92 bool eventFilter(QObject *o, QEvent *e); 93 93 void customEvent(QCustomEvent *ce); 94 94 void closeEvent(QCloseEvent *e); 95 95 void paintEvent(QPaintEvent *e); -
libmythui.pro
28 28 SOURCES += mythscreenstack.cpp mythscreentype.cpp 29 29 SOURCES += mythuitype.cpp mythuiimage.cpp mythuitext.cpp 30 30 SOURCES += mythuistatetype.cpp mythlistbutton.cpp mythfontproperties.cpp 31 SOURCES += mythuibutton.cpp themedmenu.cpp dialogbox.cpp 31 SOURCES += mythuibutton.cpp themedmenu.cpp dialogbox.cpp mythstroke.cpp 32 32 33 33 inc.path = $${PREFIX}/include/mythui/ 34 34 … … 36 36 inc.files += mythpainter_ogl.h mythpainter_qt.h mythuistatetype.h 37 37 inc.files += mythscreenstack.h mythscreentype.h mythuitype.h mythuiimage.h 38 38 inc.files += mythuitext.h mythuibutton.h mythlistbutton.h 39 inc.files += themedmenu.h dialogbox.h mythfontproperties.h 39 inc.files += themedmenu.h dialogbox.h mythfontproperties.h mythstroke.h 40 40 41 41 INSTALLS += inc 42 42 -
mythuitype.h
25 25 void AddChild(MythUIType *child); 26 26 MythUIType *GetChild(const char *name, const char *inherits = 0); 27 27 QValueVector<MythUIType *> *GetAllChildren(void); 28 MythUIType *GetChildAt(const QPoint &p); 28 29 29 30 // Check set dirty status 30 31 bool NeedsRedraw(void);