Example #1
0
void TitleBar::MousePressed(const MouseEvent& lEvent)
{
	if(m_pParent != NULL)
	{
		m_pParent->SetFocusWindow();
	}

	m_bDragging = true;

	OnMousePressed();
}
Example #2
0
void Button::MousePressed(const MouseEvent& lEvent)
{
	if(IsDisabled())
	{
		return;
	}

	// If our parent is a GUIWindow, then makew this window have focus in the GUI, used to make it's depth the highest
	if(GetParent() != NULL && GetParent()->GetComponentType() == EComponentType_GUIWindow)
	{
		GUIWindow* lpParentWindow = (GUIWindow *)GetParent();
		lpParentWindow->SetFocusWindow();
	}

	SetSelected(true);

	OnMousePressed();

	// Colour change
	if(m_bChangeLabelText)
	{
		for(unsigned int i = 0; i < m_vpAddedComponentList.size(); i++)
		{
			if(m_vpAddedComponentList[i]->GetComponentType() == EComponentType_Label)
			{
				((Label*)m_vpAddedComponentList[i])->SetColour(m_PressedLabelColour);
			}
		}

		m_label.SetColour(m_PressedLabelColour);
	}

	// Position change
	if(m_offsetApplied == false)
	{
		for(unsigned int i = 0; i < m_vpAddedComponentList.size(); i++)
		{
			m_vpAddedComponentList[i]->SetLocation(m_vpAddedComponentList[i]->GetLocation().m_x + m_pressedOffsetX, m_vpAddedComponentList[i]->GetLocation().m_y + m_pressedOffsetY);
		}

		m_label.SetLocation(m_label.GetLocation().m_x + m_pressedOffsetX, m_label.GetLocation().m_y + m_pressedOffsetY);

		m_offsetApplied = true;
	}
	
	if(m_Callback_Pressed)
	{
		m_Callback_Pressed(m_pCallbackData_Pressed);
	}
}
Example #3
0
bool CBaseControl::DispatchOwnEvent(sf::Event const & event)
{
	switch (event.type)
	{
	case sf::Event::MouseButtonPressed:
		return OnMousePressed(event.mouseButton);
	case sf::Event::MouseButtonReleased:
		return OnMouseReleased(event.mouseButton);
	case sf::Event::Resized:
		return OnWindowResized(event.size);
	case sf::Event::MouseMoved:
		return OnMouseMoved(event.mouseMove);
	default:
		return false;
	}
}
Example #4
0
void InputEventController::ProcessInputEvent(const SDL_Event &evt)
{
	switch (evt.type) {
		case SDL_KEYDOWN: OnKeyPressed(evt.key); break;
		case SDL_KEYUP: OnKeyReleased(evt.key); break;
		case SDL_TEXTINPUT: OnTextInput(evt.text); break;

		case SDL_MOUSEMOTION: OnMouseMoved(evt.motion); break;
		case SDL_MOUSEBUTTONDOWN: OnMousePressed(evt.button); break;
		case SDL_MOUSEBUTTONUP: OnMouseReleased(evt.button); break;
		case SDL_MOUSEWHEEL: OnMouseWheel(evt.wheel); break;

		default:
			HR_LOG(info) << "Unhandled input event type: " << evt.type;
	}
}
Example #5
0
void MenuItem::MousePressed(const MouseEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	// If our parent is a GUIWindow, then makew this window have focus in the GUI, used to make it's depth the highest
	if(GetParent() != NULL && GetParent()->GetComponentType() == EComponentType_GUIWindow)
	{
		GUIWindow* lpParentWindow = (GUIWindow *)GetParent();
		lpParentWindow->SetFocusWindow();
	}

	SetSelected(true);

	OnMousePressed();
}
Example #6
0
void Slider::MousePressed(const MouseEvent& lEvent)
{
	int lSliderX;
	int lSliderY;
	int lSliderWidth;
	int lSliderHeight;

	int lBarX;
	int lBarY;
	int lBarWidth;
	int lBarHeight;

	if(m_eSliderDirection == ESliderDirection_Horizontal)
	{
		lSliderX = GetLocationOnScreen().m_x + (int)((m_dimensions.m_width - m_sliderWidth) * ((m_currentValue - m_minValue) / (m_maxValue - m_minValue)));
		lSliderY = GetLocationOnScreen().m_y;
		lSliderWidth = m_sliderWidth;
		lSliderHeight = m_dimensions.m_height;

		lBarX = GetLocationOnScreen().m_x + (m_sliderWidth / 2);
		lBarY = GetLocationOnScreen().m_y + (m_dimensions.m_height / 2) - (m_barHeight / 2);
		lBarWidth = m_dimensions.m_width - m_sliderWidth;
		lBarHeight = m_barHeight;
	}
	else //if(m_eSliderDirection == ESliderDirection_Vertical)
	{
		lSliderX = GetLocationOnScreen().m_x;
		lSliderY = GetLocationOnScreen().m_y + (int)((m_dimensions.m_height - m_sliderWidth) * ((m_currentValue - m_minValue) / (m_maxValue - m_minValue)));
		lSliderWidth = m_dimensions.m_width;
		lSliderHeight = m_sliderWidth;

		lBarX = GetLocationOnScreen().m_x + (m_dimensions.m_width / 2) - (m_barHeight / 2);
		lBarY = GetLocationOnScreen().m_y + (m_sliderWidth / 2);
		lBarWidth = m_barHeight;
		lBarHeight = m_dimensions.m_height - m_sliderWidth;
	}

	int mouseX = lEvent.GetX();
	int mouseY = lEvent.GetY();

	// Check to see if we have clicked the slider to start dragging
	if((mouseX >= lSliderX) && (mouseX < lSliderX + lSliderWidth) && (mouseY >= lSliderY) && (mouseY < lSliderY + lSliderHeight))
	{
		if(m_bAllowDragging)
		{
			m_bDragging = true;
			m_bAllowDragginOutside = true;
		}
	}
	else
	{
		// Check to see if we have clicked on the bar to 'zoom' to a location
		if((mouseX >= lBarX) && (mouseX < lBarX + lBarWidth) && (mouseY >= lBarY) && (mouseY < lBarY + lBarHeight))
		{
			if(m_bAllowReleasingOnBar && !m_bDragging)
			{
				m_bPressedBar = true;
			}
		}
		else
		{
			// Don't allow releasing on the bar since we didnt first click on the bar, have to wait for release now
			m_bAllowReleasingOnBar = false;
		}

		// Don't allow dragging, or dragging outside, since our first press wasnt on the slider, have to wait for release now
		if(!m_bDragging)
		{
			m_bAllowDragging = false;
			m_bAllowDragginOutside = false;
		}
	}

	// If our parent is a GUIWindow, then makew this window have focus in the GUI, used to make it's depth the highest
	if(GetParent() != NULL && GetParent()->GetComponentType() == EComponentType_GUIWindow)
	{
		GUIWindow* lpParentWindow = (GUIWindow *)GetParent();
		lpParentWindow->SetFocusWindow();
	}

	OnMousePressed();
}
Example #7
0
//---------------------------------------------------------------
// Purpose: 
//---------------------------------------------------------------
void CGuiClientElement::HandleMousePressed( KeyCodes::KeyCode key, const Vector2f &absPos, const Vector2f &relPos )
{
	Vector2f rel = GetRelativePosition(relPos);
	OnMousePressed(key, absPos, rel);
	CALL_FUNC_ON_CLIENT_CHILDREN( HandleMousePressed, key, absPos, rel );
}
Example #8
0
void Application::Run()
{
    //
    // keyboard
    //

    if (keyboard_needs_poll())
        poll_keyboard();

    for (int k = 0; k < 256; k++)
    {
        if (key[k])
        {
            OnKeyPress(k);

            if (!prevKeyState[k])
                OnKeyPressed(k);
        }
        else if (!key[k])
        {
            if (prevKeyState[k])
                OnKeyReleased(k);
        }
    }

    memcpy(prevKeyState,(char*)key,256);

    //
    // mouse
    //

    if (mouse_needs_poll())
        poll_mouse();

    for (int button = 0; button < (numMouseButtons); button++)
    {
        if ((mouse_b & (1 << button)) != 0)
        {
            mouseButtons[button] = true;
        }
        else
        {
            mouseButtons[button] = false;
        }

        if (mouseButtons[button] && (!prevMouseButtons[button]))
        {
            OnMousePressed(button, mouse_x, mouse_y);

            mousePressedLocs[button].x = mouse_x;
            mousePressedLocs[button].y = mouse_y;
        }
        else if ((!mouseButtons[button]) && prevMouseButtons[button])
        {
            OnMouseReleased(button, mouse_x, mouse_y);

            if ((mousePressedLocs[button].x == mouse_x) &&
                    (mousePressedLocs[button].y == mouse_y))
            {
                OnMouseClick(button,mouse_x,mouse_y);
            }
        }
    }

    memcpy(prevMouseButtons,mouseButtons,sizeof(bool)*(numMouseButtons+1));

    if ((mouse_x != prevMouseX) || (mouse_y != prevMouseY))
    {
        OnMouseMove(mouse_x,mouse_y);

        prevMouseX = mouse_x;
        prevMouseY = mouse_y;
    }

    // mouse wheel
    if (mouse_z > prevMouseZ)
    {
        OnMouseWheelUp( mouse_x, mouse_y );
        prevMouseZ = mouse_z;
    }
    else if (mouse_z < prevMouseZ)
    {
        OnMouseWheelDown( mouse_x, mouse_y );
        prevMouseZ = mouse_z;
    }

    //
    // run the game
    //

    show_mouse(NULL);
    RunGame();
    show_mouse(canvas);

    //
    // render canvas to the screen
    //

    blit(canvas,screen,0,0,0,0,screen->w,screen->h);

    //
    // sound polling (to ensure sounds currently playing will keep playing)
    //
    SoundOGG::PollSounds();

    //
    // handle timing
    //

    HandleTiming();
}