Esempio n. 1
0
void Clickable::mouseDragged(MouseEvent* mouse_event) {
  emit onMouseDragged(mouse_event);
}
Esempio n. 2
0
void Buttons::onMouseMoved(int mx, int my) {
    if(!is_visible) {
        return;
    }

    mdx = mx - pmx;
    mdy = my - pmy;

    // are we inside our header area? TODO: we cn optimize here by returning early
    if(!is_locked) {
        is_mouse_inside_header = BINSIDE_HEADER(this, mx, my);
        if(is_mouse_inside_header && state == BSTATE_NONE) {
            state = BSTATE_ENTER;
            onMouseEnter(mx,my);
        }
        else if(!is_mouse_inside_header && state == BSTATE_ENTER) {
            state = BSTATE_NONE;
            onMouseLeave(mx, my);
        }
    }

    if(is_mouse_down) {
        onMouseDragged(mdx, mdy);
    }

    // check elements when we're opened.
    if(is_open) {
        // check if we are inside an element and dragging...
        Element* e = elements[0];
        Element* el;
        vector<Element*>::iterator it;
        if(is_mouse_down) {
            it = elements.begin();
            while(it != elements.end()) {
                el = *it;
                if(!el->is_visible) {
                    ++it;
                    continue;
                }

                el->onMouseDragged(mx, my, mdx, mdy);
                ++it;
            }
        }

        // call "leave" and "enter"
        it = elements.begin();
        while(it != elements.end()) {
            el = *it;
            if(!el->is_visible) {
                ++it;
                continue;
            }

            el->is_mouse_inside = BINSIDE_ELEMENT(el, mx, my);
            if(el->is_mouse_inside && el->state == BSTATE_NONE) {
                el->state = BSTATE_ENTER;
                el->onMouseEnter(x,y);
            }
            else if(!el->is_mouse_inside && el->state == BSTATE_ENTER) {
                el->state = BSTATE_NONE;
                el->onMouseLeave(mx,my);
            }
            el->onMouseMoved(mx,my);
            ++it;
        }
    }

    // is mouse inside the gui
    int panel_h = getPanelHeight();
    if(mx > x && mx < (x+w) && my > y && my < (y+panel_h)) {
        is_mouse_inside_panel = true;
    }
    else {
        is_mouse_inside_panel = false;
    }

    // keep track of current x and y;
    pmx = mx;
    pmy = my;
}
Esempio n. 3
0
void ContextView::processMouseDragged(sf::Event& event) {
  m_lastMouseEventWasMove = false;

  onMouseDragged(event);
}