++ interaction bouton
This commit is contained in:
		
							parent
							
								
									14086f1e05
								
							
						
					
					
						commit
						6b1743efff
					
				| 
						 | 
				
			
			@ -4,8 +4,9 @@ const unsigned int WidgetButton::ARROW_UP = 0;
 | 
			
		|||
const unsigned int WidgetButton::ARROW_DOWN = 1;
 | 
			
		||||
 | 
			
		||||
const sf::Color ARROW_COLOR = sf::Color(33, 33, 33);
 | 
			
		||||
const sf::Color CLICKED_COLOR = sf::Color(190, 190, 190);
 | 
			
		||||
const sf::Color REST_COLOR = sf::Color(230, 230, 230);
 | 
			
		||||
const sf::Color NORMAL_COLOR = sf::Color(230, 230, 230);
 | 
			
		||||
const sf::Color HOVER_COLOR = sf::Color(220, 220, 220);
 | 
			
		||||
const sf::Color ACTIVE_COLOR = sf::Color(190, 190, 190);
 | 
			
		||||
 | 
			
		||||
WidgetButton::WidgetButton(
 | 
			
		||||
    Manager& manager, std::function<void(void)> click_cb,
 | 
			
		||||
| 
						 | 
				
			
			@ -58,13 +59,14 @@ void WidgetButton::draw(sf::Vector2f position) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    // coloration des boutons si enfoncement
 | 
			
		||||
    button.setFillColor(REST_COLOR);
 | 
			
		||||
    sf::Vector2f mouse_position = (sf::Vector2f) sf::Mouse::getPosition(window);
 | 
			
		||||
    button.setFillColor(NORMAL_COLOR);
 | 
			
		||||
 | 
			
		||||
    if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
 | 
			
		||||
        sf::Vector2f mouse_position = (sf::Vector2f) sf::Mouse::getPosition(window);
 | 
			
		||||
 | 
			
		||||
        if (button.getGlobalBounds().contains(mouse_position)) {
 | 
			
		||||
            button.setFillColor(CLICKED_COLOR);
 | 
			
		||||
    if (button.getGlobalBounds().contains(mouse_position)) {
 | 
			
		||||
        if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
 | 
			
		||||
            button.setFillColor(ACTIVE_COLOR);
 | 
			
		||||
        } else {
 | 
			
		||||
            button.setFillColor(HOVER_COLOR);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue