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)
            {
                dragDrop.dragCommand(spell, DRAGDROP_SOURCE_SPELLS, index);
                dragDrop.setItem(spell->getId() + SPELL_MIN_ID);
            }
            else
            {
                dragDrop.clear();
                mSpellClicked = false;
            }
        }
    }
}
void SpellShortcutContainer::mousePressed(MouseEvent &event)
{
    const int index = getIndexFromGrid(event.getX(), event.getY());

    if (index == -1)
        return;

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

        event.consume();
        const int itemId = getItemByIndex(index);
        spellManager->invoke(itemId);
    }
}
Exemplo n.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
0
void ListBox::mouseReleased(MouseEvent &event)
{
    if (mPressedIndex != getSelectionByMouse(event.getY()))
        return;

    if (mDistributeMousePressed)
    {
        mouseReleased1(event);
    }
    else
    {
        switch (event.getClickCount())
        {
            case 1:
                mouseDragged(event);
                mOldSelected = mSelected;
                break;
            case 2:
                if (gui != nullptr)
                    gui->resetClickCount();
                if (mOldSelected == mSelected)
                    mouseReleased1(event);
                else
                    mouseDragged(event);
                mOldSelected = mSelected;
                break;
            default:
                mouseDragged(event);
                mOldSelected = mSelected;
                break;
        }
    }
    mPressedIndex = -2;
}
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 ListBox::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::LEFT)
     {
         setSelected(mouseEvent.getY() / getFont()->getHeight());
         generateAction();
     }
 }
Exemplo n.º 11
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.º 12
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.º 13
0
 void TextBox::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::Left)
     {
         mText->setCaretPosition(mouseEvent.getX(), mouseEvent.getY(), getFont());
         mouseEvent.consume();
     }
 }
Exemplo n.º 14
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.º 15
0
void ListBox::mouseReleased1(const MouseEvent &event)
{
    if (event.getButton() == MouseButton::LEFT)
    {
        setSelected(std::max(0, getSelectionByMouse(event.getY())));
        distributeActionEvent();
    }
}
Exemplo n.º 16
0
 void TextField::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::Left)
     {
         mText->setCaretPosition(mouseEvent.getX() + mXScroll, mouseEvent.getY(), getFont());
         fixScroll();
     }
 }
Exemplo n.º 17
0
    void Window::mousePressed(MouseEvent& mouseEvent)
    {
        if (mouseEvent.getSource() != this)
        {
            return;
        }

        if (getParent() != NULL)
        {
            getParent()->moveToTop(this);
        }

        mDragOffsetX = mouseEvent.getX();
        mDragOffsetY = mouseEvent.getY();

        mMoved = mouseEvent.getY() <= (int)mTitleBarHeight;
    }
Exemplo n.º 18
0
 void ListBox::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::LEFT)
     {
         setSelected(mouseEvent.getY() / getRowHeight());
         distributeActionEvent();
     }
 }
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.º 20
0
void ListBox::mouseDragged(MouseEvent &event)
{
    if (event.getButton() != MouseButton::LEFT || getRowHeight() == 0)
        return;

    // Make list selection update on drag, but guard against negative y
    if (getRowHeight())
        setSelected(std::max(0, getSelectionByMouse(event.getY())));
}
Exemplo n.º 21
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.º 22
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;
}
Exemplo n.º 23
0
void HW04App::mouseDown( MouseEvent event )
{
    if (event.isRight()) {
        double mouse_x = (event.getX()*1.0)/getWindowWidth();
        double mouse_y = (event.getY()*1.0)/getWindowHeight();
        
        closest = starbucks->getNearest(mouse_x, mouse_y);
    }
}
Exemplo n.º 24
0
// THis satisfies requirment E.6
void CatPictureApp::mouseDown(MouseEvent event)
{
	uint8_t* dataArray = (*mySurface_).getData();
	int x = event.getX();
	int y = event.getY();

	basicCircle(dataArray,x,y,20,Color8u(frame_number_+100,frame_number_,frame_number_+200));
	
}
Exemplo n.º 25
0
void ClientApp::mouseMove( MouseEvent event )
{
	// send mouse positions to server
	JsonTree mousePositions;
	mousePositions.pushBack( JsonTree( "x", event.getX() ) );
	mousePositions.pushBack( JsonTree( "y", event.getY() ) );

	mAMPM->sendCustomMessage( "/mouse", mousePositions );
}
Exemplo n.º 26
0
Arquivo: Events.cpp Projeto: Jmos/vaca
  virtual void onMouseLeave(MouseEvent& ev)
  {
    m_console->println(format_string(L"onMouseLeave(%d, %d)",
				     ev.getX(), ev.getY()));
    invalidate(true);
    update();

    Widget::onMouseLeave(ev);
  }
void Shape_Stacking_HW1App::mouseDown( MouseEvent event )
{

    x_pos_ = (float) event.getX();
    y_pos_ = (float) event.getY();

    if(x_pos_ >= x_pos_cir_-50 && x_pos_ <= x_pos_cir_+50 && y_pos_ >= y_pos_cir_-50 && y_pos_ <= y_pos_cir_+50) {
        gl::color(Color8u(200, 200, 200));
    }
}
Exemplo n.º 28
0
bool GraphicalObject::IsEventInsideBoundary(MouseEvent event)
{

	int X = (int)topLeftBoxPoint.x;
	int Y = (int)topLeftBoxPoint.y;


	// if Event exists within the graphical objects bounding box return true, else false.
	if ((event.getX() >= X) && (event.getX() <= X + width))
	{
		if ((event.getY() >= Y) && (event.getY() <= Y + height))
		{
			//cout << "Top left point of selected peice x: " << X << " Y: " << Y << endl;
			return true;
		}
	}

	return false;
}
Exemplo n.º 29
0
 void
 mouse_callback (const MouseEvent& mouse_event,
                 void* /*cookie*/)
 {
     if (mouse_event.getType () == MouseEvent::MouseButtonPress &&
             mouse_event.getButton () == MouseEvent::LeftButton)
     {
         cout << mouse_event.getX () << " , " << mouse_event.getY () << endl;
     }
 }
//When user clicks left button of mouse, draw flowers that painted in different color--> implement stretch goal J
void RoyalSociety_jiangy9LucyApp::mouseDown( MouseEvent event )
{
	gl::enableAlphaBlending();
	if(event.isLeftDown()){
		Flower* addFlower = new Flower();
		addFlower->set((*mySurface).getData(),(float)event.getX(),(float)event.getY(), addFlowerColor);
		insertAfter(first_item->previous,addFlower);
		click++;
	}
}