Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CDropDown.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
CDropDown::~CDropDown() | CDropDown::~CDropDown() | ||||
{ | { | ||||
} | } | ||||
void CDropDown::SetupText() | void CDropDown::SetupText() | ||||
{ | { | ||||
SetupListRect(); | SetupListRect(); | ||||
vladislavbelov: What's the reason to make this `if`? At least in this place. We don't use GUI here and deeper… | |||||
CList::SetupText(); | CList::SetupText(); | ||||
} | } | ||||
void CDropDown::UpdateCachedSize() | void CDropDown::UpdateCachedSize() | ||||
{ | { | ||||
CList::UpdateCachedSize(); | CList::UpdateCachedSize(); | ||||
SetupText(); | SetupText(); | ||||
} | } | ||||
void CDropDown::HandleMessage(SGUIMessage& Message) | void CDropDown::HandleMessage(SGUIMessage& Message) | ||||
{ | { | ||||
// Important | // Important | ||||
switch (Message.type) | switch (Message.type) | ||||
{ | { | ||||
case GUIM_SETTINGS_UPDATED: | case GUIM_SETTINGS_UPDATED: | ||||
{ | { | ||||
// Update cached list rect | // Update cached list rect | ||||
if (Message.value == "size" || | if (Message.value == "size" || | ||||
Message.value == "absolute" || | Message.value == "absolute" || | ||||
Message.value == "dropdown_size" || | Message.value == "dropdown_size" || | ||||
Message.value == "dropdown_buffer" || | Message.value == "dropdown_buffer" || | ||||
Message.value == "scrollbar_style" || | Message.value == "scrollbar_style" || | ||||
Message.value == "scrollbar" || | |||||
Message.value == "button_width") | Message.value == "button_width") | ||||
{ | { | ||||
SetupListRect(); | SetupListRect(); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
Show All 17 Lines | case GUIM_MOUSE_MOTION: | ||||
CRect rect = GetListRect(); | CRect rect = GetListRect(); | ||||
mouse.y += scroll; | mouse.y += scroll; | ||||
int set = -1; | int set = -1; | ||||
for (int i = 0; i < (int)pList->m_Items.size(); ++i) | for (int i = 0; i < (int)pList->m_Items.size(); ++i) | ||||
{ | { | ||||
if (mouse.y >= rect.top + m_ItemsYPositions[i] && | if (mouse.y >= rect.top + m_ItemsYPositions[i] && | ||||
mouse.y < rect.top + m_ItemsYPositions[i+1] && | mouse.y < rect.top + m_ItemsYPositions[i+1] && | ||||
// mouse is not over scroll-bar | // Mouse is not over scrollbar | ||||
(m_HideScrollBar || | (m_HideScrollBar || | ||||
mouse.x < GetScrollBar(0).GetOuterRect().left || | mouse.x < GetScrollBar(0).GetOuterRect().left || | ||||
mouse.x > GetScrollBar(0).GetOuterRect().right)) | mouse.x > GetScrollBar(0).GetOuterRect().right)) | ||||
{ | { | ||||
set = i; | set = i; | ||||
} | } | ||||
} | } | ||||
Show All 29 Lines | if (!enabled) | ||||
break; | break; | ||||
CStrW soundPath; | CStrW soundPath; | ||||
if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_leave", soundPath) == PSRETURN_OK && !soundPath.empty()) | if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_leave", soundPath) == PSRETURN_OK && !soundPath.empty()) | ||||
g_SoundManager->PlayAsUI(soundPath.c_str(), false); | g_SoundManager->PlayAsUI(soundPath.c_str(), false); | ||||
break; | break; | ||||
} | } | ||||
// We can't inherent this routine from CList, because we need to include | // We can't inherit this routine from CList, because we need to include | ||||
// a mouse click to open the dropdown, also the coordinates are changed. | // a mouse click to open the dropdown. Also, the coordinates are changed. | ||||
case GUIM_MOUSE_PRESS_LEFT: | case GUIM_MOUSE_PRESS_LEFT: | ||||
{ | { | ||||
bool enabled; | bool enabled; | ||||
GUI<bool>::GetSetting(this, "enabled", enabled); | GUI<bool>::GetSetting(this, "enabled", enabled); | ||||
if (!enabled) | if (!enabled) | ||||
{ | { | ||||
CStrW soundPath; | CStrW soundPath; | ||||
if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_disabled", soundPath) == PSRETURN_OK && !soundPath.empty()) | if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_disabled", soundPath) == PSRETURN_OK && !soundPath.empty()) | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev) | ||||
if (update_highlight) | if (update_highlight) | ||||
GUI<int>::GetSetting(this, "selected", m_ElementHighlight); | GUI<int>::GetSetting(this, "selected", m_ElementHighlight); | ||||
return result; | return result; | ||||
} | } | ||||
void CDropDown::SetupListRect() | void CDropDown::SetupListRect() | ||||
{ | { | ||||
if (!GetGUI()) | |||||
return; | |||||
float size, buffer; | float size, buffer; | ||||
GUI<float>::GetSetting(this, "dropdown_size", size); | GUI<float>::GetSetting(this, "dropdown_size", size); | ||||
GUI<float>::GetSetting(this, "dropdown_buffer", buffer); | GUI<float>::GetSetting(this, "dropdown_buffer", buffer); | ||||
if (m_ItemsYPositions.empty() || m_ItemsYPositions.back() >= size) | if (m_ItemsYPositions.empty() || m_ItemsYPositions.back() >= size) | ||||
{ | { | ||||
m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom+buffer, | m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom+buffer, | ||||
m_CachedActualSize.right, m_CachedActualSize.bottom+buffer + size); | m_CachedActualSize.right, m_CachedActualSize.bottom+buffer + size); | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
What's the reason to make this if? At least in this place. We don't use GUI here and deeper too, mostly on the draw part.