Ticket #850: minimap_ticket850.patch

File minimap_ticket850.patch, 3.5 KB (added by Yves, 13 years ago)
  • gui/CGUI.cpp

     
    132132        // TODO Gee: Optimizations needed!
    133133        //  these two recursive function are quite overhead heavy.
    134134
    135         // pNearest will after this point at the hovered object, possibly NULL
    136         pNearest = FindObjectUnderMouse();
     135        // If no object is currently capturing the mouse, pNearest will point at the topmost hovered object, possibly NULL.
     136        if (m_MouseCapturingObject == NULL)
     137            pNearest = FindObjectUnderMouse();
     138        else
     139            pNearest = m_MouseCapturingObject;
    137140
    138141        // Is placed in the UpdateMouseOver function
    139142        //if (ev->ev.type == SDL_MOUSEMOTION && pNearest)
     
    157160
    158161                if (pNearest)
    159162                {
     163                    // Should this GUIObject capture all mouse-input until the left mouse-button is released again?
     164                    if(pNearest->DoesCaptureMouse())
     165                        m_MouseCapturingObject = pNearest;
     166
    160167                    ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_LEFT, "mouseleftpress");
    161168                }
    162169                break;
     
    206213                    {
    207214                        ret = pNearest->SendEvent(GUIM_MOUSE_RELEASE_LEFT, "mouseleftrelease");
    208215                    }
     216                    // Stop capturing
     217                    m_MouseCapturingObject = NULL;
    209218                }
    210219                break;
    211220            case SDL_BUTTON_RIGHT:
     
    382391    NULL, NULL, NULL, NULL
    383392};
    384393
    385 CGUI::CGUI() : m_MouseButtons(0), m_FocusedObject(NULL), m_InternalNameNumber(0)
     394CGUI::CGUI() : m_MouseButtons(0), m_FocusedObject(NULL), m_MouseCapturingObject(NULL), m_InternalNameNumber(0)
    386395{
    387396    m_BaseObject = new CGUIDummyObject;
    388397    m_BaseObject->SetGUI(this);
  • gui/IGUIObject.h

     
    405405     */
    406406    void SetFocus();
    407407
     408    bool DoesCaptureMouse() { return m_CaptureMouseAfterLMBClick; }
     409
    408410protected:
    409411    /**
    410412     * Check if object is focused.
     
    549551
    550552    // Is mouse hovering the object? used with the function MouseOver()
    551553    bool                                    m_MouseHovering;
     554   
     555    // Still receive mouse input after click-dragging the cursor out of the GUIObject until
     556    // LMB is released?
     557    bool m_CaptureMouseAfterLMBClick;
    552558
    553559    /**
    554560     * Settings pool, all an object's settings are located here
  • gui/IGUIObject.cpp

     
    4444    m_pGUI(NULL),
    4545    m_pParent(NULL),
    4646    m_MouseHovering(false),
    47     m_JSObject(NULL)
     47    m_JSObject(NULL),
     48    m_CaptureMouseAfterLMBClick(false)
    4849{
    4950    AddSetting(GUIST_bool,          "enabled");
    5051    AddSetting(GUIST_bool,          "hidden");
  • gui/MiniMap.cpp

     
    6060    AddSetting(GUIST_CStr,      "tooltip_style");
    6161    m_Clicking = false;
    6262    m_Hovering = false;
     63    m_CaptureMouseAfterLMBClick = true;
    6364}
    6465
    6566CMiniMap::~CMiniMap()
     
    105106        }
    106107    case GUIM_MOUSE_LEAVE:
    107108        {
    108             m_Clicking = false;
    109109            m_Hovering = false;
    110110            break;
    111111        }
  • gui/CGUI.h

     
    629629     */
    630630    IGUIObject* m_FocusedObject;
    631631
     632    /**
     633     * Object that captures all mouse input.
     634     * This is currently only needed for the minimap.
     635     */
     636    IGUIObject* m_MouseCapturingObject;
     637
    632638    /**
    633639     * Just pointers for fast name access, each object
    634640     * is really constructed within its parent for easy