|
41 | 41 | OutputWindow::OutputWindow() : PatchObject("output window"){ |
42 | 42 |
|
43 | 43 | this->numInlets = 2; |
44 | | - this->numOutlets = 0; |
| 44 | + this->numOutlets = 1; |
45 | 45 |
|
46 | 46 | _inletParams[0] = new ofTexture(); // projector |
47 | 47 | _inletParams[1] = new LiveCoding(); // script reference |
48 | 48 |
|
| 49 | + _outletParams[0] = new vector<float>(); // mouse |
| 50 | + |
49 | 51 | this->specialLinkTypeName = "LiveCoding"; |
50 | 52 |
|
51 | 53 | this->initInletsState(); |
@@ -91,6 +93,8 @@ void OutputWindow::newObject(){ |
91 | 93 | this->addInlet(VP_LINK_TEXTURE,"projector"); |
92 | 94 | this->addInlet(VP_LINK_SPECIAL,"script"); |
93 | 95 |
|
| 96 | + this->addOutlet(VP_LINK_ARRAY,"mouse"); |
| 97 | + |
94 | 98 | this->setCustomVar(static_cast<float>(isFullscreen),"FULLSCREEN"); |
95 | 99 | this->setCustomVar(static_cast<float>(this->output_width),"OUTPUT_WIDTH"); |
96 | 100 | this->setCustomVar(static_cast<float>(this->output_height),"OUTPUT_HEIGHT"); |
@@ -159,6 +163,9 @@ void OutputWindow::setupObjectContent(shared_ptr<ofAppGLFWWindow> &mainWindow){ |
159 | 163 | window_asRatio = reduceToAspectRatio(window->getWidth(),window->getHeight()); |
160 | 164 | scaleTextureToWindow(window->getWidth(),window->getHeight()); |
161 | 165 |
|
| 166 | + // init outlet mouse data |
| 167 | + static_cast<vector<float> *>(_outletParams[0])->assign(3,0.0f); |
| 168 | + |
162 | 169 | } |
163 | 170 |
|
164 | 171 | //-------------------------------------------------------------- |
@@ -668,64 +675,87 @@ void OutputWindow::mouseMoved(ofMouseEventArgs &e){ |
668 | 675 | warpController->onMouseMoved(window->events().getMouseX(),window->events().getMouseY()); |
669 | 676 | } |
670 | 677 |
|
| 678 | + ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
671 | 679 | if(this->inletsConnected[0] && this->inletsConnected[1] && _inletParams[1] != nullptr && static_cast<ofTexture *>(_inletParams[0])->isAllocated()){ |
672 | | - ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
673 | 680 | if(static_cast<LiveCoding *>(_inletParams[1])->lua.isValid()){ |
674 | 681 | static_cast<LiveCoding *>(_inletParams[1])->lua.scriptMouseMoved(static_cast<int>(tm.x),static_cast<int>(tm.y)); |
675 | 682 | } |
676 | 683 | } |
| 684 | + |
| 685 | + static_cast<vector<float> *>(_outletParams[0])->at(0) = tm.x; |
| 686 | + static_cast<vector<float> *>(_outletParams[0])->at(1) = tm.y; |
| 687 | + static_cast<vector<float> *>(_outletParams[0])->at(2) = e.button; |
| 688 | + |
677 | 689 | } |
678 | 690 |
|
679 | 691 | //-------------------------------------------------------------- |
680 | 692 | void OutputWindow::mouseDragged(ofMouseEventArgs &e){ |
681 | 693 | if(this->inletsConnected[0] && static_cast<ofTexture *>(_inletParams[0])->isAllocated() && isFullscreen){ |
682 | 694 | warpController->onMouseDragged(window->events().getMouseX(),window->events().getMouseY()); |
683 | 695 | } |
| 696 | + |
| 697 | + ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
684 | 698 | if(this->inletsConnected[0] && this->inletsConnected[1] && _inletParams[1] != nullptr && static_cast<ofTexture *>(_inletParams[0])->isAllocated()){ |
685 | | - ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
686 | 699 | if(static_cast<LiveCoding *>(_inletParams[1])->lua.isValid()){ |
687 | 700 | static_cast<LiveCoding *>(_inletParams[1])->lua.scriptMouseDragged(static_cast<int>(tm.x),static_cast<int>(tm.y), e.button); |
688 | 701 | } |
689 | 702 | } |
| 703 | + |
| 704 | + static_cast<vector<float> *>(_outletParams[0])->at(0) = tm.x; |
| 705 | + static_cast<vector<float> *>(_outletParams[0])->at(1) = tm.y; |
| 706 | + static_cast<vector<float> *>(_outletParams[0])->at(2) = e.button; |
690 | 707 | } |
691 | 708 |
|
692 | 709 | //-------------------------------------------------------------- |
693 | 710 | void OutputWindow::mousePressed(ofMouseEventArgs &e){ |
694 | 711 | if(this->inletsConnected[0] && static_cast<ofTexture *>(_inletParams[0])->isAllocated() && isFullscreen){ |
695 | 712 | warpController->onMousePressed(window->events().getMouseX(),window->events().getMouseY()); |
696 | 713 | } |
| 714 | + |
| 715 | + ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
697 | 716 | if(this->inletsConnected[0] && this->inletsConnected[1] && _inletParams[1] != nullptr && static_cast<ofTexture *>(_inletParams[0])->isAllocated()){ |
698 | | - ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
699 | 717 | if(static_cast<LiveCoding *>(_inletParams[1])->lua.isValid()){ |
700 | 718 | static_cast<LiveCoding *>(_inletParams[1])->lua.scriptMousePressed(static_cast<int>(tm.x),static_cast<int>(tm.y), e.button); |
701 | 719 | } |
702 | 720 | } |
| 721 | + |
| 722 | + static_cast<vector<float> *>(_outletParams[0])->at(0) = tm.x; |
| 723 | + static_cast<vector<float> *>(_outletParams[0])->at(1) = tm.y; |
| 724 | + static_cast<vector<float> *>(_outletParams[0])->at(2) = e.button; |
703 | 725 | } |
704 | 726 |
|
705 | 727 | //-------------------------------------------------------------- |
706 | 728 | void OutputWindow::mouseReleased(ofMouseEventArgs &e){ |
707 | 729 | if(this->inletsConnected[0] && static_cast<ofTexture *>(_inletParams[0])->isAllocated() && isFullscreen){ |
708 | 730 | warpController->onMouseReleased(window->events().getMouseX(),window->events().getMouseY()); |
709 | 731 | } |
| 732 | + ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
710 | 733 | if(this->inletsConnected[0] && this->inletsConnected[1] && _inletParams[1] != nullptr && static_cast<ofTexture *>(_inletParams[0])->isAllocated()){ |
711 | | - ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
712 | 734 | if(static_cast<LiveCoding *>(_inletParams[1])->lua.isValid()){ |
713 | 735 | static_cast<LiveCoding *>(_inletParams[1])->lua.scriptMouseReleased(static_cast<int>(tm.x),static_cast<int>(tm.y), e.button); |
714 | 736 | } |
715 | 737 | } |
716 | 738 |
|
| 739 | + static_cast<vector<float> *>(_outletParams[0])->at(0) = tm.x; |
| 740 | + static_cast<vector<float> *>(_outletParams[0])->at(1) = tm.y; |
| 741 | + static_cast<vector<float> *>(_outletParams[0])->at(2) = e.button; |
| 742 | + |
717 | 743 | this->setCustomVar(window->getWindowPosition().x,"OUTPUT_POSX"); |
718 | 744 | this->setCustomVar(window->getWindowPosition().y,"OUTPUT_POSY"); |
719 | 745 | } |
720 | 746 |
|
721 | 747 | //-------------------------------------------------------------- |
722 | 748 | void OutputWindow::mouseScrolled(ofMouseEventArgs &e){ |
| 749 | + ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
723 | 750 | if(this->inletsConnected[0] && this->inletsConnected[1] && _inletParams[1] != nullptr && static_cast<ofTexture *>(_inletParams[0])->isAllocated()){ |
724 | | - ofVec2f tm = ofVec2f(((window->events().getMouseX()-thposX)/thdrawW * this->output_width),((window->events().getMouseY()-thposY)/thdrawH * this->output_height)); |
725 | 751 | if(static_cast<LiveCoding *>(_inletParams[1])->lua.isValid()){ |
726 | 752 | static_cast<LiveCoding *>(_inletParams[1])->lua.scriptMouseScrolled(static_cast<int>(tm.x),static_cast<int>(tm.y), e.scrollX,e.scrollY); |
727 | 753 | } |
728 | 754 | } |
| 755 | + |
| 756 | + static_cast<vector<float> *>(_outletParams[0])->at(0) = tm.x; |
| 757 | + static_cast<vector<float> *>(_outletParams[0])->at(1) = tm.y; |
| 758 | + static_cast<vector<float> *>(_outletParams[0])->at(2) = e.button; |
729 | 759 | } |
730 | 760 |
|
731 | 761 | //-------------------------------------------------------------- |
|
0 commit comments