WgWidget *  WgPopupLayer::_findWidget( const WgCoord& ofs, WgSearchMode mode )
{
	// MenuPanel has its own _findWidget() method since we need special treatment of
	// searchmode ACTION_TARGET when a menu is open.

	if( mode == WG_SEARCH_ACTION_TARGET && !m_popupHooks.IsEmpty() )
	{
		// In search mode ACTION_TARGET we limit our target to us, our menu-branches and the menu-opener if a menu is open.

		WgPopupHook * pHook = m_popupHooks.Last();
		WgWidget * pResult = 0;

		while( pHook && !pResult )
		{
			if( pHook->m_geo.Contains( ofs ) )
			{
				if( pHook->_widget()->IsContainer() )
					pResult = static_cast<WgContainer*>(pHook->_widget())->_findWidget( ofs - pHook->m_geo.Pos(), mode );
				else if( pHook->_widget()->MarkTest( ofs - pHook->m_geo.Pos() ) )
					pResult = pHook->_widget();
			}
			pHook = pHook->_prev();
		}

		if( pResult == 0 )
		{
			// Check the first opener
			
			WgPopupHook * pHook = m_popupHooks.First();
			if( pHook && pHook->m_pOpener )
			{
				WgWidget * pOpener = pHook->m_pOpener.RawPtr();

				WgCoord absPos 		= ofs + GlobalPos();
				WgRect	openerGeo 	= pOpener->GlobalGeo();

				if( openerGeo.Contains(absPos) && pOpener->MarkTest( absPos - openerGeo.Pos() ) )
					pResult = pOpener;
			}
			
			// Fall back to us.
			
			if( pResult == 0 )
				pResult = this;
		}
		return pResult;
	}
	else
	{
		// For the rest of the modes we can rely on the default method.

		return WgContainer::_findWidget( ofs, mode );
	}
}
Exemple #2
0
void JButton::Draw() const
{
    Batched& sb = *WinS::sb;
    glm::vec2 Pos = GlobalPos();
    glm::vec4 col;
    if(aimed){
        col = Colors::White;
    } else {
        col = Colors::Red;
    }
    sb.DrawLine(Pos, glm::vec2(Pos.x, Pos.y + size.y), 2, col);
    sb.DrawLine(Pos, glm::vec2(Pos.x + size.x, Pos.y), 2, col);
    sb.DrawLine(glm::vec2(Pos.x, Pos.y + size.y), Pos + size, 2, col);
    sb.DrawLine(glm::vec2(Pos.x + size.x, Pos.y), Pos + size, 2, col);

    text->DrawAt(atCenter(text->Size, Pos, size));
}
Exemple #3
0
void JButton::Update()
{
    if(WinS::MouseHooked){
        aimed = false;
        return;
    }

    glm::vec2 wpos = GlobalPos();
    if(inLimsV(Mouse::GetCursorPos(), wpos, wpos + size)){
        aimed = true;
        if(Mouse::IsLeftPressed()){
            if(onPress){
                onPress();
            }
        }
    } else {
        aimed = false;
    }
}
WgRect WgPackListHook::GlobalGeo() const
{
	WgRect	geo;
	m_pParent->_getChildGeo(geo,this);
	return geo + GlobalPos();
}