TEST(TestMouseEventDispatcher, TestEnterExitPosPurge) {
    GlfwMock mock;
    FTEngine::setup(true);
    MockMouseEventListener listener;

    auto enter_delegate = Gallant::Delegate1<const FTMouseEnterEvent&>(&listener, &MockMouseEventListener::mouseEnterEvent);
    FTEngine::getEventManager()->getEventDispatcher<FTMouseEventDispatcher>()->registerDelegate(enter_delegate);
    auto exit_delegate = Gallant::Delegate1<const FTMouseExitEvent&>(&listener, &MockMouseEventListener::mouseExitEvent);
    FTEngine::getEventManager()->getEventDispatcher<FTMouseEventDispatcher>()->registerDelegate(exit_delegate);
    auto move_delegate = Gallant::Delegate1<const FTMouseMoveEvent&>(&listener, &MockMouseEventListener::mouseMoveEvent);
    FTEngine::getEventManager()->getEventDispatcher<FTMouseEventDispatcher>()->registerDelegate(move_delegate);

    testing::InSequence s;


    EXPECT_CALL(listener, mouseMoveEvent(FTMouseMoveEvent(200, 100, 0, 0)));
    EXPECT_CALL(listener, mouseEnterEvent(testing::_));
    EXPECT_CALL(listener, mouseExitEvent(testing::_));
    EXPECT_CALL(listener, mouseMoveEvent(FTMouseMoveEvent(240, 80, 0, 0)));

    mock.mouse_pos_callback_(nullptr, 200, 100);

    mock.mouse_enter_callback_(nullptr, GL_TRUE);
    mock.mouse_enter_callback_(nullptr, GL_FALSE);

    mock.mouse_pos_callback_(nullptr, 240, 80);

    FTEngine::cleanup();
}
Пример #2
0
void UIShowPanel::createUI( int marginX, int marginY, int width, int height )
{
    // Title
    this->title = new QLabel( this );
    this->title->setStyleSheet( "font-size: 30px;" );
    this->title->move( marginX, this->engineProperties->get( "TVSHOW_TITLE_Y_SPACE" ).toInt() );

    // Categorie
    this->categorie = new QLabel( this );
    this->categorie->move( marginX, this->title->pos().y() + this->title->height() + this->engineProperties->get("TVSHOW_DECALLAGE_TITLE_CATEGORIE").toInt( ));

    // Stars
    int i, size = this->engineProperties->get( "MAX_STARS" ).toInt(), starSpace = this->engineProperties->get( "STAR_SPACE" ).toInt();
    const QPixmap *emptyPixmap = this->enginePicture->getPicture( PICTURE_STAR_EMPTY );
    for( i = 0; i < size; i++ )
    {
        JLabel *star = new JLabel( this );
        star->setPixmap( *emptyPixmap );
        star->move( marginX + i * emptyPixmap->width() + starSpace, this->categorie->pos().y() + this->categorie->height() );
        this->connect( star, SIGNAL(mouseEnterEvent()), this, SLOT(changeStarsHover()));
        this->connect( star, SIGNAL(mouseLeaveEvent()), this, SLOT(changeStarsLeave()));
        this->connect( star, SIGNAL(mouseRelease()), this, SLOT(starClicked()));
        this->stars.push_back( star );
    }

    int ySpace = 30;

    // Status
    this->show_status = new QLabel( this );
    this->show_status->move( this->engineProperties->get( "TVSHOW_CALQUE_LEFT" ).toInt(), marginY );
    this->show_status->setStyleSheet( "font-size: 12px" );

    // Started
    this->show_started = new QLabel( this );
    this->show_started->move( this->show_status->pos().x(), marginY + ySpace );
    this->show_started->setStyleSheet( "font-size: 12px" );

    // Ended
    this->show_ended = new QLabel( this );
    this->show_ended->move( this->show_status->pos().x(), marginY + 2 * ySpace );
    this->show_ended->setStyleSheet( "font-size: 12px" );

    // Country
    this->show_country = new QLabel( this );
    this->show_country->move( this->show_status->pos().x(), marginY + 3 * ySpace );
    this->show_country->setStyleSheet( "font-size: 12px" );

    // Episode list
    this->listConteneur = new QWidget( this );
    this->listConteneur->move( this->engineProperties->get( "TVSHOW_CALQUE_LIST_LEFT" ).toInt(), this->engineProperties->get( "TVSHOW_CALQUE_LIST_TOP" ).toInt() );
    this->listConteneur->setFixedSize( width - this->listConteneur->width() - this->engineProperties->get( "TVSHOW_X_DECALLAGE" ).toInt(), height - this->listConteneur->pos().y() - this->engineProperties->get( "TVSHOW_X_DECALLAGE" ).toInt() );
    this->moveConteneur = new QWidget( this->listConteneur );

    // Options panel
    this->optionsPanel = new UIOptionsPanel( this->engineProperties, this->enginePicture, this->engineLanguage, this->engineProperties->get( "OPTIONSPANEL_HEIGHT" ).toInt() - 2 * this->engineProperties->get( "OPTIONSPANEL.MARGIN.Y" ).toInt(), this );
    this->optionsPanel->setNormalPosX( width - this->optionsPanel->getMinLeftWIdth() );
    this->optionsPanel->move( width - this->optionsPanel->getMinLeftWIdth(), this->engineProperties->get( "OPTIONSPANEL_MARGIN_Y" ).toInt() );
}
Пример #3
0
bool XWidget::devEvent(X_Event *event)
{
	//如果是此组件
	if(JUDGEMOUSE(event,widget_rect))
	{
		//先判断子组件是否符合
		if(layout && layout->responseEvent(event) )
		{
			return true;
		}

		switch(event->type)
		{
#ifdef USE_MOUSE
			case SDL_MOUSEMOTION:
				{
					mouseEnterEvent(event);
					
					if(isFocus() && event->motion->state == SDL_PRESSED)
					{
						focusEnter();	
					}else if(!isFocus() && event->motion->state == SDL_PRESSED)
					{
						XAbstractWidget::focus_widget->focusLeave();	
					}
				}
				break;
				
			case SDL_MOUSEBUTTONDOWN:
				{
					switch(event->mouse_type)
					{
						case X_BUTTON_LEFT:
							{
								XAbstractWidget::setFocusWidget(this);
								mouseLPressEvent(event);
							}
							break;
							
						case X_BUTTON_RIGHT:
							{
								mouseRPressEvent(event);	
							}
							
						case X_BUTTON_WHEELUP:
							{
								mouseWheelUp(event);
							}
							break;
							
						case X_BUTTON_WHEELDOWN:
							{
								mouseWheelDown(event);
							}
							break;
							
						case X_BUTTON_MIDDLE:
							{
								mouseMPressEvent(event);	
							}
							break;
					}
						
					if(mouse_listener)
					{
						mouse_listener->mousePressed(event,(ID)this);
					}
				
				}
				break;
				
 			case SDL_MOUSEBUTTONUP:
				{	
					switch(event->mouse_type)
					{
						case X_BUTTON_LEFT:
							{
								//printf("this=%x,focus=%x\n",this,XWidgetProcess::focus_widget);
								if(isFocus())
								{
									mouseLReleaseEvent(event);
								}
							}
							break;
							
						case X_BUTTON_RIGHT:
							{
								mouseRReleaseEvent(event);	
							}
							break;
						case X_BUTTON_WHEELUP:
							{
								mouseWheelUp(event);
							}
							break;
							
						case X_BUTTON_WHEELDOWN:
							{
								mouseWheelDown(event);
							}
							break;
							
						case X_BUTTON_MIDDLE:
							{
								mouseMReleaEvent(event);	
							}
							break;
					}
				
					if(mouse_listener)
					{
						mouse_listener->mouseReleased(event,(ID)this);
					}
				}
				break;
#endif
		}
		return true;
	}
#ifdef USE_KEYBOARD
	switch(event->type)
	{
			case X_KEYDOWN:
				{
					keydownEvent(event);
				}
				break;
			case X_KEYUP:
				{
					keyReleaseEvent(event);
				}
				break;
	}
#endif
	return false;	
}
Пример #4
0
void Widget::handleMouseEnter(MouseFocusEvent &event)
{
	hasMouseOver_ = true;
	mouseEnterEvent(event);
}