diff options
author | jmarshallnz <jmarshallnz@svn> | 2010-02-19 02:55:37 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2010-02-19 02:55:37 +0000 |
commit | 5f22c573c7fbb7a45cf2aaee2e1ddad7bb7899cb (patch) | |
tree | 616c5e8b5f6bb5ee97f4e2ed92ab661d2f22e555 /guilib | |
parent | af22bc05ff517e85698c5618ad0b322706955ed8 (diff) |
cleanup: Move all members of CAction private, accessed via getters, as we only ever set in constructors.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@27962 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
27 files changed, 160 insertions, 117 deletions
diff --git a/guilib/GUIAudioManager.cpp b/guilib/GUIAudioManager.cpp index a6eec09561..8368fc7feb 100644 --- a/guilib/GUIAudioManager.cpp +++ b/guilib/GUIAudioManager.cpp @@ -174,7 +174,7 @@ void CGUIAudioManager::PlayActionSound(const CAction& action) CSingleLock lock(m_cs); - actionSoundMap::iterator it=m_actionSoundMap.find(action.actionId); + actionSoundMap::iterator it=m_actionSoundMap.find(action.GetID()); if (it==m_actionSoundMap.end()) return; diff --git a/guilib/GUIBaseContainer.cpp b/guilib/GUIBaseContainer.cpp index 9407dafff3..102a9f3a32 100644 --- a/guilib/GUIBaseContainer.cpp +++ b/guilib/GUIBaseContainer.cpp @@ -198,13 +198,13 @@ void CGUIBaseContainer::RenderItem(float posX, float posY, CGUIListItem *item, b bool CGUIBaseContainer::OnAction(const CAction &action) { - if (action.actionId >= KEY_ASCII) + if (action.GetID() >= KEY_ASCII) { - OnJumpLetter((char)(action.actionId & 0xff)); + OnJumpLetter((char)(action.GetID() & 0xff)); return true; } - switch (action.actionId) + switch (action.GetID()) { case ACTION_MOVE_LEFT: case ACTION_MOVE_RIGHT: @@ -212,16 +212,16 @@ bool CGUIBaseContainer::OnAction(const CAction &action) case ACTION_MOVE_UP: { if (!HasFocus()) return false; - if (action.holdTime > HOLD_TIME_START && - ((m_orientation == VERTICAL && (action.actionId == ACTION_MOVE_UP || action.actionId == ACTION_MOVE_DOWN)) || - (m_orientation == HORIZONTAL && (action.actionId == ACTION_MOVE_LEFT || action.actionId == ACTION_MOVE_RIGHT)))) + if (action.GetHoldTime() > HOLD_TIME_START && + ((m_orientation == VERTICAL && (action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN)) || + (m_orientation == HORIZONTAL && (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT)))) { // action is held down - repeat a number of times - float speed = std::min(1.0f, (float)(action.holdTime - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START)); + float speed = std::min(1.0f, (float)(action.GetHoldTime() - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START)); unsigned int itemsPerFrame = 1; if (m_lastHoldTime) // number of rows/10 items/second max speed itemsPerFrame = std::max((unsigned int)1, (unsigned int)(speed * 0.0001f * GetRows() * (CTimeUtils::GetFrameTime() - m_lastHoldTime))); m_lastHoldTime = CTimeUtils::GetFrameTime(); - if (action.actionId == ACTION_MOVE_LEFT || action.actionId == ACTION_MOVE_UP) + if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP) while (itemsPerFrame--) MoveUp(false); else while (itemsPerFrame--) MoveDown(false); @@ -265,15 +265,15 @@ bool CGUIBaseContainer::OnAction(const CAction &action) case ACTION_JUMP_SMS8: case ACTION_JUMP_SMS9: { - OnJumpSMS(action.actionId - ACTION_JUMP_SMS2 + 2); + OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2); return true; } break; default: - if (action.actionId) + if (action.GetID()) { - return OnClick(action.actionId); + return OnClick(action.GetID()); } } return false; diff --git a/guilib/GUIButtonControl.cpp b/guilib/GUIButtonControl.cpp index a417b55813..b5e47a2121 100644 --- a/guilib/GUIButtonControl.cpp +++ b/guilib/GUIButtonControl.cpp @@ -122,7 +122,7 @@ void CGUIButtonControl::RenderText() bool CGUIButtonControl::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { OnClick(); return true; diff --git a/guilib/GUIButtonScroller.cpp b/guilib/GUIButtonScroller.cpp index 509b9b6145..2db7e8831f 100644 --- a/guilib/GUIButtonScroller.cpp +++ b/guilib/GUIButtonScroller.cpp @@ -114,7 +114,7 @@ CGUIButtonScroller::~CGUIButtonScroller(void) bool CGUIButtonScroller::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { // send the appropriate message to the parent window vector<CGUIActionDescriptor> actions = m_vecButtons[GetActiveButton()]->clickActions; @@ -127,15 +127,15 @@ bool CGUIButtonScroller::OnAction(const CAction &action) } return true; } - if (action.actionId == ACTION_CONTEXT_MENU) + if (action.GetID() == ACTION_CONTEXT_MENU) { // send a click message to our parent - SEND_CLICK_MESSAGE(GetID(), GetParentID(), action.actionId); + SEND_CLICK_MESSAGE(GetID(), GetParentID(), action.GetID()); return true; } // smooth scrolling (for analog controls) - if (action.actionId == ACTION_SCROLL_UP) + if (action.GetID() == ACTION_SCROLL_UP) { - m_fAnalogScrollSpeed += action.amount1 * action.amount1; + m_fAnalogScrollSpeed += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_fAnalogScrollSpeed > ANALOG_SCROLL_START) { @@ -147,9 +147,9 @@ bool CGUIButtonScroller::OnAction(const CAction &action) } return handled; } - if (action.actionId == ACTION_SCROLL_DOWN) + if (action.GetID() == ACTION_SCROLL_DOWN) { - m_fAnalogScrollSpeed += action.amount1 * action.amount1; + m_fAnalogScrollSpeed += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_fAnalogScrollSpeed > ANALOG_SCROLL_START) { diff --git a/guilib/GUICheckMarkControl.cpp b/guilib/GUICheckMarkControl.cpp index 1ea16a3875..19851496b2 100644 --- a/guilib/GUICheckMarkControl.cpp +++ b/guilib/GUICheckMarkControl.cpp @@ -85,10 +85,10 @@ CGUILabel::COLOR CGUICheckMarkControl::GetTextColor() const bool CGUICheckMarkControl::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { m_bSelected = !m_bSelected; - CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID(), action.actionId); + CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID(), action.GetID()); SendWindowMessage(msg); return true; } diff --git a/guilib/GUIControl.cpp b/guilib/GUIControl.cpp index af5dad0e34..2d6912412c 100644 --- a/guilib/GUIControl.cpp +++ b/guilib/GUIControl.cpp @@ -160,7 +160,7 @@ void CGUIControl::Render() bool CGUIControl::OnAction(const CAction &action) { - switch (action.actionId) + switch (action.GetID()) { case ACTION_MOVE_DOWN: if (!HasFocus()) return false; diff --git a/guilib/GUIDialog.cpp b/guilib/GUIDialog.cpp index 076ae4a27e..52e9dd02cd 100644 --- a/guilib/GUIDialog.cpp +++ b/guilib/GUIDialog.cpp @@ -67,7 +67,7 @@ void CGUIDialog::OnWindowLoaded() bool CGUIDialog::OnAction(const CAction &action) { - if (action.actionId == ACTION_CLOSE_DIALOG || action.actionId == ACTION_PREVIOUS_MENU) + if (action.GetID() == ACTION_CLOSE_DIALOG || action.GetID() == ACTION_PREVIOUS_MENU) { Close(); return true; diff --git a/guilib/GUIEditControl.cpp b/guilib/GUIEditControl.cpp index 6c8fb9c19b..5bb2219197 100644 --- a/guilib/GUIEditControl.cpp +++ b/guilib/GUIEditControl.cpp @@ -98,7 +98,7 @@ bool CGUIEditControl::OnAction(const CAction &action) { ValidateCursor(); - if (action.actionId == ACTION_BACKSPACE) + if (action.GetID() == ACTION_BACKSPACE) { // backspace if (m_cursorPos) @@ -108,7 +108,7 @@ bool CGUIEditControl::OnAction(const CAction &action) } return true; } - else if (action.actionId == ACTION_MOVE_LEFT) + else if (action.GetID() == ACTION_MOVE_LEFT) { if (m_cursorPos > 0) { @@ -117,7 +117,7 @@ bool CGUIEditControl::OnAction(const CAction &action) return true; } } - else if (action.actionId == ACTION_MOVE_RIGHT) + else if (action.GetID() == ACTION_MOVE_RIGHT) { if ((unsigned int) m_cursorPos < m_text2.size()) { @@ -126,14 +126,14 @@ bool CGUIEditControl::OnAction(const CAction &action) return true; } } - else if (action.actionId == ACTION_PASTE) + else if (action.GetID() == ACTION_PASTE) { OnPasteClipboard(); } - else if (action.actionId >= KEY_VKEY && action.actionId < KEY_ASCII) + else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) - BYTE b = action.actionId & 0xFF; + BYTE b = action.GetID() & 0xFF; if (b == 0x24) // home { m_cursorPos = 0; @@ -177,10 +177,10 @@ bool CGUIEditControl::OnAction(const CAction &action) return true; } } - else if (action.actionId >= KEY_ASCII) + else if (action.GetID() >= KEY_ASCII) { // input from the keyboard - switch (action.unicode) + switch (action.GetUnicode()) { case '\t': break; @@ -206,22 +206,22 @@ bool CGUIEditControl::OnAction(const CAction &action) } default: { - m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.unicode); + m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.GetUnicode()); break; } } UpdateText(); return true; } - else if (action.actionId >= REMOTE_0 && action.actionId <= REMOTE_9) + else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { // input from the remote if (m_inputType == INPUT_TYPE_FILTER) { // filtering - use single number presses - m_text2.insert(m_text2.begin() + m_cursorPos++, L'0' + (action.actionId - REMOTE_0)); + m_text2.insert(m_text2.begin() + m_cursorPos++, L'0' + (action.GetID() - REMOTE_0)); UpdateText(); } else - OnSMSCharacter(action.actionId - REMOTE_0); + OnSMSCharacter(action.GetID() - REMOTE_0); return true; } return CGUIButtonControl::OnAction(action); diff --git a/guilib/GUIFixedListContainer.cpp b/guilib/GUIFixedListContainer.cpp index ba00782660..d8076c917a 100644 --- a/guilib/GUIFixedListContainer.cpp +++ b/guilib/GUIFixedListContainer.cpp @@ -40,7 +40,7 @@ CGUIFixedListContainer::~CGUIFixedListContainer(void) bool CGUIFixedListContainer::OnAction(const CAction &action) { - switch (action.actionId) + switch (action.GetID()) { case ACTION_PAGE_UP: { @@ -57,7 +57,7 @@ bool CGUIFixedListContainer::OnAction(const CAction &action) // smooth scrolling (for analog controls) case ACTION_SCROLL_UP: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { @@ -70,7 +70,7 @@ bool CGUIFixedListContainer::OnAction(const CAction &action) break; case ACTION_SCROLL_DOWN: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { diff --git a/guilib/GUIListContainer.cpp b/guilib/GUIListContainer.cpp index 4f4a7b1b94..7a9d9ddda8 100644 --- a/guilib/GUIListContainer.cpp +++ b/guilib/GUIListContainer.cpp @@ -37,7 +37,7 @@ CGUIListContainer::~CGUIListContainer(void) bool CGUIListContainer::OnAction(const CAction &action) { - switch (action.actionId) + switch (action.GetID()) { case ACTION_PAGE_UP: { @@ -68,7 +68,7 @@ bool CGUIListContainer::OnAction(const CAction &action) // smooth scrolling (for analog controls) case ACTION_SCROLL_UP: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { @@ -88,7 +88,7 @@ bool CGUIListContainer::OnAction(const CAction &action) break; case ACTION_SCROLL_DOWN: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { diff --git a/guilib/GUIMoverControl.cpp b/guilib/GUIMoverControl.cpp index cf0fd93379..bdf7999878 100644 --- a/guilib/GUIMoverControl.cpp +++ b/guilib/GUIMoverControl.cpp @@ -85,21 +85,21 @@ void CGUIMoverControl::Render() bool CGUIMoverControl::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { // button selected - send message to parent CGUIMessage message(GUI_MSG_CLICKED, GetID(), GetParentID()); SendWindowMessage(message); return true; } - if (action.actionId == ACTION_ANALOG_MOVE) + if (action.GetID() == ACTION_ANALOG_MOVE) { // if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_UPDOWN) - // Move(0, (int)(-m_fAnalogSpeed*action.amount2)); + // Move(0, (int)(-m_fAnalogSpeed*action.GetAmount(1))); // else if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_LEFTRIGHT) - // Move((int)(m_fAnalogSpeed*action.amount1), 0); + // Move((int)(m_fAnalogSpeed*action.GetAmount()), 0); // else // ALLOWED_DIRECTIONS_ALL - Move((int)(m_fAnalogSpeed*action.amount1), (int)( -m_fAnalogSpeed*action.amount2)); + Move((int)(m_fAnalogSpeed*action.GetAmount()), (int)( -m_fAnalogSpeed*action.GetAmount(1))); return true; } // base class diff --git a/guilib/GUIMultiSelectText.cpp b/guilib/GUIMultiSelectText.cpp index bc70d5e979..4cb80714f0 100644 --- a/guilib/GUIMultiSelectText.cpp +++ b/guilib/GUIMultiSelectText.cpp @@ -156,7 +156,7 @@ void CGUIMultiSelectTextControl::UpdateInfo(const CGUIListItem *item) bool CGUIMultiSelectTextControl::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { // item is clicked - see if we have a clickaction CStdString clickAction; diff --git a/guilib/GUIPanelContainer.cpp b/guilib/GUIPanelContainer.cpp index 9fd012c81e..cd5bd88287 100644 --- a/guilib/GUIPanelContainer.cpp +++ b/guilib/GUIPanelContainer.cpp @@ -120,7 +120,7 @@ void CGUIPanelContainer::Render() bool CGUIPanelContainer::OnAction(const CAction &action) { - switch (action.actionId) + switch (action.GetID()) { case ACTION_PAGE_UP: { @@ -151,7 +151,7 @@ bool CGUIPanelContainer::OnAction(const CAction &action) // smooth scrolling (for analog controls) case ACTION_SCROLL_UP: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > AnalogScrollSpeed()) { @@ -171,7 +171,7 @@ bool CGUIPanelContainer::OnAction(const CAction &action) break; case ACTION_SCROLL_DOWN: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > AnalogScrollSpeed()) { diff --git a/guilib/GUIRadioButtonControl.cpp b/guilib/GUIRadioButtonControl.cpp index c928ad8ce5..510b66e514 100644 --- a/guilib/GUIRadioButtonControl.cpp +++ b/guilib/GUIRadioButtonControl.cpp @@ -60,7 +60,7 @@ void CGUIRadioButtonControl::Render() bool CGUIRadioButtonControl::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { m_bSelected = !m_bSelected; } diff --git a/guilib/GUIResizeControl.cpp b/guilib/GUIResizeControl.cpp index 8ca728ef5c..c71dd8b738 100644 --- a/guilib/GUIResizeControl.cpp +++ b/guilib/GUIResizeControl.cpp @@ -84,16 +84,16 @@ void CGUIResizeControl::Render() bool CGUIResizeControl::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { // button selected - send message to parent CGUIMessage message(GUI_MSG_CLICKED, GetID(), GetParentID()); SendWindowMessage(message); return true; } - if (action.actionId == ACTION_ANALOG_MOVE) + if (action.GetID() == ACTION_ANALOG_MOVE) { - Resize(m_fAnalogSpeed*action.amount1, -m_fAnalogSpeed*action.amount2); + Resize(m_fAnalogSpeed*action.GetAmount(), -m_fAnalogSpeed*action.GetAmount(1)); return true; } return CGUIControl::OnAction(action); diff --git a/guilib/GUIScrollBarControl.cpp b/guilib/GUIScrollBarControl.cpp index a4b1a39bb0..9107b7c13c 100644 --- a/guilib/GUIScrollBarControl.cpp +++ b/guilib/GUIScrollBarControl.cpp @@ -89,7 +89,7 @@ bool CGUIScrollBar::OnMessage(CGUIMessage& message) bool CGUIScrollBar::OnAction(const CAction &action) { - switch ( action.actionId ) + switch ( action.GetID() ) { case ACTION_MOVE_LEFT: if (m_orientation == HORIZONTAL) diff --git a/guilib/GUISelectButtonControl.cpp b/guilib/GUISelectButtonControl.cpp index 30c220af37..e3a73f2f5f 100644 --- a/guilib/GUISelectButtonControl.cpp +++ b/guilib/GUISelectButtonControl.cpp @@ -189,7 +189,7 @@ bool CGUISelectButtonControl::OnAction(const CAction &action) { if (!m_bShowSelect) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { // Enter selection mode m_bShowSelect = true; @@ -205,7 +205,7 @@ bool CGUISelectButtonControl::OnAction(const CAction &action) } else { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { // User has selected an item, disable selection mode... m_bShowSelect = false; @@ -215,7 +215,7 @@ bool CGUISelectButtonControl::OnAction(const CAction &action) SendWindowMessage(message); return true; } - if (action.actionId == ACTION_MOVE_UP || action.actionId == ACTION_MOVE_DOWN ) + if (action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN ) { // Disable selection mode when moving up or down m_bShowSelect = false; diff --git a/guilib/GUISliderControl.cpp b/guilib/GUISliderControl.cpp index 59a6474bbd..73b58ac147 100644 --- a/guilib/GUISliderControl.cpp +++ b/guilib/GUISliderControl.cpp @@ -128,7 +128,7 @@ bool CGUISliderControl::OnMessage(CGUIMessage& message) bool CGUISliderControl::OnAction(const CAction &action) { - switch ( action.actionId ) + switch ( action.GetID() ) { case ACTION_MOVE_LEFT: //case ACTION_OSD_SHOW_VALUE_MIN: diff --git a/guilib/GUISpinControl.cpp b/guilib/GUISpinControl.cpp index b8380efcb3..59676da085 100644 --- a/guilib/GUISpinControl.cpp +++ b/guilib/GUISpinControl.cpp @@ -62,7 +62,7 @@ CGUISpinControl::~CGUISpinControl(void) bool CGUISpinControl::OnAction(const CAction &action) { - switch (action.actionId) + switch (action.GetID()) { case REMOTE_0: case REMOTE_1: @@ -80,7 +80,7 @@ bool CGUISpinControl::OnAction(const CAction &action) m_iTypedPos = 0; strcpy(m_szTyped, ""); } - int iNumber = action.actionId - REMOTE_0; + int iNumber = action.GetID() - REMOTE_0; m_szTyped[m_iTypedPos] = iNumber + '0'; m_iTypedPos++; @@ -165,9 +165,9 @@ bool CGUISpinControl::OnAction(const CAction &action) break; } /* static float m_fSmoothScrollOffset = 0.0f; - if (action.actionId == ACTION_SCROLL_UP) + if (action.GetID() == ACTION_SCROLL_UP) { - m_fSmoothScrollOffset += action.amount1 * action.amount1; + m_fSmoothScrollOffset += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_fSmoothScrollOffset > 0.4) { diff --git a/guilib/GUIStandardWindow.cpp b/guilib/GUIStandardWindow.cpp index 05aa97b09d..d4f039fc58 100644 --- a/guilib/GUIStandardWindow.cpp +++ b/guilib/GUIStandardWindow.cpp @@ -34,13 +34,13 @@ CGUIStandardWindow::~CGUIStandardWindow(void) bool CGUIStandardWindow::OnAction(const CAction &action) { - if (action.actionId == ACTION_PREVIOUS_MENU) + if (action.GetID() == ACTION_PREVIOUS_MENU) { g_windowManager.PreviousWindow(); return true; } - if (action.actionId == ACTION_PARENT_DIR && g_advancedSettings.m_bUseEvilB) + if (action.GetID() == ACTION_PARENT_DIR && g_advancedSettings.m_bUseEvilB) { g_windowManager.PreviousWindow(); return true; diff --git a/guilib/GUIToggleButtonControl.cpp b/guilib/GUIToggleButtonControl.cpp index be669c79ba..a29efa0447 100644 --- a/guilib/GUIToggleButtonControl.cpp +++ b/guilib/GUIToggleButtonControl.cpp @@ -63,7 +63,7 @@ void CGUIToggleButtonControl::Render() bool CGUIToggleButtonControl::OnAction(const CAction &action) { - if (action.actionId == ACTION_SELECT_ITEM) + if (action.GetID() == ACTION_SELECT_ITEM) { m_bSelected = !m_bSelected; } diff --git a/guilib/GUIVisualisationControl.cpp b/guilib/GUIVisualisationControl.cpp index 6f5e7b3144..0783c866d7 100644 --- a/guilib/GUIVisualisationControl.cpp +++ b/guilib/GUIVisualisationControl.cpp @@ -352,17 +352,17 @@ bool CGUIVisualisationControl::OnAction(const CAction &action) { if (!m_pVisualisation) return false; enum CVisualisation::VIS_ACTION visAction = CVisualisation::VIS_ACTION_NONE; - if (action.actionId == ACTION_VIS_PRESET_NEXT) + if (action.GetID() == ACTION_VIS_PRESET_NEXT) visAction = CVisualisation::VIS_ACTION_NEXT_PRESET; - else if (action.actionId == ACTION_VIS_PRESET_PREV) + else if (action.GetID() == ACTION_VIS_PRESET_PREV) visAction = CVisualisation::VIS_ACTION_PREV_PRESET; - else if (action.actionId == ACTION_VIS_PRESET_LOCK) + else if (action.GetID() == ACTION_VIS_PRESET_LOCK) visAction = CVisualisation::VIS_ACTION_LOCK_PRESET; - else if (action.actionId == ACTION_VIS_PRESET_RANDOM) + else if (action.GetID() == ACTION_VIS_PRESET_RANDOM) visAction = CVisualisation::VIS_ACTION_RANDOM_PRESET; - else if (action.actionId == ACTION_VIS_RATE_PRESET_PLUS) + else if (action.GetID() == ACTION_VIS_RATE_PRESET_PLUS) visAction = CVisualisation::VIS_ACTION_RATE_PRESET_PLUS; - else if (action.actionId == ACTION_VIS_RATE_PRESET_MINUS) + else if (action.GetID() == ACTION_VIS_RATE_PRESET_MINUS) visAction = CVisualisation::VIS_ACTION_RATE_PRESET_MINUS; return m_pVisualisation->OnAction(visAction); diff --git a/guilib/GUIWindow.cpp b/guilib/GUIWindow.cpp index 725f14f6e5..a16050a1a9 100644 --- a/guilib/GUIWindow.cpp +++ b/guilib/GUIWindow.cpp @@ -336,7 +336,7 @@ void CGUIWindow::Close(bool forceClose) bool CGUIWindow::OnAction(const CAction &action) { - if (action.actionId == ACTION_MOUSE) + if (action.GetID() == ACTION_MOUSE) return OnMouseAction(); CGUIControl *focusedControl = GetFocusedControl(); diff --git a/guilib/GUIWindowManager.cpp b/guilib/GUIWindowManager.cpp index 10999c96d4..873665b718 100644 --- a/guilib/GUIWindowManager.cpp +++ b/guilib/GUIWindowManager.cpp @@ -456,7 +456,7 @@ bool CGUIWindowManager::OnAction(const CAction &action) } // music or video overlay are handled as a special case, as they're modeless, but we allow // clicking on them with the mouse. - if (action.actionId == ACTION_MOUSE && (dialog->GetID() == WINDOW_VIDEO_OVERLAY || + if (action.GetID() == ACTION_MOUSE && (dialog->GetID() == WINDOW_VIDEO_OVERLAY || dialog->GetID() == WINDOW_MUSIC_OVERLAY)) { if (dialog->OnAction(action)) diff --git a/guilib/GUIWrappingListContainer.cpp b/guilib/GUIWrappingListContainer.cpp index a9b972a6d3..7a5520696d 100644 --- a/guilib/GUIWrappingListContainer.cpp +++ b/guilib/GUIWrappingListContainer.cpp @@ -48,7 +48,7 @@ void CGUIWrappingListContainer::UpdatePageControl(int offset) bool CGUIWrappingListContainer::OnAction(const CAction &action) { - switch (action.actionId) + switch (action.GetID()) { case ACTION_PAGE_UP: Scroll(-m_itemsPerPage); @@ -59,7 +59,7 @@ bool CGUIWrappingListContainer::OnAction(const CAction &action) // smooth scrolling (for analog controls) case ACTION_SCROLL_UP: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { @@ -72,7 +72,7 @@ bool CGUIWrappingListContainer::OnAction(const CAction &action) break; case ACTION_SCROLL_DOWN: { - m_analogScrollCount += action.amount1 * action.amount1; + m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { diff --git a/guilib/Key.cpp b/guilib/Key.cpp index 07d7441838..c54cc7e2cc 100644 --- a/guilib/Key.cpp +++ b/guilib/Key.cpp @@ -163,57 +163,60 @@ unsigned int CKey::GetHeld() const return m_held; } -CAction::CAction(int actionID, float _amount1 /* = 1.0f */, float _amount2 /* = 0.0f */, const CStdString &name /* = "" */) +CAction::CAction(int actionID, float amount1 /* = 1.0f */, float amount2 /* = 0.0f */, const CStdString &name /* = "" */) { - actionId = actionID; - amount1 = _amount1; - amount2 = _amount2; - strAction = name; - repeat = 0; - buttonCode = 0; - unicode = 0; - holdTime = 0; + m_id = actionID; + m_amount[0] = amount1; + m_amount[1] = amount2; + for (unsigned int i = 2; i < max_amounts; i++) + m_amount[i] = 0; + m_name = name; + m_repeat = 0; + m_buttonCode = 0; + m_unicode = 0; + m_holdTime = 0; } CAction::CAction(int actionID, const CStdString &name, const CKey &key) { - actionId = actionID; - strAction = name; - amount1 = 1; // digital button (could change this for repeat acceleration) - amount2 = 0; - repeat = key.GetRepeat(); - buttonCode = key.GetButtonCode(); - unicode = 0; - holdTime = key.GetHeld(); + m_id = actionID; + m_name = name; + m_amount[0] = 1; // digital button (could change this for repeat acceleration) + for (unsigned int i = 1; i < max_amounts; i++) + m_amount[i] = 0; + m_repeat = key.GetRepeat(); + m_buttonCode = key.GetButtonCode(); + m_unicode = 0; + m_holdTime = key.GetHeld(); // get the action amounts of the analog buttons if (key.GetButtonCode() == KEY_BUTTON_LEFT_ANALOG_TRIGGER) - amount1 = (float)key.GetLeftTrigger() / 255.0f; + m_amount[0] = (float)key.GetLeftTrigger() / 255.0f; else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_ANALOG_TRIGGER) - amount1 = (float)key.GetRightTrigger() / 255.0f; + m_amount[0] = (float)key.GetRightTrigger() / 255.0f; else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK) { - amount1 = key.GetLeftThumbX(); - amount2 = key.GetLeftThumbY(); + m_amount[0] = key.GetLeftThumbX(); + m_amount[1] = key.GetLeftThumbY(); } else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK) { - amount1 = key.GetRightThumbX(); - amount2 = key.GetRightThumbY(); + m_amount[0] = key.GetRightThumbX(); + m_amount[1] = key.GetRightThumbY(); } else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_UP) - amount1 = key.GetLeftThumbY(); + m_amount[0] = key.GetLeftThumbY(); else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_DOWN) - amount1 = -key.GetLeftThumbY(); + m_amount[0] = -key.GetLeftThumbY(); else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_LEFT) - amount1 = -key.GetLeftThumbX(); + m_amount[0] = -key.GetLeftThumbX(); else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_RIGHT) - amount1 = key.GetLeftThumbX(); + m_amount[0] = key.GetLeftThumbX(); else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_UP) - amount1 = key.GetRightThumbY(); + m_amount[0] = key.GetRightThumbY(); else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_DOWN) - amount1 = -key.GetRightThumbY(); + m_amount[0] = -key.GetRightThumbY(); else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_LEFT) - amount1 = -key.GetRightThumbX(); + m_amount[0] = -key.GetRightThumbX(); else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT) - amount1 = key.GetRightThumbX(); + m_amount[0] = key.GetRightThumbX(); } diff --git a/guilib/Key.h b/guilib/Key.h index d210045ab1..24654b6966 100644 --- a/guilib/Key.h +++ b/guilib/Key.h @@ -404,14 +404,54 @@ class CAction public: CAction(int actionID, float amount1 = 1.0f, float amount2 = 0.0f, const CStdString &name = ""); CAction(int actionID, const CStdString &name, const CKey &key); - int actionId; - float amount1; - float amount2; - float repeat; - unsigned int buttonCode; - CStdString strAction; - wchar_t unicode; // new feature, does not fit into id like ASCII, wouldn't be good design either!? Will be set whenever ASCII is set into id (for backwards compatibility) - unsigned int holdTime; ///< Time the key has been held down (in ms) + + /*! \brief Identifier of the action + \return id of the action + */ + int GetID() const { return m_id; }; + + /*! \brief Human-readable name of the action + \return name of the action + */ + const CStdString &GetName() const { return m_name; }; + + /*! \brief Get an amount associated with this action + \param zero-based index of amount to retrieve, defaults to 0 + \return an amount associated with this action + */ + float GetAmount(unsigned int index = 0) const { return (index < max_amounts) ? m_amount[index] : 0; }; + + /*! \brief Unicode value associated with this action + \return unicode value associated with this action, for keyboard input. + */ + wchar_t GetUnicode() const { return m_unicode; }; + + /*! \brief Time in ms that the key has been held + \return time that the key has been held down in ms. + */ + unsigned int GetHoldTime() const { return m_holdTime; }; + + /*! \brief Time since last repeat in ms + \return time since last repeat in ms. Returns 0 if unknown. + */ + float GetRepeat() const { return m_repeat; }; + + /*! \brief Button code that triggered this action + \return button code + */ + unsigned int GetButtonCode() const { return m_buttonCode; }; + +private: + int m_id; + CStdString m_name; + + static const unsigned int max_amounts = 2; // Must be at least 2. + float m_amount[max_amounts]; + + float m_repeat; + unsigned int m_holdTime; + unsigned int m_buttonCode; + wchar_t m_unicode; }; /*! |