コード例 #1
0
ファイル: Widget.cpp プロジェクト: DalikarFT/dndgame
    void Widget::mouseNotOnWidget()
    {
        if (m_MouseHover == true)
            mouseLeftWidget();

        m_MouseHover = false;
    }
コード例 #2
0
ファイル: Grid.cpp プロジェクト: DalikarFT/dndgame
    bool Grid::mouseOnWidget(float x, float y)
    {
        // Don't continue when the child window has not been loaded yet
        if (m_Loaded == false)
            return false;

        // Get the current position
        sf::Vector2f position = getPosition();

        // Check if the mouse might be on top of the grid
        if ((x > position.x) && (y > position.y))
        {
            // Check if the mouse is on the grid
            if ((x < position.x + m_Size.x) && (y < position.y + m_Size.y))
                return true;
        }

        if (m_MouseHover)
        {
            mouseLeftWidget();

            // Tell the widgets inside the grid that the mouse is no longer on top of them
            for (unsigned int i = 0; i < m_Widgets.size(); ++i)
                m_Widgets[i]->mouseNotOnWidget();

            m_MouseHover = false;
        }

        return false;
    }
コード例 #3
0
ファイル: Checkbox.cpp プロジェクト: IMACoconut/ImaKart
    bool Checkbox::mouseOnWidget(float x, float y)
    {
        // Don't do anything when the checkbox wasn't loaded correctly
        if (m_Loaded == false)
            return false;

        // Check if the mouse is on top of the image
        if (getTransform().transformRect(sf::FloatRect(0, 0, m_Size.x, m_Size.y)).contains(x, y))
            return true;
        else
        {
            // Check if the mouse is on top of the text
            if (m_AllowTextClick)
            {
                sf::FloatRect bounds = m_Text.getLocalBounds();
                if (sf::FloatRect(bounds.left, bounds.top, bounds.width, bounds.height).contains(x - (getPosition().x + ((m_Size.x * 11.0f / 10.0f))), y - getPosition().y - ((m_Size.y - bounds.height) / 2.0f) + bounds.top))
                    return true;
            }
        }

        if (m_MouseHover == true)
            mouseLeftWidget();

        // The mouse is not on top of the checkbox
        m_MouseHover = false;
        return false;
    }
コード例 #4
0
    bool ClickableWidget::mouseOnWidget(float x, float y)
    {
        // Check if the mouse is on top of the widget
        if (getTransform().transformRect(sf::FloatRect(0, 0, getSize().x, getSize().y)).contains(x, y))
            return true;
        else
        {
            if (m_MouseHover)
                mouseLeftWidget();

            m_MouseHover = false;
            return false;
        }
    }