Example #1
0
	void MsgRouter::_updateMarkedWidget(bool bPostMouseMoveMsgs)
	{
		Widget_p pNowMarked = 0;
	
		Widget_p pWidgetTarget = m_pRoot->findWidget( m_pointerPos, WG_SEARCH_ACTION_TARGET );
	
		// Figure out which button of currently pressed has been pressed the longest.
		// Mouse is only allowed to mark Widgets that were marked on press of that button.
	
		int button = 0;								// Button that has been pressed for longest, 0 = no button pressed
		for( int i = 1 ; i <= WG_MAX_BUTTONS ; i++ )
		{
			if( m_bButtonPressed[i] && (button == 0 || m_pLatestPressMsgs[i]->timestamp() < m_pLatestPressMsgs[button]->timestamp()) )
				button = i;
		}
	
		// We are only marking the Widget if no mouse button is pressed or the first pressed button
		// was pressed on it.
	
		if( button == 0 || pWidgetTarget == m_latestPressWidgets[button].rawPtr() )
			pNowMarked = pWidgetTarget;
	
		// Post Leave events for widgets no longer marked,
		// Post Enter events for new marked widgets
		// and Move events for those already marked
	
		Widget * pFirstAlreadyMarked = _updateEnteredWidgets( pNowMarked.rawPtr() );
		
		if( bPostMouseMoveMsgs && pFirstAlreadyMarked )
			post( new MouseMoveMsg( pFirstAlreadyMarked ) );
	
		// Copy content of pNowMarked to m_pMarkedWidget
	
		m_pMarkedWidget = pNowMarked.rawPtr();
		
		// Update PointerStyle
		
		WgPointerStyle newStyle;
		
		if( pNowMarked && pNowMarked->isEnabled() )
			newStyle = pNowMarked->pointerStyle();
		else if( button != 0 )
			newStyle = m_pointerStyle;
		else
			newStyle = WG_POINTER_DEFAULT;
	
		if( newStyle != m_pointerStyle )
		{
			post( new PointerChangeMsg( newStyle ) );
			m_pointerStyle = newStyle;
		}	
	}
Example #2
0
	bool MsgRouter::setKeyboardFocus( const Widget_p& pFocus )
	{
		// Return if Widget is not child of our root.
	
		if( pFocus && (!pFocus->hook() || pFocus->hook()->root() != m_pRoot) )
			return false;
	
		// Handle old focus.
	
		Widget * pOldFocus = m_keyFocusWidget.rawPtr();
	
		if( pFocus == pOldFocus )
			return true;
	
		if( pOldFocus )
			_setWidgetFocused( pOldFocus, false );
	
		// Handle new focus, possibly switching focus group.
	
		if( pFocus )
		{
			// Check what focus group (if any) this Widget belongs to.
	
			m_keyFocusGroup = 0;
			Container * p = pFocus->_parent();
			while( p )
			{
				if( p->_isPanel() && static_cast<Panel*>(p)->isFocusGroup() )
				{
					m_keyFocusGroup = static_cast<Panel*>(p);
					break;
				}
	
				p = p->_parent();
			}
	
			// Activate focus
	
			_setWidgetFocused( pFocus.rawPtr(), true );
		}
	
		// Set members and exit.
	
		m_keyFocusWidget = pFocus.rawPtr();
		m_focusGroupMap[m_keyFocusGroup] = pFocus.rawPtr();
	
		return true;
	}
Example #3
0
	bool Capsule::removeWidget( const Widget_p& pWidget )
	{
		if( m_hook._widget() != pWidget.rawPtr() )
			return false;
	
		m_hook._setWidget(0);
		_requestRender();
		_requestResize();
		return true;
	}
Example #4
0
	CapsuleHook_p Capsule::setWidget( const Widget_p& pWidget )
	{
		if( !pWidget )
			return 0;
	
		m_hook._setWidget(pWidget.rawPtr());
		pWidget->_setSize(size());
	
		_requestRender();
		_requestResize();
		return &m_hook;
	}
Example #5
0
	Hook_p RootPanel::setWidget( const Widget_p& pWidget )
	{
		if( !pWidget )
			return 0;
	
		m_hook._setWidget(pWidget.rawPtr());
		m_hook._widget()->_onNewSize(m_geo.size());
	
		m_hook._widget()->_onCollectPatches( m_dirtyPatches, geo(), geo() );
	
		return &m_hook;
	}
Example #6
0
	ModalHook_p ModalLayer::addModalWidget( const Widget_p& pWidget, const Rect& geometry, WgOrigo origo )
	{
		// Create MyHook and fill in members.
	
		ModalHook * pHook = new ModalHook( this );
		pHook->_setWidget(pWidget.rawPtr());
		pHook->m_origo = origo;
		pHook->m_placementGeo = geometry;
		m_modalHooks.pushBack(pHook);
	
		// Refresh geometry and request render.
	
		pHook->_refreshRealGeo();
		_updateKeyboardFocus();
		return pHook;
	}
Example #7
0
	void InputHandler::setPointer( const RootPanel_p& pRoot, Coord pos, int64_t timestamp )
	{
		Coord	prevPointerPos = m_pointerPos;
		if( timestamp == 0 )
			timestamp = m_timeStamp;
		
		m_pointerPos = pos;
		m_pMarkedRoot = 0;
	
		Widget_p pNowMarked = 0;
		Widget_p pWidgetTarget = 0;
	
		if( pRoot && pRoot->geo().contains( pos ) )
		{
			m_pMarkedRoot = pRoot.rawPtr();
			pWidgetTarget = pRoot->findWidget( m_pointerPos, SearchMode::ActionTarget );
		}
	
		// Figure out which button of currently pressed has been pressed the longest.
		// Mouse is only allowed to mark Widgets that were marked on press of that button.
	
		int button = 0;								// Button that has been pressed for longest, 0 = no button pressed
		for( int i = 1 ; i <= MouseButton_Max ; i++ )
		{
			if( m_bButtonPressed[i] && (button == 0 || m_latestPressTimestamps[i] < m_latestPressTimestamps[button]) )
				button = i;
		}
	
		// We are only marking the Widget if no mouse button is pressed or the first pressed button
		// was pressed on it.
	
		if( button == 0 || pWidgetTarget == m_latestPressWidgets[button].rawPtr() )
			pNowMarked = pWidgetTarget;
	
		// Post Leave events for widgets no longer marked,
		// Post Enter events for new marked widgets
		// and Move events for those already marked
	
		Widget * pFirstAlreadyMarked = _updateEnteredWidgets( pNowMarked.rawPtr(), timestamp );
		
		if( pFirstAlreadyMarked )
			Base::msgRouter()->post( new MouseMoveMsg( m_inputId, pFirstAlreadyMarked, m_modKeys, pos, timestamp ) );
	
		// Copy content of pNowMarked to m_pMarkedWidget
	
		m_pMarkedWidget = pNowMarked.rawPtr();
	
		// Post events for button drag
	
		for( int i = 0 ; i <= MouseButton_Max ; i++ )
		{
			if( m_bButtonPressed[i] )
				Base::msgRouter()->post( new MouseDragMsg( m_inputId, (MouseButton) i, m_latestPressWidgets[i].rawPtr(), m_latestPressPosition[i], prevPointerPos, m_modKeys, m_pointerPos, timestamp ) );
		}
		
		// Update PointerStyle
		
		PointerStyle newStyle;
		
		if( pNowMarked && pNowMarked->isEnabled() )
			newStyle = pNowMarked->pointerStyle();
		else if( button != 0 )
			newStyle = m_pointerStyle;
		else
			newStyle = PointerStyle::Default;
	
		if( newStyle != m_pointerStyle )
		{
			Base::msgRouter()->post( new PointerChangeMsg( m_inputId, newStyle ) );
			m_pointerStyle = newStyle;
		}	
	}