Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 144 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; | |||||
elexisUnsubmitted 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… | |||||
vladislavbelovUnsubmitted 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,537 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Too many of the same code. Maybe remove the duplication here and below?