Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | if (ev->ev.type == SDL_MOUSEBUTTONDOWN) | ||||
ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_LEFT, "mouseleftpress"); | ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_LEFT, "mouseleftpress"); | ||||
break; | break; | ||||
case SDL_BUTTON_RIGHT: | case SDL_BUTTON_RIGHT: | ||||
if (pNearest) | if (pNearest) | ||||
ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_RIGHT, "mouserightpress"); | ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_RIGHT, "mouserightpress"); | ||||
break; | break; | ||||
case SDL_BUTTON_MIDDLE: | |||||
vladislavbelov: Too many of the same code. Maybe remove the duplication here and below? | |||||
if (pNearest) | |||||
ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_MIDDLE, "mousemiddlepress"); | |||||
break; | |||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
else if (ev->ev.type == SDL_MOUSEWHEEL && pNearest) | else if (ev->ev.type == SDL_MOUSEWHEEL && pNearest) | ||||
{ | { | ||||
if (ev->ev.wheel.y < 0) | if (ev->ev.wheel.y < 0) | ||||
ret = pNearest->SendEvent(GUIM_MOUSE_WHEEL_DOWN, "mousewheeldown"); | ret = pNearest->SendEvent(GUIM_MOUSE_WHEEL_DOWN, "mousewheeldown"); | ||||
Show All 23 Lines | else if (ev->ev.type == SDL_MOUSEBUTTONUP) | ||||
pNearest->m_LastClickTime[SDL_BUTTON_RIGHT] = timer_Time(); | pNearest->m_LastClickTime[SDL_BUTTON_RIGHT] = timer_Time(); | ||||
if (timeElapsed < SELECT_DBLCLICK_RATE) | if (timeElapsed < SELECT_DBLCLICK_RATE) | ||||
ret = pNearest->SendEvent(GUIM_MOUSE_DBLCLICK_RIGHT, "mouserightdoubleclick"); | ret = pNearest->SendEvent(GUIM_MOUSE_DBLCLICK_RIGHT, "mouserightdoubleclick"); | ||||
else | else | ||||
ret = pNearest->SendEvent(GUIM_MOUSE_RELEASE_RIGHT, "mouserightrelease"); | ret = pNearest->SendEvent(GUIM_MOUSE_RELEASE_RIGHT, "mouserightrelease"); | ||||
} | } | ||||
break; | break; | ||||
case SDL_BUTTON_MIDDLE: | |||||
if (pNearest) | |||||
{ | |||||
double timeElapsed = timer_Time() - pNearest->m_LastClickTime[SDL_BUTTON_MIDDLE]; | |||||
pNearest->m_LastClickTime[SDL_BUTTON_MIDDLE] = timer_Time(); | |||||
if (timeElapsed < SELECT_DBLCLICK_RATE) | |||||
ret = pNearest->SendEvent(GUIM_MOUSE_DBLCLICK_MIDDLE, "mousemiddledoubleclick"); | |||||
else | |||||
ret = pNearest->SendEvent(GUIM_MOUSE_RELEASE_MIDDLE, "mousemiddlerelease"); | |||||
} | |||||
break; | |||||
Not Done Inline ActionsWhen I saw this in D1751 I also thought to remove this triplicated hunk, but there are too many constants to make this immediately worthwhile. elexis: When I saw this in D1751 I also thought to remove this triplicated hunk, but there are too many… | |||||
Not Done Inline Actions
It won't be an easy task. We make solve it with keyboard settings to detect any pressed key. vladislavbelov: > I guess mouses are not limited to 3 buttons as they are not limited to 2 buttons, so one… | |||||
} | } | ||||
// Reset all states on all visible objects | // Reset all states on all visible objects | ||||
GUI<>::RecurseObject(GUIRR_HIDDEN, m_BaseObject, | GUI<>::RecurseObject(GUIRR_HIDDEN, m_BaseObject, | ||||
&IGUIObject::ResetStates); | &IGUIObject::ResetStates); | ||||
// Since the hover state will have been reset, we reload it. | // Since the hover state will have been reset, we reload it. | ||||
GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, | GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, | ||||
▲ Show 20 Lines • Show All 1,549 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Too many of the same code. Maybe remove the duplication here and below?