Exemplo n.º 1
0
void InteractiveObject::handleEvent(const Event &event)
{
    if (event.type == MouseEvent::MOUSE_MOVE || event.type == MouseEvent::CLICK || event.type == MouseEvent::MOUSE_DOWN || event.type == MouseEvent::MOUSE_UP)
    {
        MouseEvent* st = (MouseEvent*)(&event);
        bool hit = hitTestPoint(st->getX(), st->getY());
        if (event.type == MouseEvent::MOUSE_MOVE)
        {
            onMouseMove(event);
            if (isHovered)
            {
                if (!hit)
                {
                    onMouseOut(event);
                    dispatchEvent(MouseEvent(this, MouseEvent::MOUSE_OUT, st->getX(), st->getY()));
                    isHovered = !isHovered;
                }

            }
            else
            {
                if (hit)
                {
                    onMouseOver(event);
                    dispatchEvent(MouseEvent(this, MouseEvent::MOUSE_OVER, st->getX(), st->getY()));
                    isHovered = !isHovered;
                }
            }
        }
        else if (hit)
        {
            dispatchEvent(MouseEvent(this, event.type, st->getX(), st->getY()));
        }
    }
}
Exemplo n.º 2
0
bool CursorCtrl::handleMousePress( MouseEvent& e ) 
{ 
	if( e.isLeft() && ( e.isNoKey() || e.isAlt() ) ||
		e.isRight() && e.isShift() )
	{
		Allocation a;
		allocation( a );
		ViewAreaMdl* area = d_view->getArea();
		if( d_do[ DimX ] && d_do[ DimY ] && area->getDimCount() == 2 )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, 
				d_view->getDim( DimY ), y, d_mouseVeto );
		}else if( d_do[ DimX ] && area->inUse( DimX ) )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, d_mouseVeto );
		}else if( d_do[ DimY ] && area->inUse( DimY ) )
		{
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimY ), y, d_mouseVeto );
		}
		return d_swallow;	// Der Click soll nicht immer gefressen werden.
	}else
		return false;
}
Exemplo n.º 3
0
void Simulacra::mouseMove( MouseEvent event )
{
    // std::cout << ((float)event.getX()/(float)cinder::app::getWindowWidth()) << std::endl;
    synthMenu->midiSetSynth(0,((float)event.getX()/(float)cinder::app::getWindowWidth())*127);
    synthMenu->midiSetSynth(1,((float)event.getY()/(float)cinder::app::getWindowHeight())*127);
    synthMenu->midiSetSynth(2,((float)event.getX()/(float)cinder::app::getWindowWidth())*127);
    synthMenu->midiSetSynth(3,((float)event.getY()/(float)cinder::app::getWindowHeight())*127);
}
Exemplo n.º 4
0
	void mouseDown( MouseEvent event )
	{
		if (event.isLeftDown()) {
			mSelectionMode = 1; // 選択開始
			mSelectRegion.set(event.getX()-5, event.getY()-5, event.getX()+5, event.getY()+5);
		}

		mMPPrev = event.getPos();
	}
/**********************************************************************************

Function Name = SecurityProjectDemoApp::mouseDown

Descriptive Name = Used to detect the mouseDown action and open the infected window.

Function =

    This function is used to detect the mouseDown by the user and open up an infected
    window at the position where the mouse down was performed. The function also
    performs additional checks to make sure that only a mousedown event is handled. 

Input =
    
    MouseEvent event - The mouse event that is detected for cinder to call the function.

Output =
   
   Creates the infected window and opens it. 
   Prints debug info also.

******************************************************************************/
void SecurityProjectDemoApp::mouseDown ( MouseEvent event )
{
    // Variable Declaration 
    string messageBuffer = "" ;
    ostringstream intToStringConverter ;
    wstring stringTemp ;
    LPCWSTR debugMessage ;

    // Set the mouse positions when mouse button is pressed
    mouseDownMouseX = event.getX () ;
    mouseDownMouseY = event.getY () ;

    // Make sure to only open up the infection window if infection sequence is initialized, 
    // the current event is not already handled and the event is a left or right button click.
    if ( startInitialized && ( event.isLeft() || event.isRight() ) && event.isHandled () == false )
    {
        // ------------------------ Start of Debugging Block -----------------------------

        OutputDebugStringW ( L"\n-------------------- START Detecting a Left/Right mouseDown --------------------\n" ) ;

        // Add all information that is needed into the string stream
        intToStringConverter << "Y--> " << mouseDownMouseY << "\n" << "X--> " << mouseDownMouseX << "\n" ;

        // Fetch the string equivalence of the input (int or any other data type)
        messageBuffer = intToStringConverter.str () ;

        // Convert the messageBuffer string into wstring for later conversion
        stringTemp = wstring ( messageBuffer.begin (), messageBuffer.end () ) ;

        // Convert wstring to LPCWSTR
        debugMessage = stringTemp.c_str () ;

        OutputDebugStringW ( debugMessage ) ;

        OutputDebugStringW ( L"-------------------- DONE Detecting a Left/Right mouseDown --------------------\n" ) ;

        // ------------------------ End of Debugging Block -----------------------------

        // Create the infection window for draw function to open later
        createInfectedWindow ( loadResource ( RES_SUPPORTEDGESTURES_IMAGE ),
                               WINDOW_X_SIZE,
                               WINDOW_Y_SIZE,
                               event.getX (),
                               event.getY ()
                             ) ;

        // Once the single event has been handled mark it as handled to make sure that
        // we avoid handling the same event multiple times.
        event.setHandled( true ) ;
    }
}
void NearestStarbucksApp::mouseDown( MouseEvent event )
{
	if(event.isRight()){
		console() << event.getX() << "," << event.getY() << std::endl;
	}
	if(event.isLeft()){
		nearest_starbucks_ = new Entry();
		nearest_starbucks_->x = tree->getNearest(1-(getWindowWidth()-event.getX()*1.0000f)/getWindowWidth(),(getWindowHeight()-event.getY()*1.0f)/getWindowHeight()*1.0f)->x; 
		nearest_starbucks_->y = tree->getNearest(1-(getWindowWidth()-event.getX()*1.0000f)/getWindowWidth(),(getWindowHeight()-event.getY()*1.0f)/getWindowHeight()*1.0f)->y; 
		nearest_starbucks_->identifier = tree->getNearest(1-(getWindowWidth()-event.getX()*1.0000f)/getWindowWidth(),(getWindowHeight()-event.getY()*1.0f)/getWindowHeight()*1.0f)->identifier; 
		console() << "The nearest Starbucks to the clicked point is listed below. " << std::endl; 
		console() << nearest_starbucks_->identifier << std::endl;
	}
}
Exemplo n.º 7
0
	void TPopupMenu::processEvent(Event* event) {
		switch (event->getType()) {
			case MouseEvent::MOUSE_MOVED:
				{
					MouseEvent* me = (MouseEvent*)event;
					TMenuItem* m = (TMenuItem*)getComponentAt(getX() + me->getX(), getY() + me->getY());
					if (m) {
						for (int ii = 0; ii < items.size(); ii++) {
							TMenuItem* c = (TMenuItem*)items.get(ii);
							if (c != m && c->getEnabled() && c->getFocused() && c->getType() == TMenuItem::TYPE_ITEM) {
								c->setFocused(false);
								repaint();

							}
						}
						if (m->getEnabled() && !m->getFocused() && m->getType() == TMenuItem::TYPE_ITEM) {
							m->setFocused(true);
							repaint();
						}
					} else {
						for (int ii = 0; ii < items.size(); ii++) {
							TMenuItem* c = (TMenuItem*)items.get(ii);
							if (c->getEnabled() && c->getFocused() && c->getType() == TMenuItem::TYPE_ITEM) {
								c->setFocused(false);
								repaint();
							}
						}
					}
				}
				break;
			case MouseEvent::MOUSE_PRESSED:
				{
					MouseEvent* me = (MouseEvent*)event;
					TMenuItem* m = (TMenuItem*)getComponentAt(getX() + me->getX(), getY() + me->getY());
					if (m && m->getEnabled()) {
						TActionEvent* ae = new TActionEvent();
						ae->setSource(m);
						ae->setActionCommand(m->getActionCommand());
						m->processEvent(ae);
						delete ae;
						hide();
					}
				}
				break;
			default:
				break;
		}
	}
Exemplo n.º 8
0
bool PlaylistWindow::onMouseEvent(MouseEvent ev)
{
	// if clicked, give widget focus
	if (ev.getEvent() == MouseEvent::LBUTTONDOWN ||
		ev.getEvent() == MouseEvent::RBUTTONDOWN)
	{
		bool found = false;
		for (unsigned int i = 0; i < mWidgets.size(); i++)
		{
			if (!found && mWidgets[i]->isPointInside(ev.getX(), ev.getY()))
			{
				found = true;
				mWidgets[i]->focus();
			}
			else if (!mWidgets[i]->getIsFocused())
			{
				mWidgets[i]->blur();
			}
		}
	}
	bool consumed = false;
	for (unsigned int i = 0; i < mWidgets.size(); i++)
	{
		if (mWidgets[i]->onMouseEvent(ev))
		{
			consumed = true;
			break;
		}
	}
	return consumed;
}
Exemplo n.º 9
0
void BuddhabrotApp::mouseDrag( MouseEvent event )
{
	int mouseX = event.getY() * TEXTURE_HEIGHT;
	int mouseY = event.getX() * TEXTURE_WIDTH;
	
	if( mouseX != mBoundingX1 || mouseY != mBoundingY1 ){
		mBoundingX1 = mouseX;
		mBoundingY1 = mouseY;
		
		int dx = abs( mBoundingX1 - mBoundingX0 );
		int dy = abs( mBoundingY1 - mBoundingY0 );
		
		if( dx < dy * TEXTURE_WIDTH/TEXTURE_HEIGHT ){
		
			dx = dy * TEXTURE_WIDTH/TEXTURE_HEIGHT;
			if( mBoundingX1 < mBoundingX0 ){
				mBoundingX1 = mBoundingX0 - dx;
			} else {
				mBoundingX1 = mBoundingX0 + dx;
			}
			
		} else if( dy < dx * TEXTURE_HEIGHT/TEXTURE_WIDTH ){
		
			dy= dx * TEXTURE_HEIGHT/TEXTURE_WIDTH;
			if( mBoundingY1 < mBoundingY0 ){
				mBoundingY1 = mBoundingY0 - dy;
			} else {
				mBoundingY1 = mBoundingY0 + dy;
			}
			
		}
	}
}
Exemplo n.º 10
0
void EmoteShortcutContainer::mouseReleased(MouseEvent &event)
{
    if (!emoteShortcut)
        return;

    if (event.getButton() == MouseButton::LEFT)
    {
        const int index = getIndexFromGrid(event.getX(), event.getY());

        if (emoteShortcut->isEmoteSelected())
            emoteShortcut->setEmoteSelected(0);

        if (index == -1)
        {
            mEmoteMoved = 0;
            return;
        }

        if (mEmoteMoved)
        {
            emoteShortcut->setEmotes(index, mEmoteMoved);
            mEmoteMoved = 0;
        }
        else if (emoteShortcut->getEmote(index) && mEmoteClicked)
        {
            emoteShortcut->useEmote(index + 1);
        }

        mEmoteClicked = false;
    }
}
Exemplo n.º 11
0
void GoApp::mouseDown(MouseEvent event)
{
	if (game_status != WAITING_FOR_USER) {
		return;
	}

	int x = event.getX();
	int j = (x - board_x + board_width/2) / board_width;
	int y = event.getY();
	int i = (y - board_y + board_width/2) / board_width;

	try {
		if (state.is_move_possible(i, j)) {
			state.do_move(GoState<M, N>::ij_to_ind(i, j));

			// Are there any more moves possible?
			if (state.get_moves().empty()) {
				game_status = GAME_OVER;
			}
			else {
				next_player();
			}
		}
	} catch (std::exception& error) {
		game_status = GAME_ERROR;
		error_string = error.what();
	}
}
Exemplo n.º 12
0
    void TabbedArea::mousePressed(MouseEvent& mouseEvent)
    {
        if (mouseEvent.isConsumed())
        {
            return;
        }

        if (mouseEvent.getButton() == MouseEvent::LEFT)
        {
            Widget* widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY());
            Tab* tab = dynamic_cast<Tab*>(widget);

            if (tab != NULL)
            {
                setSelectedTab(tab);
            }
        }

        // Request focus only if the source of the event
        // is not focusble. If the source of the event
        // is focused we don't want to steal the focus.
        if (!mouseEvent.getSource()->isFocusable())
        {
            requestFocus();
        }
    }
Exemplo n.º 13
0
void OutfitWindow::mousePressed(MouseEvent &event)
{
    const int index = getIndexFromGrid(event.getX(), event.getY());
    if (event.getButton() == MouseButton::RIGHT && popupMenu)
    {
        popupMenu->showOutfitsWindowPopup(viewport->mMouseX,
            viewport->mMouseY);
        event.consume();
        return;
    }
    else if (index == -1)
    {
        Window::mousePressed(event);
        return;
    }
    mMoved = false;
    event.consume();

    if (mItems[mCurrentOutfit][index] > 0)
    {
        mItemClicked = true;
    }
    else
    {
        if (dragDrop.isSelected())
        {
            mItems[mCurrentOutfit][index] = dragDrop.getSelected();
            mItemColors[mCurrentOutfit][index] = dragDrop.getSelectedColor();
            dragDrop.deselect();
            save();
        }
    }

    Window::mousePressed(event);
}
void DavidShaw_RoyalSocApp::mouseDown( MouseEvent event )
{
	if(event.isLeft()) {
		

		x1 = (float(event.getX()));
		y1 = (float(event.getY()));
		Node* cur = sentinel->prev_;
		while(cur!=sentinel) {
			grabFlag = cur->isInside(x1,y1);
			if(grabFlag) {
				grabbedSquare=cur;
			}
			cur = cur->prev_;
		}

	}
	if(grabFlag){ // I'm not sure this works. I've tried it out, but I never get the expected result. - Nick
		grabbedSquare->prev_->next_=grabbedSquare->next_;
		grabbedSquare->next_->prev_=grabbedSquare->prev_; //pulls grabbed square out & connects it's siblings - Nick
		grabbedSquare->next_=sentinel->next_;
		grabbedSquare->next_->prev_=grabbedSquare;
		grabbedSquare->prev_=sentinel;
		sentinel->next_=grabbedSquare; // pulls grabbedsquare to the top. - Nick
	}
}
void Shape_Stacking_HW1App::mouseUp( MouseEvent event )
{
    x_pos_ = (float) event.getX();
    y_pos_ = (float) event.getY();

    //cir_cur_ = Circle(x_pos_, y_pos_, 50);
}
Exemplo n.º 16
0
void SpellShortcutContainer::mousePressed(MouseEvent &event)
{
    const int index = getIndexFromGrid(event.getX(), event.getY());

    if (index == -1)
        return;

    const MouseButtonT eventButton = event.getButton();
    if (eventButton == MouseButton::LEFT)
    {
        const int itemId = getItemByIndex(index);
        if (itemId > 0)
            mSpellClicked = true;
        event.consume();
    }
    else if (eventButton == MouseButton::MIDDLE)
    {
        if ((spellShortcut == nullptr) || (spellManager == nullptr))
            return;

        event.consume();
        const int itemId = getItemByIndex(index);
        spellManager->invoke(itemId);
    }
}
Exemplo n.º 17
0
// Show ItemTooltip
void SpellShortcutContainer::mouseMoved(MouseEvent &event)
{
    if (spellPopup == nullptr ||
        spellShortcut == nullptr ||
        spellManager == nullptr)
    {
        return;
    }

    const int index = getIndexFromGrid(event.getX(), event.getY());

    if (index == -1)
        return;

    const int itemId = getItemByIndex(index);
    spellPopup->setVisible(Visible_false);
    const TextCommand *const spell = spellManager->getSpell(itemId);
    if ((spell != nullptr) && !spell->isEmpty())
    {
        spellPopup->setItem(spell);
        spellPopup->view(viewport->mMouseX, viewport->mMouseY);
    }
    else
    {
        spellPopup->setVisible(Visible_false);
    }
}
Exemplo n.º 18
0
void InventoryWindow::mouseMoved(MouseEvent &event)
{
    Window::mouseMoved(event);
    if (!textPopup)
        return;

    const Widget *const src = event.getSource();
    if (!src)
    {
        textPopup->hide();
        return;
    }
    const int x = event.getX();
    const int y = event.getY();
    const Rect &rect = mDimension;
    if (src == mSlotsBar || src == mWeightBar)
    {
        // TRANSLATORS: money label
        textPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"),
            Units::formatCurrency(PlayerInfo::getAttribute(
            Attributes::MONEY)).c_str()));
    }
    else
    {
        const Button *const btn = dynamic_cast<const Button *const>(src);
        if (!btn)
        {
            textPopup->hide();
            return;
        }
        const std::string text = btn->getDescription();
        if (!text.empty())
            textPopup->show(x + rect.x, y + rect.y, text);
    }
}
Exemplo n.º 19
0
void SpellShortcutContainer::mouseDragged(MouseEvent &event)
{
    if (event.getButton() == MouseButton::LEFT)
    {
        if (dragDrop.isEmpty() && mSpellClicked)
        {
            mSpellClicked = false;
            const int index = getIndexFromGrid(event.getX(), event.getY());

            if (index == -1)
                return;

            const int itemId = getItemByIndex(index);
            if (itemId < 0)
                return;
            event.consume();
            TextCommand *const spell = spellManager->getSpell(itemId);
            if (spell != nullptr)
            {
                dragDrop.dragCommand(spell, DragDropSource::Spells, index);
                dragDrop.setItem(spell->getId() + SPELL_MIN_ID);
            }
            else
            {
                dragDrop.clear();
                mSpellClicked = false;
            }
        }
    }
}
Exemplo n.º 20
0
    void DropDown::mouseReleased(MouseEvent& mouseEvent)
    {
        if (mIsDragged)
        {
            mPushed = false;
        }

        // Released outside of widget. Can happen when we have modal input focus.
        if ((0 > mouseEvent.getY()
            || mouseEvent.getY() >= getHeight()
            || mouseEvent.getX() < 0
            || mouseEvent.getX() >= getWidth())
            && mouseEvent.getButton() == MouseEvent::LEFT
            && isModalMouseInputFocused())
        {
            releaseModalMouseInputFocus();

            if (mIsDragged)
            {
                foldUp();
            }
        }
        else if (mouseEvent.getButton() == MouseEvent::LEFT)
        {
            mPushed = false;
        }

        mIsDragged = false;
    }
Exemplo n.º 21
0
void OutfitWindow::mouseReleased(MouseEvent &event)
{
    if (event.getButton() == MouseButton::LEFT)
    {
        if (mCurrentOutfit < 0 || mCurrentOutfit
            >= static_cast<signed int>(OUTFITS_COUNT))
        {
            return;
        }
        const int index = getIndexFromGrid(event.getX(), event.getY());
        if (index == -1)
        {
            dragDrop.clear();
            Window::mouseReleased(event);
            return;
        }
        mMoved = false;
        event.consume();
        if (!dragDrop.isEmpty())
        {
            if (dragDrop.isSourceItemContainer())
            {
                mItems[mCurrentOutfit][index] = dragDrop.getItem();
                mItemColors[mCurrentOutfit][index] = dragDrop.getItemColor();
                dragDrop.clear();
                dragDrop.deselect();
                save();
            }
        }
        if (mItemClicked)
            mItemClicked = false;
    }
    Window::mouseReleased(event);
}
Exemplo n.º 22
0
 void TextField::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::Left)
     {
         mText->setCaretPosition(mouseEvent.getX() + mXScroll, mouseEvent.getY(), getFont());
         fixScroll();
     }
 }
void ThingsOnThingsApp::mouseDown( MouseEvent event )
{
    int mouseX = event.getX();
    int mouseY = event.getY();
    Node* clicked = myList->onThisRing(mouseX, mouseY);
    if(clicked != 0)
        myList->moveToFront(clicked);
}
Exemplo n.º 24
0
void WorldUIView::mouseDown(MouseEvent &event){
	Utils::LOG("mouse_down");
	dragging = true;
	int x = event.getX();
	int y = event.getY();
	lastDragX = x;
	lastDragY = y;		
}
Exemplo n.º 25
0
void GeometryShaderIntroApp::mouseDrag( MouseEvent event )
{
	mNumSides = (((float)event.getX() / getWindowWidth()) * 30) + 3;
	mNumSides = constrain( mNumSides, 2, 64 );
	
	mRadius = ((float)event.getY() / getWindowHeight()) * ( getWindowWidth() / 2.0f );
	mRadius = constrain( mRadius, 1.0f, getWindowWidth() / 2.0f );
}
Exemplo n.º 26
0
 void TextBox::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::Left)
     {
         mText->setCaretPosition(mouseEvent.getX(), mouseEvent.getY(), getFont());
         mouseEvent.consume();
     }
 }
Exemplo n.º 27
0
 void TextField::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::Left)
     {
         mCaretPosition = getFont()->getStringIndexAt(mText, mouseEvent.getX() + mXScroll);
         fixScroll();
     }
 }
Exemplo n.º 28
0
Arquivo: hexApp.cpp Projeto: pholz/hex
void hexApp::mouseDrag( MouseEvent event )
{
	if(dragging)
	{
		//console() << "dragging" << endl;
		dragging->pos = Vec2f(event.getX(), event.getY()) - dragoffset;;
	}
}
Exemplo n.º 29
0
void hw04wolfsp3App::mouseDown( MouseEvent event )
{
	double x=1.0*event.getX()/700;
	double y=1.0-1.0*event.getY()/700;
	Entry* closestStarbucks=starbucks_->getNearest(x,y);
	circ_x=700*closestStarbucks->x;
	circ_y=700-700*closestStarbucks->y;

}
Exemplo n.º 30
0
GlyphCommand::Result SelectorCmd::handleMousePress(MouseEvent & e)
{
	// Dem Command ist es egal, wie es ausgelöst wurde. Letzteres ist Sache des Commanders.
	startFeedback();
	d_left = d_right = e.getX();
	d_top = d_bottom = e.getY();
	getHandler()->getViewport()->grab( getHandler() );
	return GlyphCommand::Continue;
}