示例#1
0
void Button::MouseEntered(const MouseEvent& lEvent)
{
	if(IsDisabled())
	{
		return;
	}

	SetHover(true);

	OnMouseEnter();

	// Call the callback function
	if(m_EnterCallback)
	{
		m_EnterCallback(m_pEnterCallbackData);
	}

	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_hoverLabelColour);
			}
		}

		m_label.SetColour(m_hoverLabelColour);
	}
}
示例#2
0
GridSizeMenu::GridSizeMenu(const QIcon &icon, const QString &title, QWidget* parent/* =0 */)
	: QMenu(title, parent)
{
	setIcon(icon);

	m_Label = new QLabel(" ", this);
	m_Label->setAlignment(Qt::AlignCenter);
	m_Label->resize( m_Label->sizeHint() );

	int y = 0;
	m_Label->setGeometry(0, 0, sizeHint().width(), m_Label->height());
	y += m_Label->height();

	m_Buttons = new GridSizeButton**[QUICK_GRID_WIDTH];
	for(int col=0; col<QUICK_GRID_WIDTH; col++)
		m_Buttons[col] = new GridSizeButton*[QUICK_GRID_HEIGHT];

	for(int row=0; row<QUICK_GRID_HEIGHT; row++)
	{
		for(int col=0; col<QUICK_GRID_WIDTH; col++)
		{
			GridSizeButton *button = new GridSizeButton(col, row, this);
			connect(button, SIGNAL(hoveredGridSize(int,int)), this, SLOT(onHovered(int,int)));
			connect(button, SIGNAL(clickedGridSize(int,int)), this, SLOT(onClicked(int,int)));
			button->setGeometry(col*QUICK_GRID_BUTTON_SIZE, y + row*QUICK_GRID_BUTTON_SIZE, QUICK_GRID_BUTTON_SIZE, QUICK_GRID_BUTTON_SIZE);
			m_Buttons[col][row] = button;
		}
	}

	SetHover(0, 0);

	resize( sizeHint() );
}
示例#3
0
void Button::RemoveEventListeners()
{
	RemoveMouseListener(this);

	// Remove hover and select properties, since we have made this component un-selectable by the mouse
	SetHover(false);
	SetSelected(false);
}
示例#4
0
GuiControl::GuiControl(const sf::Uint16 entity_unique_id, 
					   const std::string& name) {
	mEntityUniqueId = entity_unique_id;
    mName = name;
	SetPositionType(Entity::PositionType::POSITIONTYPE_SCREENPIXEL);
    SetFocus(false);
    SetHover(false);
}
示例#5
0
void Button::MouseExited(const MouseEvent& lEvent)
{
	if(IsDisabled())
	{
		return;
	}

	if(IsSelected() && m_Callback_Released)
	{
		// If we have pressed the button, but not released when we move outside of the button
		m_Callback_Released(m_pCallbackData_Released);
	}

	SetHover(false);

	// Call the callback function
	if(m_ExitCallback)
	{
		m_ExitCallback(m_pExitCallbackData);
	}

	// If we are selected when we exit, reposition back the offset
	if(IsSelected() && m_offsetApplied)
	{
		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 = false;
	}

	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_normalLabelColour);
			}
		}
		m_label.SetColour(m_normalLabelColour);
	}

	// Also removed the button selection if we exit it's dimensions
	SetSelected(false);

	OnMouseExit();
}
示例#6
0
void MenuItem::MouseExited(const MouseEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	SetHover(false);

	// Also removed the button selection if we exit it's dimensions
	SetSelected(false);

	OnMouseExit();
}
示例#7
0
void MenuItem::MouseReleased(const MouseEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	Menu* lpParentMenu = (Menu* )GetParent();
	
	// Make sure that we are inside the bounds of the parent menu
	if(lpParentMenu->GetPullDownMenuParent() != NULL)
	{
		int lTextHeight = m_pRenderer->GetFreeTypeTextHeight(lpParentMenu->GetPullDownMenuParent()->GetGUIFont(), "%s", lpParentMenu->GetMenuTitle().c_str());
		int lMenuHeight = lTextHeight + (lpParentMenu->GetMenuItemSpacer() * 2);
		int lFullMenuDisplayHeight = lpParentMenu->GetPullDownMenuParent()->GetMaxNumItemsDisplayed() * lMenuHeight;

		Point location = lpParentMenu->GetPullDownMenuParent()->GetLocation();
		for(Component* parent = lpParentMenu->GetPullDownMenuParent()->GetParent(); parent != 0;)
		{
			Point parentLocation = parent->GetLocation();

			location.m_x += parentLocation.m_x;
			location.m_y += parentLocation.m_y;

			parent = parent->GetParent();
		}
		int lMenuX = location.m_x;
		int lMenuY = location.m_y - lFullMenuDisplayHeight;
		int lMenuWidth = lpParentMenu->GetBiggestWidth()+ (lpParentMenu->GetMenuItemSpacer() * 2);

		if(lEvent.GetX() > lMenuX && lEvent.GetX() <= lMenuX+lMenuWidth && lEvent.GetY() > lMenuY && lEvent.GetY() <= lMenuY+lFullMenuDisplayHeight)
		{
			// Close the menu, since we have clicked this menu item
			lpParentMenu->CloseMenu();

			SetHover(false);
			SetSelected(false);

			// Signal that we have pressed this menu item
			MenuItemPressed();
		}
	}


	FocusManager::GetInstance()->SetFocusOwner(0);

	OnMouseReleased();
}
示例#8
0
void MenuItem::MouseEntered(const MouseEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	Menu* lpParentMenu = (Menu* )GetParent();

	// Make sure that we are inside the bounds of the parent menu
	if(lpParentMenu->GetPullDownMenuParent() != NULL)
	{
		int lTextHeight = m_pRenderer->GetFreeTypeTextHeight(lpParentMenu->GetPullDownMenuParent()->GetGUIFont(), "%s", lpParentMenu->GetMenuTitle().c_str());
		int lMenuHeight = lTextHeight + (lpParentMenu->GetMenuItemSpacer() * 2);
		int lFullMenuDisplayHeight = lpParentMenu->GetPullDownMenuParent()->GetMaxNumItemsDisplayed() * lMenuHeight;

		Point location = lpParentMenu->GetPullDownMenuParent()->GetLocation();
		for(Component* parent = lpParentMenu->GetPullDownMenuParent()->GetParent(); parent != 0;)
		{
			Point parentLocation = parent->GetLocation();

			location.m_x += parentLocation.m_x;
			location.m_y += parentLocation.m_y;

			parent = parent->GetParent();
		}
		int lMenuX = location.m_x;
		int lMenuY = location.m_y - lFullMenuDisplayHeight;
		int lMenuWidth = lpParentMenu->GetBiggestWidth()+ (lpParentMenu->GetMenuItemSpacer() * 2);

		if(lEvent.GetX() > lMenuX && lEvent.GetX() <= lMenuX+lMenuWidth && lEvent.GetY() > lMenuY && lEvent.GetY() <= lMenuY+lFullMenuDisplayHeight)
		{
			SetHover(true);

			OnMouseEnter();
		}
	}
}
示例#9
0
void GridSizeMenu::onHovered(int col, int row)
{
	SetHover(col, row);
}