bool CGUIWindowFullScreen::OnAction(const CAction &action) { if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH) && g_infoManager.IsPlayerChannelPreviewActive() && (action.GetID() == ACTION_SELECT_ITEM || CButtonTranslator::GetInstance().GetGlobalAction(action.GetButtonCode()).GetID() == ACTION_SELECT_ITEM)) { // If confirm channel switch is active, channel preview is currently shown // and the button that caused this action matches (global) action "Select" (OK) // switch to the channel currently displayed within the preview. g_application.m_pPlayer->SwitchChannel(g_application.CurrentFileItem().GetPVRChannelInfoTag()); return true; } switch (action.GetID()) { case ACTION_SHOW_OSD: ToggleOSD(); return true; case ACTION_TRIGGER_OSD: TriggerOSD(); return true; case ACTION_SHOW_GUI: { // switch back to the menu g_windowManager.PreviousWindow(); return true; } break; case ACTION_SHOW_OSD_TIME: m_bShowCurrentTime = !m_bShowCurrentTime; g_infoManager.SetShowTime(m_bShowCurrentTime); return true; break; case ACTION_SHOW_INFO: { CGUIDialogFullScreenInfo* pDialog = (CGUIDialogFullScreenInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) { CFileItem item(g_application.CurrentFileItem()); pDialog->Open(); return true; } break; } case ACTION_ASPECT_RATIO: { // toggle the aspect ratio mode (only if the info is onscreen) if (m_bShowViewModeInfo) { #ifdef HAS_VIDEO_PLAYBACK g_application.m_pPlayer->SetRenderViewMode(CViewModeSettings::GetNextQuickCycleViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode)); #endif } m_bShowViewModeInfo = true; m_dwShowViewModeTimeout = XbmcThreads::SystemClockMillis(); } return true; break; case ACTION_SHOW_PLAYLIST: { CFileItem item(g_application.CurrentFileItem()); if (item.HasPVRChannelInfoTag()) g_windowManager.ActivateWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS); else if (item.HasVideoInfoTag()) g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST); else if (item.HasMusicInfoTag()) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); } return true; break; default: break; } return CGUIWindow::OnAction(action); }
bool CGUISpinControl::OnAction(const CAction &action) { switch (action.GetID()) { case REMOTE_0: case REMOTE_1: case REMOTE_2: case REMOTE_3: case REMOTE_4: case REMOTE_5: case REMOTE_6: case REMOTE_7: case REMOTE_8: case REMOTE_9: { if (strlen(m_szTyped) >= 3) { m_iTypedPos = 0; strcpy(m_szTyped, ""); } int iNumber = action.GetID() - REMOTE_0; m_szTyped[m_iTypedPos] = iNumber + '0'; m_iTypedPos++; m_szTyped[m_iTypedPos] = 0; int iValue; sscanf(m_szTyped, "%i", &iValue); switch (m_iType) { case SPIN_CONTROL_TYPE_INT: { if (iValue < m_iStart || iValue > m_iEnd) { m_iTypedPos = 0; m_szTyped[m_iTypedPos] = iNumber + '0'; m_iTypedPos++; m_szTyped[m_iTypedPos] = 0; sscanf(m_szTyped, "%i", &iValue); if (iValue < m_iStart || iValue > m_iEnd) { m_iTypedPos = 0; strcpy(m_szTyped, ""); return true; } } m_iValue = iValue; CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID()); SendWindowMessage(msg); } break; case SPIN_CONTROL_TYPE_TEXT: { if (iValue < 0 || iValue >= (int)m_vecLabels.size()) { m_iTypedPos = 0; m_szTyped[m_iTypedPos] = iNumber + '0'; m_iTypedPos++; m_szTyped[m_iTypedPos] = 0; sscanf(m_szTyped, "%i", &iValue); if (iValue < 0 || iValue >= (int)m_vecLabels.size()) { m_iTypedPos = 0; strcpy(m_szTyped, ""); return true; } } m_iValue = iValue; CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID()); SendWindowMessage(msg); } break; } return true; } break; case ACTION_PAGE_UP: if (!m_bReverse) PageDown(); else PageUp(); return true; break; case ACTION_PAGE_DOWN: if (!m_bReverse) PageUp(); else PageDown(); return true; break; case ACTION_SELECT_ITEM: if (m_iSelect == SPIN_BUTTON_UP) { MoveUp(); return true; } if (m_iSelect == SPIN_BUTTON_DOWN) { MoveDown(); return true; } break; } /* static float m_fSmoothScrollOffset = 0.0f; if (action.GetID() == ACTION_SCROLL_UP) { m_fSmoothScrollOffset += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_fSmoothScrollOffset > 0.4) { handled = true; m_fSmoothScrollOffset -= 0.4f; MoveDown(); } return handled; }*/ return CGUIControl::OnAction(action); }
bool CGUIBaseContainer::OnAction(const CAction &action) { if (action.GetID() >= KEY_ASCII) { OnJumpLetter((char)(action.GetID() & 0xff)); return true; } switch (action.GetID()) { case ACTION_MOVE_LEFT: case ACTION_MOVE_RIGHT: case ACTION_MOVE_DOWN: case ACTION_MOVE_UP: case ACTION_NAV_BACK: { if (!HasFocus()) return false; 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.GetHoldTime() - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START)); unsigned int frameDuration = CTimeUtils::GetFrameTime() - m_lastHoldTime; //scrollrate is minimum 4 items/sec and max rows/10 items/sec m_scrollItemsPerFrame += std::max(0.004f*(float)frameDuration, (float)(speed * 0.0001f * GetRows() * frameDuration)); m_lastHoldTime = CTimeUtils::GetFrameTime(); if(m_scrollItemsPerFrame < 1.0f)//not enough hold time accumulated for one step return false; if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP) while (m_scrollItemsPerFrame-- >= 1) MoveUp(false); else while (m_scrollItemsPerFrame-- >= 1) MoveDown(false); return true; } else { //if HOLD_TIME_START is reached we need //a sane initial value for calculating m_scrollItemsPerPage m_lastHoldTime = CTimeUtils::GetFrameTime(); m_scrollItemsPerFrame = 0.0f; return CGUIControl::OnAction(action); } } break; case ACTION_FIRST_PAGE: SelectItem(0); return true; case ACTION_LAST_PAGE: if (m_items.size()) SelectItem(m_items.size() - 1); return true; case ACTION_NEXT_LETTER: { OnNextLetter(); return true; } break; case ACTION_PREV_LETTER: { OnPrevLetter(); return true; } break; case ACTION_JUMP_SMS2: case ACTION_JUMP_SMS3: case ACTION_JUMP_SMS4: case ACTION_JUMP_SMS5: case ACTION_JUMP_SMS6: case ACTION_JUMP_SMS7: case ACTION_JUMP_SMS8: case ACTION_JUMP_SMS9: { OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2); return true; } break; default: if (action.GetID()) { return OnClick(action.GetID()); } } return false; }
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action) { bool handled = true; if (action.GetID() == (KEY_VKEY | XBMCVK_BACK)) Backspace(); else if (action.GetID() == ACTION_ENTER || (m_isKeyboardNavigationMode && action.GetID() == ACTION_SELECT_ITEM)) OnOK(); else if (action.GetID() == ACTION_SHIFT) OnShift(); else if (action.GetID() == ACTION_SYMBOLS) OnSymbols(); // don't handle move left/right and select in the edit control else if (!m_isKeyboardNavigationMode && (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT || action.GetID() == ACTION_SELECT_ITEM)) handled = false; else if (action.GetID() == ACTION_VOICE_RECOGNIZE) OnVoiceRecognition(); else { std::wstring wch = L""; wch.insert(wch.begin(), action.GetUnicode()); std::string ch; g_charsetConverter.wToUTF8(wch, ch); handled = CodingCharacter(ch); if (!handled) { // send action to edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) handled = edit->OnAction(action); if (!handled && action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { uint8_t b = action.GetID() & 0xFF; if (b == XBMCVK_TAB) { // Toggle left/right key mode m_isKeyboardNavigationMode = !m_isKeyboardNavigationMode; if (m_isKeyboardNavigationMode) { m_previouslyFocusedButton = GetFocusedControlID(); SET_CONTROL_FOCUS(edit->GetID(), 0); } else SET_CONTROL_FOCUS(m_previouslyFocusedButton, 0); handled = true; } } } } if (!handled) // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); return handled; }
bool CGUIDialogKeyboard::OnAction(const CAction &action) { bool handled(true); if (action.GetID() == ACTION_BACKSPACE) { Backspace(); } else if (action.GetID() == ACTION_ENTER) { OnOK(); } else if (action.GetID() == ACTION_CURSOR_LEFT) { MoveCursor( -1); } else if (action.GetID() == ACTION_CURSOR_RIGHT) { if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' ')) { // add a space Character(L' '); } else MoveCursor(1); } else if (action.GetID() == ACTION_SHIFT) { OnShift(); } else if (action.GetID() == ACTION_SYMBOLS) { OnSymbols(); } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { OnRemoteNumberClick(action.GetID()); } else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) uint8_t b = action.GetID() & 0xFF; if (b == 0x24) // home { MoveCursor(-GetCursorPos()); } else if (b == 0x23) // end { MoveCursor(m_strEdit.GetLength() - GetCursorPos()); } else if (b == 0x25) // left { MoveCursor( -1); } else if (b == 0x27) // right { MoveCursor(1); } else if (b == 0x0D) // enter { OnOK(); } else if (b == 0x2E) // delete { if (GetCursorPos() < m_strEdit.GetLength()) { MoveCursor(1); Backspace(); } } else if (b == 0x08) Backspace(); // backspace else if (b == 0x1B) Close(); // escape } else if (action.GetID() >= KEY_ASCII) { // input from the keyboard //char ch = action.GetID() & 0xFF; switch (action.GetUnicode()) { case 13: // enter case 10: // enter OnOK(); break; case 8: // backspace Backspace(); break; case 27: // escape Close(); break; default: //use character input Character(action.GetUnicode()); break; } } else // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); if (handled && m_filtering == FILTERING_SEARCH) { // we did _something_, so make sure our search message filter is reset SendSearchMessage(); } return handled; }
bool CGUIBaseContainer::OnAction(const CAction &action) { if (action.GetID() >= KEY_ASCII) { OnJumpLetter((char)(action.GetID() & 0xff)); return true; } // stop the timer on any other action m_matchTimer.Stop(); switch (action.GetID()) { case ACTION_MOVE_LEFT: case ACTION_MOVE_RIGHT: case ACTION_MOVE_DOWN: case ACTION_MOVE_UP: case ACTION_NAV_BACK: case ACTION_PREVIOUS_MENU: { if (!HasFocus()) return false; 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.GetHoldTime() - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START)); unsigned int frameDuration = std::min(CTimeUtils::GetFrameTime() - m_lastHoldTime, 50u); // max 20fps // maximal scroll rate is at least 30 items per second, and at most (item_rows/7) items per second // i.e. timed to take 7 seconds to traverse the list at full speed. // minimal scroll rate is at least 10 items per second float maxSpeed = std::max(frameDuration * 0.001f * 30, frameDuration * 0.001f * GetRows() / 7); float minSpeed = frameDuration * 0.001f * 10; m_scrollItemsPerFrame += std::max(minSpeed, speed*maxSpeed); // accelerate to max speed m_lastHoldTime = CTimeUtils::GetFrameTime(); if(m_scrollItemsPerFrame < 1.0f)//not enough hold time accumulated for one step return true; while (m_scrollItemsPerFrame >= 1) { if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP) MoveUp(false); else MoveDown(false); m_scrollItemsPerFrame--; } return true; } else { //if HOLD_TIME_START is reached we need //a sane initial value for calculating m_scrollItemsPerPage m_lastHoldTime = CTimeUtils::GetFrameTime(); m_scrollItemsPerFrame = 0.0f; return CGUIControl::OnAction(action); } } break; case ACTION_FIRST_PAGE: SelectItem(0); return true; case ACTION_LAST_PAGE: if (m_items.size()) SelectItem(m_items.size() - 1); return true; case ACTION_NEXT_LETTER: { OnNextLetter(); return true; } break; case ACTION_PREV_LETTER: { OnPrevLetter(); return true; } break; case ACTION_JUMP_SMS2: case ACTION_JUMP_SMS3: case ACTION_JUMP_SMS4: case ACTION_JUMP_SMS5: case ACTION_JUMP_SMS6: case ACTION_JUMP_SMS7: case ACTION_JUMP_SMS8: case ACTION_JUMP_SMS9: { OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2); return true; } break; default: if (action.GetID()) { return OnClick(action.GetID()); } } return false; }
bool CGUIBaseContainer::OnAction(const CAction &action) { if (action.GetID() >= KEY_ASCII) { OnJumpLetter((char)(action.GetID() & 0xff)); return true; } switch (action.GetID()) { case ACTION_MOVE_LEFT: case ACTION_MOVE_RIGHT: case ACTION_MOVE_DOWN: case ACTION_MOVE_UP: case ACTION_NAV_BACK: { if (!HasFocus()) return false; 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.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.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP) while (itemsPerFrame--) MoveUp(false); else while (itemsPerFrame--) MoveDown(false); return true; } else { m_lastHoldTime = 0; return CGUIControl::OnAction(action); } } break; case ACTION_FIRST_PAGE: SelectItem(0); return true; case ACTION_LAST_PAGE: if (m_items.size()) SelectItem(m_items.size() - 1); return true; case ACTION_NEXT_LETTER: { OnNextLetter(); return true; } break; case ACTION_PREV_LETTER: { OnPrevLetter(); return true; } break; case ACTION_JUMP_SMS2: case ACTION_JUMP_SMS3: case ACTION_JUMP_SMS4: case ACTION_JUMP_SMS5: case ACTION_JUMP_SMS6: case ACTION_JUMP_SMS7: case ACTION_JUMP_SMS8: case ACTION_JUMP_SMS9: { OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2); return true; } break; default: if (action.GetID()) { return OnClick(action.GetID()); } } return false; }
bool CGUIDialogNumeric::OnAction(const CAction &action) { if (action.GetID() == ACTION_NEXT_ITEM) OnNext(); else if (action.GetID() == ACTION_PREV_ITEM) OnPrevious(); else if (action.GetID() == ACTION_BACKSPACE) OnBackSpace(); else if (action.GetID() == ACTION_ENTER) OnOK(); else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) OnNumber(action.GetID() - REMOTE_0); else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) BYTE b = action.GetID() & 0xFF; if (b == XBMCVK_LEFT) OnPrevious(); else if (b == XBMCVK_RIGHT) OnNext(); else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER) OnOK(); else if (b == XBMCVK_BACK) OnBackSpace(); else if (b == XBMCVK_ESCAPE) OnCancel(); } else if (action.GetID() >= KEY_ASCII) // FIXME make it KEY_UNICODE { // input from the keyboard if (action.GetUnicode() == 10 || action.GetUnicode() == 13) OnOK(); // enter else if (action.GetUnicode() == 8) OnBackSpace(); // backspace else if (action.GetUnicode() == 27) OnCancel(); // escape else if (action.GetUnicode() >= 48 && action.GetUnicode() < 58) // number OnNumber(action.GetUnicode() - 48); } else return CGUIDialog::OnAction(action); return true; }
bool CGUIEditControl::OnAction(const CAction &action) { ValidateCursor(); if (m_inputType != INPUT_TYPE_READONLY) { if (action.GetID() == ACTION_BACKSPACE) { // backspace if (m_cursorPos) { if (!ClearMD5()) m_text2.erase(--m_cursorPos, 1); UpdateText(); } return true; } else if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_CURSOR_LEFT) { if (m_cursorPos > 0) { m_cursorPos--; UpdateText(false); return true; } } else if (action.GetID() == ACTION_MOVE_RIGHT || action.GetID() == ACTION_CURSOR_RIGHT) { if ((unsigned int) m_cursorPos < m_text2.size()) { m_cursorPos++; UpdateText(false); return true; } } else if (action.GetID() == ACTION_PASTE) { ClearMD5(); OnPasteClipboard(); return true; } else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII && m_edit.empty()) { // input from the keyboard (vkey, not ascii) BYTE b = action.GetID() & 0xFF; if (b == XBMCVK_HOME) { m_cursorPos = 0; UpdateText(false); return true; } else if (b == XBMCVK_END) { m_cursorPos = m_text2.length(); UpdateText(false); return true; } if (b == XBMCVK_LEFT && m_cursorPos > 0) { m_cursorPos--; UpdateText(false); return true; } if (b == XBMCVK_RIGHT && m_cursorPos < m_text2.length()) { m_cursorPos++; UpdateText(false); return true; } if (b == XBMCVK_DELETE) { if (m_cursorPos < m_text2.length()) { if (!ClearMD5()) m_text2.erase(m_cursorPos, 1); UpdateText(); return true; } } if (b == XBMCVK_BACK) { if (m_cursorPos > 0) { if (!ClearMD5()) m_text2.erase(--m_cursorPos, 1); UpdateText(); } return true; } else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER) { // enter - send click message, but otherwise ignore SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1); return true; } else if (b == XBMCVK_ESCAPE) { // escape - fallthrough to default action return CGUIButtonControl::OnAction(action); } } else if (action.GetID() >= KEY_ASCII) { // input from the keyboard int ch = action.GetUnicode(); // ignore non-printing characters if ( !((0 <= ch && ch < 0x8) || (0xE <= ch && ch < 0x1B) || (0x1C <= ch && ch < 0x20)) ) { switch (ch) { case 9: // tab, ignore case 11: // Non-printing character, ignore case 12: // Non-printing character, ignore break; case 10: case 13: { // enter - send click message, but otherwise ignore SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1); return true; } case 27: { // escape - fallthrough to default action return CGUIButtonControl::OnAction(action); } case 8: { // backspace if (m_cursorPos) { if (!ClearMD5()) m_text2.erase(--m_cursorPos, 1); } break; } case 127: { // delete if (m_cursorPos < m_text2.length()) { if (!ClearMD5()) m_text2.erase(m_cursorPos, 1); } break; } default: { if (!g_Windowing.IsTextInputEnabled()) { ClearMD5(); m_edit.clear(); m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.GetUnicode()); } break; } } UpdateText(); return true; } } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { // input from the remote ClearMD5(); m_edit.clear(); OnSMSCharacter(action.GetID() - REMOTE_0); return true; } else if (action.GetID() == ACTION_INPUT_TEXT) { m_edit.clear(); std::wstring str; g_charsetConverter.utf8ToW(action.GetText(), str); m_text2.insert(m_cursorPos, str); m_cursorPos += str.size(); UpdateText(); return true; } } return CGUIButtonControl::OnAction(action); }
bool CGUIPanelContainer::OnAction(const CAction &action) { switch (action.GetID()) { case ACTION_PAGE_UP: { if (GetOffset() == 0) { // already on the first page, so move to the first item SetCursor(0); } else { // scroll up to the previous page Scroll( -m_itemsPerPage); } return true; } break; case ACTION_PAGE_DOWN: { if ((GetOffset() + m_itemsPerPage) * m_itemsPerRow >= (int)m_items.size() || (int)m_items.size() < m_itemsPerPage) { // already at the last page, so move to the last item. SetCursor(m_items.size() - GetOffset() * m_itemsPerRow - 1); } else { // scroll down to the next page Scroll(m_itemsPerPage); } return true; } break; // smooth scrolling (for analog controls) case ACTION_SCROLL_UP: { m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > AnalogScrollSpeed()) { handled = true; m_analogScrollCount -= AnalogScrollSpeed(); if (GetOffset() > 0)// && GetCursor() <= m_itemsPerPage * m_itemsPerRow / 2) { Scroll(-1); } else if (GetCursor() > 0) { SetCursor(GetCursor() - 1); } } return handled; } break; case ACTION_SCROLL_DOWN: { m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > AnalogScrollSpeed()) { handled = true; m_analogScrollCount -= AnalogScrollSpeed(); if ((GetOffset() + m_itemsPerPage) * m_itemsPerRow < (int)m_items.size())// && GetCursor() >= m_itemsPerPage * m_itemsPerRow / 2) { Scroll(1); } else if (GetCursor() < m_itemsPerPage * m_itemsPerRow - 1 && GetOffset() * m_itemsPerRow + GetCursor() < (int)m_items.size() - 1) { SetCursor(GetCursor() + 1); } } return handled; } break; } return CGUIBaseContainer::OnAction(action); }
void CLayerDlg::OnLayerDel() { if(!m_layerListBox.layout_editor) return; if(m_layerListBox.GetCurSel() == -1) return; CLayer *layer = (CLayer*)m_layerListBox.GetItemDataPtr(m_layerListBox.GetCurSel()); if (layer->m_layerType == LAYER_NONFRAME) return; if (m_layerListBox.layout_editor->layout->layers.GetCount() == 2) { CErrorDlg error; error.Error("Error removing layer", "You can't remove the last layer."); return; } bool do_delete = false; if (layer) { CExtMsgBox msg(NULL, CONF_DELETE, CONFIRMATION, __EXT_MB_YESNO | __EXT_MB_ICONINFORMATION | __EXT_MB_DO_NOT_ASK_AGAIN, 0, "DeleteLayer", __EXT_MB_EX_CHECK_BOX_IS_NOT_CHECKED_INTIALLY); int result = msg.DoModal(); if (result == IDYES) do_delete = true; else msg.ResetMsgBox(); } if (do_delete) { POSITION pos = layer->m_zOrder.GetHeadPosition(); vector<long> deletelist; for (int i = 0; i < layer->m_zOrder.GetCount(); i++) { deletelist.push_back(layer->m_zOrder.GetNext(pos)); } for(int i = 0; i < deletelist.size(); i++) { m_layerListBox.layout_editor->DeleteObject(deletelist.at(i), TRUE); } // START UNDO INFO // CAction *action = new CAction(); action->m_type = ACTION_CHANGEZORDER; CArchive *ar = action->Prepare1(); m_layerListBox.layout_editor->SerializeAllZLists(ar); action->Prepare2(); m_layerListBox.layout_editor->m_undo->AddAction(action); // END UNDO INFO // m_layerListBox.layout_editor->layout->layers.RemoveAt(m_layerListBox.layout_editor->layout->layers.Find(layer)); m_layerListBox.DeleteString(m_layerListBox.GetCurSel()); m_layerListBox.SetCurSel(0); OnSelchange(); g_PropertyBar->Update(layout_editor, TYPE_LAYER, NULL, NULL,NULL, layout_editor->application, 0, layout_editor->layout->layers.GetAt(layout_editor->layout->layers.GetTailPosition())); // update the property editor m_layerListBox.layout_editor->Invalidate(); CChildFrame* pCF = (CChildFrame*)m_layerListBox.layout_editor->GetParentFrame(); pCF->object_bar.Refresh(); layout_editor->layout->SetChanged(true); } }
bool CGUIWindowSettingsCategory::OnAction(const CAction &action) { switch (action.GetID()) { case ACTION_SETTINGS_RESET: { if (CGUIDialogYesNo::ShowAndGetInput(10041, 0, 10042, 0)) { for(vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); it++) { CSetting *setting = (*it)->GetSetting(); if (setting != NULL) setting->Reset(); } } return true; } case ACTION_SETTINGS_LEVEL_CHANGE: { CViewStateSettings::Get().CycleSettingLevel(); CSettings::Get().Save(); // try to keep the current position std::string oldCategory; if (m_iCategory >= 0 && m_iCategory < (int)m_categories.size()) oldCategory = m_categories[m_iCategory]->GetId(); SET_CONTROL_LABEL(CONTRL_BTN_LEVELS, 10036 + (int)CViewStateSettings::Get().GetSettingLevel()); // only re-create the categories, the settings will be created later SetupControls(false); m_iCategory = 0; // try to find the category that was previously selected if (!oldCategory.empty()) { for (int i = 0; i < (int)m_categories.size(); i++) { if (m_categories[i]->GetId() == oldCategory) { m_iCategory = i; break; } } } CreateSettings(); return true; } case ACTION_SHOW_INFO: { int label = -1; int help = -1; int focusedControl = GetFocusedControlID(); // check if we are focusing a category if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size())) { CSettingCategory *category = m_categories[focusedControl - CONTROL_START_BUTTONS]; label = category->GetLabel(); help = category->GetHelp(); } else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size())) { CSetting *setting = GetSettingControl(focusedControl)->GetSetting(); if (setting != NULL) { label = setting->GetLabel(); help = setting->GetHelp(); } } else break; if (help >= 0) { CGUIDialogTextViewer *dialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER); if (dialog != NULL) { if (label < 0) label = 10043; // "Help" dialog->SetHeading(g_localizeStrings.Get(label)); dialog->SetText(g_localizeStrings.Get(help)); dialog->DoModal(); } } else CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(10043), g_localizeStrings.Get(10044), 2000U); return true; } default: break; } return CGUIWindow::OnAction(action); }
unsigned int CKeymapActionMap::GetActionID(const CKey& key) { CAction action = CServiceBroker::GetInputManager().GetAction(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindowOrDialog(), key); return action.GetID(); }
bool CGUIWindowSlideShow::OnAction(const CAction &action) { if (m_bScreensaver) { g_windowManager.PreviousWindow(); return true; } switch (action.GetID()) { case ACTION_SHOW_CODEC: { CGUIDialogPictureInfo *pictureInfo = (CGUIDialogPictureInfo *)g_windowManager.GetWindow(WINDOW_DIALOG_PICTURE_INFO); if (pictureInfo) { // no need to set the picture here, it's done in Render() pictureInfo->DoModal(); } } break; case ACTION_PREVIOUS_MENU: case ACTION_NAV_BACK: case ACTION_STOP: g_windowManager.PreviousWindow(); break; case ACTION_NEXT_PICTURE: ShowNext(); break; case ACTION_PREV_PICTURE: ShowPrevious(); break; case ACTION_MOVE_RIGHT: if (m_iZoomFactor == 1) ShowNext(); else Move(PICTURE_MOVE_AMOUNT, 0); break; case ACTION_MOVE_LEFT: if (m_iZoomFactor == 1) ShowPrevious(); else Move( -PICTURE_MOVE_AMOUNT, 0); break; case ACTION_MOVE_DOWN: Move(0, PICTURE_MOVE_AMOUNT); break; case ACTION_MOVE_UP: Move(0, -PICTURE_MOVE_AMOUNT); break; case ACTION_PAUSE: if (m_bSlideShow) m_bPause = !m_bPause; break; case ACTION_PLAYER_PLAY: if (!m_bSlideShow) { m_bSlideShow = true; m_bPause = false; } else if (m_bPause) m_bPause = false; break; case ACTION_ZOOM_OUT: Zoom(m_iZoomFactor - 1); break; case ACTION_ZOOM_IN: Zoom(m_iZoomFactor + 1); break; case ACTION_ROTATE_PICTURE: Rotate(); break; case ACTION_ZOOM_LEVEL_NORMAL: case ACTION_ZOOM_LEVEL_1: case ACTION_ZOOM_LEVEL_2: case ACTION_ZOOM_LEVEL_3: case ACTION_ZOOM_LEVEL_4: case ACTION_ZOOM_LEVEL_5: case ACTION_ZOOM_LEVEL_6: case ACTION_ZOOM_LEVEL_7: case ACTION_ZOOM_LEVEL_8: case ACTION_ZOOM_LEVEL_9: Zoom((action.GetID() - ACTION_ZOOM_LEVEL_NORMAL) + 1); break; case ACTION_ANALOG_MOVE: Move(action.GetAmount()*PICTURE_MOVE_AMOUNT_ANALOG, -action.GetAmount(1)*PICTURE_MOVE_AMOUNT_ANALOG); break; default: return CGUIWindow::OnAction(action); } return true; }
// поток на выполнение... UINT ExecuteThread(LPVOID pParam) { HWND hServer=hServer_; HWND hTarget=hTarget_; CGesture* pGesture=pGesture_; // *** выпоняем // сообщаяем главному окну PostMessage(hServer,WM_IDENTIFY,(WPARAM)1,(LPARAM)pGesture); CAction* pAction; for(int i=0;i<pGesture->m_Commands.m_nActions;i++) { pAction=&pGesture->m_Commands.m_Actions[i]; switch(pAction->m_Type) { case 0: { CString &s=pAction->m_Param[0]; if(s==_T("Close")) { PressHotKey(VK_F4,VK_MENU); //PostMessage(m_hClientWnd,WM_CLOSE,0,0); } if(s==_T("Maximize")) PostMessage(hTarget, WM_SYSCOMMAND, SC_MAXIMIZE, 0); if(s==_T("Minimize")) PostMessage(hTarget, WM_SYSCOMMAND, SC_MINIMIZE, 0); if(s==_T("MinimizeAll")) { PressHotKey('D',VK_LWIN); //SendMessage(FindWindow("Shell_TrayWnd",NULL),WM_COMMAND,0x019F,0); } if(s==_T("Copy")) PressHotKey('C',VK_CONTROL); if(s==_T("Paste")) PressHotKey('V',VK_CONTROL); if(s==_T("Cut")) PressHotKey('X',VK_CONTROL); if(s==_T("Open")) PressHotKey('O',VK_CONTROL); if(s==_T("Save")) PressHotKey('S',VK_CONTROL); if(s==_T("Print")) PressHotKey('P',VK_CONTROL); if(s==_T("Next")) PressHotKey(VK_RIGHT,VK_MENU); if(s==_T("Back")) PressHotKey(VK_LEFT,VK_MENU); if(s==_T("Shutdown")) { ExitWindowsEx(EWX_POWEROFF|EWX_SHUTDOWN,0); } if(s==_T("NextWindow")) PressHotKey(VK_ESCAPE,VK_MENU); if(s==_T("PrevWindow")) { keybd_event(VK_MENU, 0, 0, 0); keybd_event(VK_SHIFT, 0, 0, 0); keybd_event(VK_ESCAPE, 0, 0, 0); keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0); keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0); keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0); } if(s==_T("Undo")) PressHotKey('Z',VK_CONTROL); if(s==_T("Redo")) PressHotKey('Y',VK_CONTROL); if(s==_T("SelectAll")) PressHotKey('A',VK_CONTROL); if(s==_T("CloseDocument")) PressHotKey(VK_F4,VK_CONTROL); } break; case 1: { //if(pAction->m_Param[0].Mid(pAction->m_Param[0].GetLength()-1,4)==".lnk") ShellExecute(NULL,_T("open"),pAction->m_Param[0],pAction->m_Param[1],pAction->m_Param[2],SW_SHOWNORMAL); //else // ShellExecute(NULL,"open","start "+pAction->m_Param[0],pAction->m_Param[1],pAction->m_Param[2],SW_SHOWNORMAL); } break; case 2: TypeText(pAction->m_Param[0],hTarget); break; case 3: { int type=0,key=0; CString s=pAction->m_Param[0]; while(!s.IsEmpty()) { pAction->GetKeyElement(s,type,key); if(type==0) keybd_event(key,0,0,0); else keybd_event(key,0,KEYEVENTF_KEYUP,0); Sleep(100); } /* //old long i=0,m=0; i=atol(pAction->m_Param[0]); m=atol(pAction->m_Param[1]); if((m & HOTKEYF_SHIFT)==HOTKEYF_SHIFT) keybd_event(VK_SHIFT,0,0,0); if((m & HOTKEYF_CONTROL)==HOTKEYF_CONTROL) keybd_event(VK_CONTROL,0,0,0); if((m & HOTKEYF_ALT)==HOTKEYF_ALT) keybd_event(VK_MENU,0,0,0); keybd_event((BYTE)i, 0, 0, 0); keybd_event((BYTE)i, 0, KEYEVENTF_KEYUP, 0); if((m & HOTKEYF_SHIFT)==HOTKEYF_SHIFT) keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0); if((m & HOTKEYF_CONTROL)==HOTKEYF_CONTROL) keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0); if((m & HOTKEYF_ALT)==HOTKEYF_ALT) keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); */ } break; case 4: PostMessage(hTarget,StringToLong(pAction->m_Param[0]),StringToLong(pAction->m_Param[1]),StringToLong(pAction->m_Param[2])); break; } } return 0; }
// all linear features are extracted from positive examples int Segmentor::createAlphabet(const vector<Instance>& vecInsts) { cout << "Creating Alphabet..." << endl; int numInstance = vecInsts.size(); hash_map<string, int> char_stat; hash_map<string, int> bichar_stat; hash_map<string, int> action_stat; hash_map<string, int> feat_stat; hash_map<string, int> word_stat; assert(numInstance > 0); static Metric eval; #if USE_CUDA==1 static CStateItem<gpu> state[m_classifier.MAX_SENTENCE_SIZE]; #else static CStateItem<cpu> state[m_classifier.MAX_SENTENCE_SIZE]; #endif static Feature feat; static vector<string> output; static CAction answer; static int actionNum; m_classifier.initAlphabet(); eval.reset(); for (numInstance = 0; numInstance < vecInsts.size(); numInstance++) { const Instance &instance = vecInsts[numInstance]; for (int idx = 0; idx < instance.wordsize(); idx++) { m_word_stat[normalize_to_lowerwithdigit(instance.words[idx])]++; } for(int distance = 1; distance <= 2; distance++) { for (int idx = 0; idx < instance.charsize(); idx++) { if(idx + distance >= instance.charsize()) break; string curWord = instance.chars[idx]; for(int idz = 1; idz < distance; idz++){ curWord= curWord + instance.chars[idx+idz]; } curWord = normalize_to_lowerwithdigit(curWord); word_stat[curWord]++; } } for (int idx = 0; idx < instance.charsize(); idx++) { char_stat[instance.chars[idx]]++; } for (int idx = 0; idx < instance.charsize() - 1; idx++) { bichar_stat[instance.chars[idx] + instance.chars[idx + 1]]++; } bichar_stat[instance.chars[instance.charsize() - 1] + m_classifier.fe.nullkey]++; bichar_stat[m_classifier.fe.nullkey + instance.chars[0]]++; actionNum = 0; state[actionNum].initSentence(&instance.chars); state[actionNum].clear(); while (!state[actionNum].IsTerminated()) { state[actionNum].getGoldAction(instance.words, answer); action_stat[answer.str()]++; m_classifier.extractFeature(state+actionNum, answer, feat); for (int idx = 0; idx < feat._strSparseFeat.size(); idx++) { feat_stat[feat._strSparseFeat[idx]]++; } state[actionNum].move(state+actionNum+1, answer); actionNum++; } if(actionNum-1 != instance.charsize()) { std::cout << "action number is not correct, please check" << std::endl; } state[actionNum].getSegResults(output); instance.evaluate(output, eval); if (!eval.bIdentical()) { std::cout << "error state conversion!" << std::endl; exit(0); } if ((numInstance + 1) % m_options.verboseIter == 0) { cout << numInstance + 1 << " "; if ((numInstance + 1) % (40 * m_options.verboseIter) == 0) cout << std::endl; cout.flush(); } if (m_options.maxInstance > 0 && numInstance == m_options.maxInstance) break; } int discount = 2; hash_map<string, int>::iterator word_iter; for (word_iter = word_stat.begin(); word_iter != word_stat.end(); word_iter++) { if (word_iter->second > discount && m_word_stat.find(word_iter->first) == m_word_stat.end()) { m_word_stat[word_iter->first] = word_iter->second - discount; } } m_classifier.addToActionAlphabet(action_stat); m_classifier.addToWordAlphabet(m_word_stat); m_classifier.addToCharAlphabet(char_stat, m_options.charEmbFineTune ? m_options.charCutOff : 0); m_classifier.addToBiCharAlphabet(bichar_stat, m_options.bicharEmbFineTune ? m_options.bicharCutOff : 0); m_classifier.addToFeatureAlphabet(feat_stat, m_options.featCutOff); cout << numInstance << " " << endl; cout << "Action num: " << m_classifier.fe._actionAlphabet.size() << endl; cout << "Total word num: " << m_word_stat.size() << endl; cout << "Total char num: " << char_stat.size() << endl; cout << "Total bichar num: " << bichar_stat.size() << endl; cout << "Total feat num: " << feat_stat.size() << endl; cout << "Remain word num: " << m_classifier.fe._wordAlphabet.size() << endl; cout << "Remain char num: " << m_classifier.fe._charAlphabet.size() << endl; cout << "Remain bichar num: " << m_classifier.fe._bicharAlphabet.size() << endl; cout << "Remain feat num: " << m_classifier.fe._featAlphabet.size() << endl; //m_classifier.setFeatureCollectionState(false); return 0; }
bool CGUIDialogGamepad::OnAction(const CAction &action) { if ((action.GetButtonCode() >= KEY_BUTTON_A && action.GetButtonCode() <= KEY_BUTTON_RIGHT_TRIGGER) || (action.GetButtonCode() >= KEY_BUTTON_DPAD_UP && action.GetButtonCode() <= KEY_BUTTON_DPAD_RIGHT) || (action.GetID() >= ACTION_MOVE_LEFT && action.GetID() <= ACTION_MOVE_DOWN) || action.GetID() == ACTION_PLAYER_PLAY ) { switch (action.GetButtonCode()) { case KEY_BUTTON_A : m_strUserInput += "A"; break; case KEY_BUTTON_B : m_strUserInput += "B"; break; case KEY_BUTTON_X : m_strUserInput += "X"; break; case KEY_BUTTON_Y : m_strUserInput += "Y"; break; case KEY_BUTTON_BLACK : m_strUserInput += "K"; break; case KEY_BUTTON_WHITE : m_strUserInput += "W"; break; case KEY_BUTTON_LEFT_TRIGGER : m_strUserInput += "("; break; case KEY_BUTTON_RIGHT_TRIGGER : m_strUserInput += ")"; break; case KEY_BUTTON_DPAD_UP : m_strUserInput += "U"; break; case KEY_BUTTON_DPAD_DOWN : m_strUserInput += "D"; break; case KEY_BUTTON_DPAD_LEFT : m_strUserInput += "L"; break; case KEY_BUTTON_DPAD_RIGHT : m_strUserInput += "R"; break; default: switch (action.GetID()) { case ACTION_MOVE_LEFT: m_strUserInput += "L"; break; case ACTION_MOVE_RIGHT: m_strUserInput += "R"; break; case ACTION_MOVE_UP: m_strUserInput += "U"; break; case ACTION_MOVE_DOWN: m_strUserInput += "D"; break; case ACTION_PLAYER_PLAY: m_strUserInput += "P"; break; default: return true; } break; } CStdString strHiddenInput(m_strUserInput); for (int i = 0; i < (int)strHiddenInput.size(); i++) { strHiddenInput[i] = m_cHideInputChar; } SetLine(2, strHiddenInput); return true; } else if (action.GetButtonCode() == KEY_BUTTON_BACK || action.GetID() == ACTION_PREVIOUS_MENU || action.GetID() == ACTION_NAV_BACK) { m_bConfirmed = false; m_bCanceled = true; m_strUserInput = ""; m_bHideInputChars = true; Close(); return true; } else if (action.GetButtonCode() == KEY_BUTTON_START || action.GetID() == ACTION_SELECT_ITEM) { m_bConfirmed = false; m_bCanceled = false; CStdString md5pword2; XBMC::XBMC_MD5 md5state; md5state.append(m_strUserInput); md5state.getDigest(md5pword2); if (!m_strPassword.Equals(md5pword2)) { // incorrect password entered m_iRetries--; // don't clean up if the calling code wants the bad user input if (m_bUserInputCleanup) m_strUserInput = ""; else m_bUserInputCleanup = true; m_bHideInputChars = true; Close(); return true; } // correct password entered m_bConfirmed = true; m_iRetries = 0; m_strUserInput = ""; m_bHideInputChars = true; Close(); return true; } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { return true; // unhandled } else { return CGUIDialog::OnAction(action); } }
void CAction::setAction(CAction P_action) { if (P_action.getActionType() == CAction::E_AT_ASSIGN_FROM_SAMPLE) { assert(P_action.getDistribution() != NULL); } int L_i; setActionType ( P_action.getActionType() ); setLookingPlace ( P_action.getLookingPlace() ); setVarId ( P_action.getVarId() ); setVarInId ( P_action.getVarInId() ); setDoubleValue ( P_action.getDoubleValue() ); setDistribution ( P_action.getDistribution() ); setScenario ( P_action.M_scenario ); setNbSubVarId ( P_action.getNbSubVarId() ); for (L_i = 0; L_i < P_action.getNbSubVarId() ; L_i++ ) { setSubVarId (P_action.getSubVarId(L_i)); } setLookingChar ( P_action.getLookingChar() ); setCheckIt ( P_action.getCheckIt() ); setCheckItInverse ( P_action.getCheckItInverse() ); setCaseIndep ( P_action.getCaseIndep() ); setOccurrence ( P_action.getOccurrence() ); setHeadersOnly ( P_action.getHeadersOnly() ); for (L_i = 0; L_i < MAX_ACTION_MESSAGE; L_i++) { setMessage(P_action.M_message_str[L_i], L_i); } setRegExp ( P_action.M_regularExpression); setIntCmd ( P_action.M_IntCmd ); #ifdef PCAPPLAY setPcapArgs ( P_action.M_pcapArgs ); #endif #ifdef RTP_STREAM setRTPStreamActInfo (&(P_action.M_rtpstream_actinfo)); #endif }
bool CGUIDialogAudioDSPManager::OnActionMove(const CAction &action) { bool bReturn(false); int iActionId = action.GetID(); if (GetFocusedControlID() == CONTROL_LIST_ACTIVE) { if (iActionId == ACTION_MOUSE_MOVE) { int iSelected = m_activeViewControl.GetSelectedItem(); if (m_iSelected[LIST_ACTIVE] < iSelected) { iActionId = ACTION_MOVE_DOWN; } else if (m_iSelected[LIST_ACTIVE] > iSelected) { iActionId = ACTION_MOVE_UP; } else { return bReturn; } } if (iActionId == ACTION_MOVE_DOWN || iActionId == ACTION_MOVE_UP || iActionId == ACTION_PAGE_DOWN || iActionId == ACTION_PAGE_UP) { bReturn = true; CGUIDialog::OnAction(action); int iSelected = m_activeViewControl.GetSelectedItem(); if (!m_bMovingMode) { if (iSelected != m_iSelected[LIST_ACTIVE]) { m_iSelected[LIST_ACTIVE] = iSelected; } } else { bool bMoveUp = iActionId == ACTION_PAGE_UP || iActionId == ACTION_MOVE_UP; unsigned int iLines = bMoveUp ? abs(m_iSelected[LIST_ACTIVE] - iSelected) : 1; bool bOutOfBounds = bMoveUp ? m_iSelected[LIST_ACTIVE] <= 0 : m_iSelected[LIST_ACTIVE] >= m_activeItems[m_iCurrentType]->Size() - 1; if (bOutOfBounds) { bMoveUp = !bMoveUp; iLines = m_activeItems[m_iCurrentType]->Size() - 1; } std::string strNumber; for (unsigned int iLine = 0; iLine < iLines; iLine++) { unsigned int iNewSelect = bMoveUp ? m_iSelected[LIST_ACTIVE] - 1 : m_iSelected[LIST_ACTIVE] + 1; if (m_activeItems[m_iCurrentType]->Get(iNewSelect)->GetProperty("Number").asString() != "-") { strNumber = StringUtils::Format("%i", m_iSelected[LIST_ACTIVE]+1); m_activeItems[m_iCurrentType]->Get(iNewSelect)->SetProperty("Number", strNumber); strNumber = StringUtils::Format("%i", iNewSelect+1); m_activeItems[m_iCurrentType]->Get(m_iSelected[LIST_ACTIVE])->SetProperty("Number", strNumber); } m_activeItems[m_iCurrentType]->Swap(iNewSelect, m_iSelected[LIST_ACTIVE]); m_iSelected[LIST_ACTIVE] = iNewSelect; } SET_CONTROL_FOCUS(CONTROL_LIST_ACTIVE, 0); m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); m_activeViewControl.SetSelectedItem(m_iSelected[LIST_ACTIVE]); } } } return bReturn; }
bool CInputManager::OnKey(const CKey& key) { for (std::vector<KEYBOARD::IKeyboardHandler*>::iterator it = m_keyboardHandlers.begin(); it != m_keyboardHandlers.end(); ++it) { if ((*it)->OnKeyPress(key)) return true; } // Turn the mouse off, as we've just got a keypress from controller or remote m_Mouse.SetActive(false); // get the current active window int iWin = g_windowManager.GetActiveWindowID(); // this will be checked for certain keycodes that need // special handling if the screensaver is active CAction action = CButtonTranslator::GetInstance().GetAction(iWin, key); // a key has been pressed. // reset Idle Timer g_application.ResetSystemIdleTimer(); bool processKey = AlwaysProcess(action); if (StringUtils::StartsWithNoCase(action.GetName(), "CECToggleState") || StringUtils::StartsWithNoCase(action.GetName(), "CECStandby")) { // do not wake up the screensaver right after switching off the playing device if (StringUtils::StartsWithNoCase(action.GetName(), "CECToggleState")) { CLog::LogF(LOGDEBUG, "action %s [%d], toggling state of playing device", action.GetName().c_str(), action.GetID()); bool result; CApplicationMessenger::GetInstance().SendMsg(TMSG_CECTOGGLESTATE, 0, 0, static_cast<void*>(&result)); if (!result) return true; } else { CApplicationMessenger::GetInstance().PostMsg(TMSG_CECSTANDBY); return true; } } g_application.ResetScreenSaver(); // allow some keys to be processed while the screensaver is active if (g_application.WakeUpScreenSaverAndDPMS(processKey) && !processKey) { CLog::LogF(LOGDEBUG, "%s pressed, screen saver/dpms woken up", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str()); return true; } if (iWin != WINDOW_FULLSCREEN_VIDEO) { // current active window isnt the fullscreen window // just use corresponding section from keymap.xml // to map key->action // first determine if we should use keyboard input directly bool useKeyboard = key.FromKeyboard() && (iWin == WINDOW_DIALOG_KEYBOARD || iWin == WINDOW_DIALOG_NUMERIC); CGUIWindow *window = g_windowManager.GetWindow(iWin); if (window) { CGUIControl *control = window->GetFocusedControl(); if (control) { // If this is an edit control set usekeyboard to true. This causes the // keypress to be processed directly not through the key mappings. if (control->GetControlType() == CGUIControl::GUICONTROL_EDIT) useKeyboard = true; // If the key pressed is shift-A to shift-Z set usekeyboard to true. // This causes the keypress to be used for list navigation. if (control->IsContainer() && key.GetModifiers() == CKey::MODIFIER_SHIFT && key.GetVKey() >= XBMCVK_A && key.GetVKey() <= XBMCVK_Z) useKeyboard = true; } } if (useKeyboard) { // use the virtualkeyboard section of the keymap, and send keyboard-specific or navigation // actions through if that's what they are CAction action = CButtonTranslator::GetInstance().GetAction(WINDOW_DIALOG_KEYBOARD, key); if (!(action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT || action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN || action.GetID() == ACTION_SELECT_ITEM || action.GetID() == ACTION_ENTER || action.GetID() == ACTION_PREVIOUS_MENU || action.GetID() == ACTION_NAV_BACK)) { // the action isn't plain navigation - check for a keyboard-specific keymap action = CButtonTranslator::GetInstance().GetAction(WINDOW_DIALOG_KEYBOARD, key, false); if (!(action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) || action.GetID() == ACTION_BACKSPACE || action.GetID() == ACTION_SHIFT || action.GetID() == ACTION_SYMBOLS || action.GetID() == ACTION_CURSOR_LEFT || action.GetID() == ACTION_CURSOR_RIGHT) action = CAction(0); // don't bother with this action } // else pass the keys through directly if (!action.GetID()) { if (key.GetFromService()) action = CAction(key.GetButtonCode() != KEY_INVALID ? key.GetButtonCode() : 0, key.GetUnicode()); else { // Check for paste keypress #ifdef TARGET_WINDOWS // In Windows paste is ctrl-V if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_CTRL) #elif defined(TARGET_LINUX) // In Linux paste is ctrl-V if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_CTRL) #elif defined(TARGET_DARWIN_OSX) // In OSX paste is cmd-V if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_META) #else // Placeholder for other operating systems if (false) #endif action = CAction(ACTION_PASTE); // If the unicode is non-zero the keypress is a non-printing character else if (key.GetUnicode()) action = CAction(key.GetAscii() | KEY_ASCII, key.GetUnicode()); // The keypress is a non-printing character else action = CAction(key.GetVKey() | KEY_VKEY); } } CLog::LogF(LOGDEBUG, "%s pressed, trying keyboard action %x", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetID()); if (g_application.OnAction(action)) return true; // failed to handle the keyboard action, drop down through to standard action } if (key.GetFromService()) { if (key.GetButtonCode() != KEY_INVALID) action = CButtonTranslator::GetInstance().GetAction(iWin, key); } else action = CButtonTranslator::GetInstance().GetAction(iWin, key); } if (!key.IsAnalogButton()) CLog::LogF(LOGDEBUG, "%s pressed, action is %s", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetName().c_str()); return ExecuteInputAction(action); }
bool CGUIWindowFullScreen::OnAction(const CAction &action) { if (m_timeCodePosition > 0 && action.GetButtonCode()) { // check whether we have a mapping in our virtual videotimeseek "window" and have a select action CKey key(action.GetButtonCode()); CAction timeSeek = CButtonTranslator::GetInstance().GetAction(WINDOW_VIDEO_TIME_SEEK, key, false); if (timeSeek.GetID() == ACTION_SELECT_ITEM) { SeekToTimeCodeStamp(SEEK_ABSOLUTE); return true; } } switch (action.GetID()) { case ACTION_SHOW_OSD: ToggleOSD(); return true; case ACTION_SHOW_GUI: { // switch back to the menu OutputDebugString("Switching to GUI\n"); g_windowManager.PreviousWindow(); OutputDebugString("Now in GUI\n"); return true; } break; case ACTION_PLAYER_PLAY: case ACTION_PAUSE: if (m_timeCodePosition > 0) { SeekToTimeCodeStamp(SEEK_ABSOLUTE); return true; } break; case ACTION_STEP_BACK: if (m_timeCodePosition > 0) SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD); else g_application.m_pPlayer->Seek(false, false); return true; case ACTION_STEP_FORWARD: if (m_timeCodePosition > 0) SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_FORWARD); else g_application.m_pPlayer->Seek(true, false); return true; case ACTION_BIG_STEP_BACK: case ACTION_CHAPTER_OR_BIG_STEP_BACK: if (m_timeCodePosition > 0) SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD); else g_application.m_pPlayer->Seek(false, true, action.GetID() == ACTION_CHAPTER_OR_BIG_STEP_BACK); return true; case ACTION_BIG_STEP_FORWARD: case ACTION_CHAPTER_OR_BIG_STEP_FORWARD: if (m_timeCodePosition > 0) SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_FORWARD); else g_application.m_pPlayer->Seek(true, true, action.GetID() == ACTION_CHAPTER_OR_BIG_STEP_FORWARD); return true; case ACTION_NEXT_SCENE: if (g_application.m_pPlayer->SeekScene(true)) g_infoManager.SetDisplayAfterSeek(); return true; break; case ACTION_PREV_SCENE: if (g_application.m_pPlayer->SeekScene(false)) g_infoManager.SetDisplayAfterSeek(); return true; break; case ACTION_SHOW_OSD_TIME: m_bShowCurrentTime = !m_bShowCurrentTime; if(!m_bShowCurrentTime) g_infoManager.SetDisplayAfterSeek(0); //Force display off g_infoManager.SetShowTime(m_bShowCurrentTime); return true; break; case ACTION_SHOW_INFO: { CGUIDialogFullScreenInfo* pDialog = (CGUIDialogFullScreenInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) { CFileItem item(g_application.CurrentFileItem()); pDialog->DoModal(); return true; } break; } case REMOTE_0: case REMOTE_1: case REMOTE_2: case REMOTE_3: case REMOTE_4: case REMOTE_5: case REMOTE_6: case REMOTE_7: case REMOTE_8: case REMOTE_9: { if (g_application.CurrentFileItem().IsLiveTV()) { if(CPVRManager::Get().IsPlaying()) { // pvr client addon CPVRChannelPtr playingChannel; if(!g_PVRManager.GetCurrentChannel(playingChannel)) return false; if (action.GetID() == REMOTE_0) { CPVRChannelGroupPtr group = g_PVRChannelGroups->GetPreviousPlayedGroup(); if (group) { g_PVRManager.SetPlayingGroup(group); CFileItemPtr fileItem = group->GetLastPlayedChannel(playingChannel->ChannelID()); if (fileItem && fileItem->HasPVRChannelInfoTag()) { CLog::Log(LOGDEBUG, "%s - switch to channel number %d", __FUNCTION__, fileItem->GetPVRChannelInfoTag()->ChannelNumber()); g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float) fileItem->GetPVRChannelInfoTag()->ChannelNumber())); } } } else { int autoCloseTime = CSettings::Get().GetBool("pvrplayback.confirmchannelswitch") ? 0 : g_advancedSettings.m_iPVRNumericChannelSwitchTimeout; CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0); if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000), autoCloseTime) || autoCloseTime) { int iChannelNumber = atoi(strChannel.c_str()); if (iChannelNumber > 0 && iChannelNumber != playingChannel->ChannelNumber()) { CPVRChannelGroupPtr selectedGroup = g_PVRManager.GetPlayingGroup(playingChannel->IsRadio()); CFileItemPtr channel = selectedGroup->GetByChannelNumber(iChannelNumber); if (!channel || !channel->HasPVRChannelInfoTag()) return false; g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float)iChannelNumber)); } } } } else { // filesystem provider like slingbox, cmyth, etc int iChannelNumber = -1; CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0); if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000))) iChannelNumber = atoi(strChannel.c_str()); if (iChannelNumber > 0) g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float)iChannelNumber)); } } else { ChangetheTimeCode(action.GetID()); } return true; } break; case ACTION_ASPECT_RATIO: { // toggle the aspect ratio mode (only if the info is onscreen) if (m_bShowViewModeInfo) { #ifdef HAS_VIDEO_PLAYBACK g_renderManager.SetViewMode(++CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); #endif } m_bShowViewModeInfo = true; m_dwShowViewModeTimeout = XbmcThreads::SystemClockMillis(); } return true; break; case ACTION_SMALL_STEP_BACK: if (m_timeCodePosition > 0) SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD); else { int orgpos = (int)g_application.GetTime(); int jumpsize = g_advancedSettings.m_videoSmallStepBackSeconds; // secs int setpos = (orgpos > jumpsize) ? orgpos - jumpsize : 0; g_application.SeekTime((double)setpos); } return true; break; case ACTION_SHOW_PLAYLIST: { CFileItem item(g_application.CurrentFileItem()); if (item.HasPVRChannelInfoTag()) g_windowManager.ActivateWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS); else if (item.HasVideoInfoTag()) g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST); else if (item.HasMusicInfoTag()) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); } return true; break; case ACTION_PREVIOUS_CHANNELGROUP: { if (g_application.CurrentFileItem().HasPVRChannelInfoTag()) ChangetheTVGroup(false); return true; } case ACTION_NEXT_CHANNELGROUP: { if (g_application.CurrentFileItem().HasPVRChannelInfoTag()) ChangetheTVGroup(true); return true; } default: break; } return CGUIWindow::OnAction(action); }
bool CGUIDialogNumeric::OnAction(const CAction &action) { if (action.GetID() >= ACTION_MOVE_LEFT && action.GetID() <= ACTION_MOVE_DOWN) m_autoClosing = false; if (action.GetID() == ACTION_CLOSE_DIALOG || action.GetID() == ACTION_PREVIOUS_MENU) OnCancel(); else if (action.GetID() == ACTION_NEXT_ITEM) OnNext(); else if (action.GetID() == ACTION_PREV_ITEM) OnPrevious(); else if (action.GetID() == ACTION_BACKSPACE) OnBackSpace(); else if (action.GetID() == ACTION_ENTER) OnOK(); else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) OnNumber(action.GetID() - REMOTE_0); else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) BYTE b = action.GetID() & 0xFF; if (b == 0x25) OnPrevious(); // left else if (b == 0x27) OnNext(); // right else if (b == 0x0D) OnOK(); // enter else if (b == 0x08) OnBackSpace(); // backspace else if (b == 0x1B) OnCancel(); // escape } else if (action.GetID() >= KEY_ASCII) // FIXME make it KEY_UNICODE { // input from the keyboard if (action.GetUnicode() == 10 || action.GetUnicode() == 13) OnOK(); // enter else if (action.GetUnicode() == 8) OnBackSpace(); // backspace else if (action.GetUnicode() == 27) OnCancel(); // escape else if (action.GetUnicode() >= 48 && action.GetUnicode() < 58) // number OnNumber(action.GetUnicode() - 48); } else return CGUIDialog::OnAction(action); return true; }
bool CGUIWindowFileManager::OnAction(const CAction &action) { int list = GetFocusedList(); if (list >= 0 && list <= 1) { int item; // the non-contextual menu can be called at any time if (action.GetID() == ACTION_CONTEXT_MENU && m_vecItems[list]->Size() == 0) { OnPopupMenu(list,-1, false); return true; } if (action.GetID() == ACTION_DELETE_ITEM) { if (CanDelete(list)) { bool bDeselect = SelectItem(list, item); OnDelete(list); if (bDeselect) m_vecItems[list]->Get(item)->Select(false); } return true; } if (action.GetID() == ACTION_COPY_ITEM) { if (CanCopy(list)) { bool bDeselect = SelectItem(list, item); OnCopy(list); if (bDeselect) m_vecItems[list]->Get(item)->Select(false); } return true; } if (action.GetID() == ACTION_MOVE_ITEM) { if (CanMove(list)) { bool bDeselect = SelectItem(list, item); OnMove(list); if (bDeselect) m_vecItems[list]->Get(item)->Select(false); } return true; } if (action.GetID() == ACTION_RENAME_ITEM) { if (CanRename(list)) { bool bDeselect = SelectItem(list, item); OnRename(list); if (bDeselect) m_vecItems[list]->Get(item)->Select(false); } return true; } if (action.GetID() == ACTION_PARENT_DIR) { GoParentFolder(list); return true; } if (action.GetID() == ACTION_PLAYER_PLAY) { #ifdef HAS_DVD_DRIVE if (m_vecItems[list]->Get(GetSelectedItem(list))->IsDVD()) return MEDIA_DETECT::CAutorun::PlayDiscAskResume(m_vecItems[list]->Get(GetSelectedItem(list))->GetPath()); #endif } } return CGUIWindow::OnAction(action); }
bool CGUIWindowVisualisation::OnAction(const CAction &action) { bool passToVis = false; switch (action.GetID()) { case ACTION_VIS_PRESET_NEXT: case ACTION_VIS_PRESET_PREV: case ACTION_VIS_PRESET_RANDOM: case ACTION_VIS_RATE_PRESET_PLUS: case ACTION_VIS_RATE_PRESET_MINUS: passToVis = true; break; case ACTION_SHOW_INFO: { m_initTimer.Stop(); CServiceBroker::GetSettings().SetBool(CSettings::SETTING_MYMUSIC_SONGTHUMBINVIS, CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().ToggleShowInfo()); return true; } break; case ACTION_SHOW_OSD: CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_DIALOG_MUSIC_OSD); return true; case ACTION_SHOW_GUI: // save the settings CServiceBroker::GetSettings().Save(); CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow(); return true; break; case ACTION_VIS_PRESET_LOCK: { // show the locked icon + fall through so that the vis handles the locking if (!m_bShowPreset) { m_lockedTimer.StartZero(); } passToVis = true; } break; case ACTION_VIS_PRESET_SHOW: { if (!m_lockedTimer.IsRunning() || m_bShowPreset) m_bShowPreset = !m_bShowPreset; return true; } break; case ACTION_DECREASE_RATING: case ACTION_INCREASE_RATING: { // actual action is taken care of in CApplication::OnAction() m_initTimer.StartZero(); CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().SetShowInfo(true); } break; //! @todo These should be mapped to its own function - at the moment it's overriding //! the global action of fastforward/rewind and OSD. /* case KEY_BUTTON_Y: g_application.m_CdgParser.Pause(); return true; break; case ACTION_ANALOG_FORWARD: // calculate the speed based on the amount the button is held down if (action.GetAmount()) { float AVDelay = g_application.m_CdgParser.GetAVDelay(); g_application.m_CdgParser.SetAVDelay(AVDelay - action.GetAmount() / 4.0f); return true; } break;*/ } if (passToVis) { CGUIControl *control = GetControl(CONTROL_VIS); if (control) return control->OnAction(action); } return CGUIWindow::OnAction(action); }
bool CStereoscopicsManager::OnAction(const CAction &action) { RENDER_STEREO_MODE mode = GetStereoMode(); if (action.GetID() == ACTION_STEREOMODE_NEXT) { SetStereoModeByUser(GetNextSupportedStereoMode(mode)); return true; } else if (action.GetID() == ACTION_STEREOMODE_PREVIOUS) { SetStereoModeByUser(GetNextSupportedStereoMode(mode, RENDER_STEREO_MODE_COUNT - 1)); return true; } else if (action.GetID() == ACTION_STEREOMODE_TOGGLE) { if (mode == RENDER_STEREO_MODE_OFF) { RENDER_STEREO_MODE targetMode = GetPreferredPlaybackMode(); // if user selected a specific mode before, make sure to // switch back into that mode on toggle. if (m_stereoModeSetByUser != RENDER_STEREO_MODE_UNDEFINED) { // if user mode is set to OFF, he manually turned it off before. In this case use the last user applied mode if (m_stereoModeSetByUser != RENDER_STEREO_MODE_OFF) targetMode = m_stereoModeSetByUser; else if (m_lastStereoModeSetByUser != RENDER_STEREO_MODE_UNDEFINED && m_lastStereoModeSetByUser != RENDER_STEREO_MODE_OFF) targetMode = m_lastStereoModeSetByUser; } SetStereoModeByUser(targetMode); } else { SetStereoModeByUser(RENDER_STEREO_MODE_OFF); } return true; } else if (action.GetID() == ACTION_STEREOMODE_SELECT) { SetStereoModeByUser(GetStereoModeByUserChoice()); return true; } else if (action.GetID() == ACTION_STEREOMODE_TOMONO) { if (mode == RENDER_STEREO_MODE_MONO) { RENDER_STEREO_MODE targetMode = GetPreferredPlaybackMode(); // if we have an old userdefined steremode, use that one as toggle target if (m_stereoModeSetByUser != RENDER_STEREO_MODE_UNDEFINED) { // if user mode is set to OFF, he manually turned it off before. In this case use the last user applied mode if (m_stereoModeSetByUser != RENDER_STEREO_MODE_OFF && m_stereoModeSetByUser != mode) targetMode = m_stereoModeSetByUser; else if (m_lastStereoModeSetByUser != RENDER_STEREO_MODE_UNDEFINED && m_lastStereoModeSetByUser != RENDER_STEREO_MODE_OFF && m_lastStereoModeSetByUser != mode) targetMode = m_lastStereoModeSetByUser; } SetStereoModeByUser(targetMode); } else { SetStereoModeByUser(RENDER_STEREO_MODE_MONO); } return true; } else if (action.GetID() == ACTION_STEREOMODE_SET) { int stereoMode = ConvertStringToGuiStereoMode(action.GetName()); if (stereoMode > -1) SetStereoModeByUser( (RENDER_STEREO_MODE) stereoMode ); return true; } return false; }
bool CGUIWindowSlideShow::OnAction(const CAction &action) { switch (action.GetID()) { case ACTION_SHOW_INFO: { CGUIDialogPictureInfo *pictureInfo = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogPictureInfo>(WINDOW_DIALOG_PICTURE_INFO); if (pictureInfo) { // no need to set the picture here, it's done in Render() pictureInfo->Open(); } } break; case ACTION_STOP: if (m_slides.size()) AnnouncePlayerStop(m_slides.at(m_iCurrentSlide)); if (g_application.GetAppPlayer().IsPlayingVideo()) g_application.GetAppPlayer().ClosePlayer(); Close(); break; case ACTION_NEXT_PICTURE: ShowNext(); break; case ACTION_PREV_PICTURE: ShowPrevious(); break; case ACTION_MOVE_RIGHT: if (m_iZoomFactor == 1 || !m_Image[m_iCurrentPic].m_bCanMoveHorizontally) ShowNext(); else Move(PICTURE_MOVE_AMOUNT, 0); break; case ACTION_MOVE_LEFT: if (m_iZoomFactor == 1 || !m_Image[m_iCurrentPic].m_bCanMoveHorizontally) ShowPrevious(); else Move( -PICTURE_MOVE_AMOUNT, 0); break; case ACTION_MOVE_DOWN: Move(0, PICTURE_MOVE_AMOUNT); break; case ACTION_MOVE_UP: Move(0, -PICTURE_MOVE_AMOUNT); break; case ACTION_PAUSE: case ACTION_PLAYER_PLAY: if (m_slides.size() == 0) break; if (m_slides.at(m_iCurrentSlide)->IsVideo()) { if (!m_bPlayingVideo) { if (m_bSlideShow) { SetDirection(1); m_bPause = false; } PlayVideo(); } } else if (!m_bSlideShow || m_bPause) { m_bSlideShow = true; m_bPause = false; SetDirection(1); if (m_Image[m_iCurrentPic].IsLoaded()) { CSlideShowPic::DISPLAY_EFFECT effect = GetDisplayEffect(m_iCurrentSlide); if (m_Image[m_iCurrentPic].DisplayEffectNeedChange(effect)) m_Image[m_iCurrentPic].Reset(effect); } AnnouncePlayerPlay(m_slides.at(m_iCurrentSlide)); } else if (action.GetID() == ACTION_PAUSE) { m_bPause = true; AnnouncePlayerPause(m_slides.at(m_iCurrentSlide)); } break; case ACTION_ZOOM_OUT: Zoom(m_iZoomFactor - 1); break; case ACTION_ZOOM_IN: Zoom(m_iZoomFactor + 1); break; case ACTION_GESTURE_SWIPE_UP: case ACTION_GESTURE_SWIPE_DOWN: if (m_iZoomFactor == 1 || !m_Image[m_iCurrentPic].m_bCanMoveVertically) { bool swipeOnLeft = action.GetAmount() < CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth() / 2.0f; bool swipeUp = action.GetID() == ACTION_GESTURE_SWIPE_UP; if (swipeUp == swipeOnLeft) Rotate(90.0f); else Rotate(-90.0f); } break; case ACTION_ROTATE_PICTURE_CW: Rotate(90.0f); break; case ACTION_ROTATE_PICTURE_CCW: Rotate(-90.0f); break; case ACTION_ZOOM_LEVEL_NORMAL: case ACTION_ZOOM_LEVEL_1: case ACTION_ZOOM_LEVEL_2: case ACTION_ZOOM_LEVEL_3: case ACTION_ZOOM_LEVEL_4: case ACTION_ZOOM_LEVEL_5: case ACTION_ZOOM_LEVEL_6: case ACTION_ZOOM_LEVEL_7: case ACTION_ZOOM_LEVEL_8: case ACTION_ZOOM_LEVEL_9: Zoom((action.GetID() - ACTION_ZOOM_LEVEL_NORMAL) + 1); break; case ACTION_ANALOG_MOVE: // this action is used and works, when CAction object provides both x and y coordinates Move(action.GetAmount()*PICTURE_MOVE_AMOUNT_ANALOG, -action.GetAmount(1)*PICTURE_MOVE_AMOUNT_ANALOG); break; case ACTION_ANALOG_MOVE_X_LEFT: Move(-action.GetAmount()*PICTURE_MOVE_AMOUNT_ANALOG, 0.0f); break; case ACTION_ANALOG_MOVE_X_RIGHT: Move(action.GetAmount()*PICTURE_MOVE_AMOUNT_ANALOG, 0.0f); break; case ACTION_ANALOG_MOVE_Y_UP: Move(0.0f, -action.GetAmount()*PICTURE_MOVE_AMOUNT_ANALOG); break; case ACTION_ANALOG_MOVE_Y_DOWN: Move(0.0f, action.GetAmount()*PICTURE_MOVE_AMOUNT_ANALOG); break; default: return CGUIDialog::OnAction(action); } return true; }
bool CPlayerController::OnAction(const CAction &action) { const unsigned int MsgTime = 300; const unsigned int DisplTime = 2000; if (g_application.GetAppPlayer().IsPlayingVideo()) { switch (action.GetID()) { case ACTION_SHOW_SUBTITLES: { if (g_application.GetAppPlayer().GetSubtitleCount() == 0) return true; bool subsOn = !g_application.GetAppPlayer().GetSubtitleVisible(); g_application.GetAppPlayer().SetSubtitleVisible(subsOn); std::string sub, lang; if (subsOn) { SubtitleStreamInfo info; g_application.GetAppPlayer().GetSubtitleStreamInfo(g_application.GetAppPlayer().GetSubtitle(), info); if (!g_LangCodeExpander.Lookup(info.language, lang)) lang = g_localizeStrings.Get(13205); // Unknown if (info.name.length() == 0) sub = lang; else sub = StringUtils::Format("%s - %s", lang.c_str(), info.name.c_str()); } else sub = g_localizeStrings.Get(1223); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(287), sub, DisplTime, false, MsgTime); return true; } case ACTION_NEXT_SUBTITLE: case ACTION_CYCLE_SUBTITLE: { if (g_application.GetAppPlayer().GetSubtitleCount() == 0) return true; int currentSub = g_application.GetAppPlayer().GetSubtitle(); bool currentSubVisible = true; if (g_application.GetAppPlayer().GetSubtitleVisible()) { if (++currentSub >= g_application.GetAppPlayer().GetSubtitleCount()) { currentSub = 0; if (action.GetID() == ACTION_NEXT_SUBTITLE) { g_application.GetAppPlayer().SetSubtitleVisible(false); currentSubVisible = false; } } g_application.GetAppPlayer().SetSubtitle(currentSub); } else if (action.GetID() == ACTION_NEXT_SUBTITLE) { g_application.GetAppPlayer().SetSubtitleVisible(true); } std::string sub, lang; if (currentSubVisible) { SubtitleStreamInfo info; g_application.GetAppPlayer().GetSubtitleStreamInfo(currentSub, info); if (!g_LangCodeExpander.Lookup(info.language, lang)) lang = g_localizeStrings.Get(13205); // Unknown if (info.name.length() == 0) sub = lang; else sub = StringUtils::Format("%s - %s", lang.c_str(), info.name.c_str()); } else sub = g_localizeStrings.Get(1223); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(287), sub, DisplTime, false, MsgTime); return true; } case ACTION_SUBTITLE_DELAY_MIN: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_SubtitleDelay -= 0.1f; if (vs.m_SubtitleDelay < -g_advancedSettings.m_videoSubsDelayRange) vs.m_SubtitleDelay = -g_advancedSettings.m_videoSubsDelayRange; g_application.GetAppPlayer().SetSubTitleDelay(vs.m_SubtitleDelay); ShowSlider(action.GetID(), 22006, g_application.GetAppPlayer().GetVideoSettings().m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange); return true; } case ACTION_SUBTITLE_DELAY_PLUS: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_SubtitleDelay += 0.1f; if (vs.m_SubtitleDelay > g_advancedSettings.m_videoSubsDelayRange) vs.m_SubtitleDelay = g_advancedSettings.m_videoSubsDelayRange; g_application.GetAppPlayer().SetSubTitleDelay(vs.m_SubtitleDelay); ShowSlider(action.GetID(), 22006, g_application.GetAppPlayer().GetVideoSettings().m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange); return true; } case ACTION_SUBTITLE_DELAY: { ShowSlider(action.GetID(), 22006, g_application.GetAppPlayer().GetVideoSettings().m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange, true); return true; } case ACTION_AUDIO_DELAY: { ShowSlider(action.GetID(), 297, g_application.GetAppPlayer().GetVideoSettings().m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, 0.025f, g_advancedSettings.m_videoAudioDelayRange, true); return true; } case ACTION_AUDIO_DELAY_MIN: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_AudioDelay -= 0.025f; if (vs.m_AudioDelay < -g_advancedSettings.m_videoAudioDelayRange) vs.m_AudioDelay = -g_advancedSettings.m_videoAudioDelayRange; g_application.GetAppPlayer().SetAVDelay(vs.m_AudioDelay); ShowSlider(action.GetID(), 297, g_application.GetAppPlayer().GetVideoSettings().m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, 0.025f, g_advancedSettings.m_videoAudioDelayRange); return true; } case ACTION_AUDIO_DELAY_PLUS: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_AudioDelay += 0.025f; if (vs.m_AudioDelay > g_advancedSettings.m_videoAudioDelayRange) vs.m_AudioDelay = g_advancedSettings.m_videoAudioDelayRange; g_application.GetAppPlayer().SetAVDelay(vs.m_AudioDelay); ShowSlider(action.GetID(), 297, g_application.GetAppPlayer().GetVideoSettings().m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, 0.025f, g_advancedSettings.m_videoAudioDelayRange); return true; } case ACTION_AUDIO_NEXT_LANGUAGE: { if (g_application.GetAppPlayer().GetAudioStreamCount() == 1) return true; int currentAudio = g_application.GetAppPlayer().GetAudioStream(); if (++currentAudio >= g_application.GetAppPlayer().GetAudioStreamCount()) currentAudio = 0; g_application.GetAppPlayer().SetAudioStream(currentAudio); // Set the audio stream to the one selected std::string aud; std::string lan; AudioStreamInfo info; g_application.GetAppPlayer().GetAudioStreamInfo(currentAudio, info); if (!g_LangCodeExpander.Lookup(info.language, lan)) lan = g_localizeStrings.Get(13205); // Unknown if (info.name.empty()) aud = lan; else aud = StringUtils::Format("%s - %s", lan.c_str(), info.name.c_str()); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(460), aud, DisplTime, false, MsgTime); return true; } case ACTION_ZOOM_IN: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_CustomZoomAmount += 0.01f; if (vs.m_CustomZoomAmount > 2.f) vs.m_CustomZoomAmount = 2.f; vs.m_ViewMode = ViewModeCustom; g_application.GetAppPlayer().SetRenderViewMode(ViewModeCustom, vs.m_CustomZoomAmount, vs.m_CustomPixelRatio, vs.m_CustomVerticalShift, vs.m_CustomNonLinStretch); ShowSlider(action.GetID(), 216, vs.m_CustomZoomAmount, 0.5f, 0.1f, 2.0f); return true; } case ACTION_ZOOM_OUT: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_CustomZoomAmount -= 0.01f; if (vs.m_CustomZoomAmount < 0.5f) vs.m_CustomZoomAmount = 0.5f; vs.m_ViewMode = ViewModeCustom; g_application.GetAppPlayer().SetRenderViewMode(ViewModeCustom, vs.m_CustomZoomAmount, vs.m_CustomPixelRatio, vs.m_CustomVerticalShift, vs.m_CustomNonLinStretch); ShowSlider(action.GetID(), 216, vs.m_CustomZoomAmount, 0.5f, 0.1f, 2.0f); return true; } case ACTION_INCREASE_PAR: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_CustomPixelRatio += 0.01f; if (vs.m_CustomPixelRatio > 2.f) vs.m_CustomPixelRatio = 2.f; vs.m_ViewMode = ViewModeCustom; g_application.GetAppPlayer().SetRenderViewMode(ViewModeCustom, vs.m_CustomZoomAmount, vs.m_CustomPixelRatio, vs.m_CustomVerticalShift, vs.m_CustomNonLinStretch); ShowSlider(action.GetID(), 217, vs.m_CustomPixelRatio, 0.5f, 0.1f, 2.0f); return true; } case ACTION_DECREASE_PAR: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_CustomPixelRatio -= 0.01f; if (vs.m_CustomPixelRatio < 0.5f) vs.m_CustomPixelRatio = 0.5f; vs.m_ViewMode = ViewModeCustom; g_application.GetAppPlayer().SetRenderViewMode(ViewModeCustom, vs.m_CustomZoomAmount, vs.m_CustomPixelRatio, vs.m_CustomVerticalShift, vs.m_CustomNonLinStretch); ShowSlider(action.GetID(), 217, vs.m_CustomPixelRatio, 0.5f, 0.1f, 2.0f); return true; } case ACTION_VSHIFT_UP: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_CustomVerticalShift -= 0.01f; if (vs.m_CustomVerticalShift < -2.0f) vs.m_CustomVerticalShift = -2.0f; vs.m_ViewMode = ViewModeCustom; g_application.GetAppPlayer().SetRenderViewMode(ViewModeCustom, vs.m_CustomZoomAmount, vs.m_CustomPixelRatio, vs.m_CustomVerticalShift, vs.m_CustomNonLinStretch); ShowSlider(action.GetID(), 225, vs.m_CustomVerticalShift, -2.0f, 0.1f, 2.0f); return true; } case ACTION_VSHIFT_DOWN: { CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); vs.m_CustomVerticalShift += 0.01f; if (vs.m_CustomVerticalShift > 2.0f) vs.m_CustomVerticalShift = 2.0f; vs.m_ViewMode = ViewModeCustom; g_application.GetAppPlayer().SetRenderViewMode(ViewModeCustom, vs.m_CustomZoomAmount, vs.m_CustomPixelRatio, vs.m_CustomVerticalShift, vs.m_CustomNonLinStretch); ShowSlider(action.GetID(), 225, vs.m_CustomVerticalShift, -2.0f, 0.1f, 2.0f); return true; } case ACTION_SUBTITLE_VSHIFT_UP: { RESOLUTION_INFO res_info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(); int subalign = CServiceBroker::GetSettings().GetInt(CSettings::SETTING_SUBTITLES_ALIGN); if ((subalign == SUBTITLE_ALIGN_BOTTOM_OUTSIDE) || (subalign == SUBTITLE_ALIGN_TOP_INSIDE)) { res_info.iSubtitles ++; if (res_info.iSubtitles >= res_info.iHeight) res_info.iSubtitles = res_info.iHeight - 1; ShowSlider(action.GetID(), 274, (float) res_info.iHeight - res_info.iSubtitles, 0.0f, 1.0f, (float) res_info.iHeight); } else { res_info.iSubtitles --; if (res_info.iSubtitles < 0) res_info.iSubtitles = 0; if (subalign == SUBTITLE_ALIGN_MANUAL) ShowSlider(action.GetID(), 274, (float) res_info.iSubtitles, 0.0f, 1.0f, (float) res_info.iHeight); else ShowSlider(action.GetID(), 274, (float) res_info.iSubtitles - res_info.iHeight, (float) -res_info.iHeight, -1.0f, 0.0f); } CServiceBroker::GetWinSystem()->GetGfxContext().SetResInfo(CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution(), res_info); return true; } case ACTION_SUBTITLE_VSHIFT_DOWN: { RESOLUTION_INFO res_info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(); int subalign = CServiceBroker::GetSettings().GetInt(CSettings::SETTING_SUBTITLES_ALIGN); if ((subalign == SUBTITLE_ALIGN_BOTTOM_OUTSIDE) || (subalign == SUBTITLE_ALIGN_TOP_INSIDE)) { res_info.iSubtitles--; if (res_info.iSubtitles < 0) res_info.iSubtitles = 0; ShowSlider(action.GetID(), 274, (float) res_info.iHeight - res_info.iSubtitles, 0.0f, 1.0f, (float) res_info.iHeight); } else { res_info.iSubtitles++; if (res_info.iSubtitles >= res_info.iHeight) res_info.iSubtitles = res_info.iHeight - 1; if (subalign == SUBTITLE_ALIGN_MANUAL) ShowSlider(action.GetID(), 274, (float) res_info.iSubtitles, 0.0f, 1.0f, (float) res_info.iHeight); else ShowSlider(action.GetID(), 274, (float) res_info.iSubtitles - res_info.iHeight, (float) -res_info.iHeight, -1.0f, 0.0f); } CServiceBroker::GetWinSystem()->GetGfxContext().SetResInfo(CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution(), res_info); return true; } case ACTION_SUBTITLE_ALIGN: { RESOLUTION_INFO res_info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(); int subalign = CServiceBroker::GetSettings().GetInt(CSettings::SETTING_SUBTITLES_ALIGN); subalign++; if (subalign > SUBTITLE_ALIGN_TOP_OUTSIDE) subalign = SUBTITLE_ALIGN_MANUAL; res_info.iSubtitles = res_info.iHeight - 1; CServiceBroker::GetSettings().SetInt(CSettings::SETTING_SUBTITLES_ALIGN, subalign); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(21460), g_localizeStrings.Get(21461 + subalign), TOAST_DISPLAY_TIME, false); CServiceBroker::GetWinSystem()->GetGfxContext().SetResInfo(CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution(), res_info); return true; } case ACTION_VOLAMP_UP: case ACTION_VOLAMP_DOWN: { // Don't allow change with passthrough audio if (g_application.GetAppPlayer().IsPassthrough()) { CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(660), g_localizeStrings.Get(29802), TOAST_DISPLAY_TIME, false); return false; } float sliderMax = VOLUME_DRC_MAXIMUM / 100.0f; float sliderMin = VOLUME_DRC_MINIMUM / 100.0f; CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings(); if (action.GetID() == ACTION_VOLAMP_UP) vs.m_VolumeAmplification += 1.0f; else vs.m_VolumeAmplification -= 1.0f; vs.m_VolumeAmplification = std::max(std::min(vs.m_VolumeAmplification, sliderMax), sliderMin); g_application.GetAppPlayer().SetDynamicRangeCompression((long)(vs.m_VolumeAmplification * 100)); ShowSlider(action.GetID(), 660, vs.m_VolumeAmplification, sliderMin, 1.0f, sliderMax); return true; } case ACTION_VOLAMP: { float sliderMax = VOLUME_DRC_MAXIMUM / 100.0f; float sliderMin = VOLUME_DRC_MINIMUM / 100.0f; ShowSlider(action.GetID(), 660, g_application.GetAppPlayer().GetVideoSettings().m_VolumeAmplification, sliderMin, 1.0f, sliderMax, true); return true; } case ACTION_PLAYER_PROGRAM_SELECT: { std::vector<ProgramInfo> programs; g_application.GetAppPlayer().GetPrograms(programs); CGUIDialogSelect *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (dialog) { int playing = 0; int idx = 0; for (auto prog : programs) { dialog->Add(prog.name); if (prog.playing) playing = idx; idx++; } dialog->SetHeading(CVariant{g_localizeStrings.Get(39109)}); dialog->SetSelected(playing); dialog->Open(); idx = dialog->GetSelectedItem(); if (idx > 0) g_application.GetAppPlayer().SetProgram(programs[idx].id); } return true; } case ACTION_PLAYER_RESOLUTION_SELECT: { std::vector<CVariant> indexList = CServiceBroker::GetSettings().GetList(CSettings::SETTING_VIDEOSCREEN_WHITELIST); CGUIDialogSelect *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (dialog) { int current = 0; int idx = 0; auto currentRes = CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution(); for (const CVariant &mode : indexList) { auto res = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(res); dialog->Add(info.strMode); if (res == currentRes) current = idx; idx++; } dialog->SetHeading(CVariant{g_localizeStrings.Get(39110)}); dialog->SetSelected(current); dialog->Open(); idx = dialog->GetSelectedItem(); if (idx >= 0) { auto res = CDisplaySettings::GetInstance().GetResFromString(indexList[idx].asString()); CServiceBroker::GetWinSystem()->GetGfxContext().SetVideoResolution(res, false); } } return true; } default: break; } } return false; }
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action) { bool handled(true); if (action.GetID() == ACTION_BACKSPACE) { Backspace(); } else if (action.GetID() == ACTION_ENTER) { OnOK(); } else if (action.GetID() == ACTION_CURSOR_LEFT) { MoveCursor( -1); } else if (action.GetID() == ACTION_CURSOR_RIGHT) { if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' ')) { // add a space Character(L' '); } else MoveCursor(1); } else if (action.GetID() == ACTION_SHIFT) { OnShift(); } else if (action.GetID() == ACTION_SYMBOLS) { OnSymbols(); } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { OnRemoteNumberClick(action.GetID()); } else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) uint8_t b = action.GetID() & 0xFF; if (b == XBMCVK_HOME) { SetCursorPos(0); } else if (b == XBMCVK_END) { SetCursorPos(m_strEdit.GetLength()); } else if (b == XBMCVK_LEFT) { MoveCursor( -1); } else if (b == XBMCVK_RIGHT) { MoveCursor(1); } else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER) { OnOK(); } else if (b == XBMCVK_DELETE) { if (GetCursorPos() < m_strEdit.GetLength()) { MoveCursor(1); Backspace(); } } else if (b == XBMCVK_BACK) Backspace(); else if (b == XBMCVK_ESCAPE) Close(); } else if (action.GetID() >= KEY_ASCII) { // input from the keyboard //char ch = action.GetID() & 0xFF; int ch = action.GetUnicode(); // Ignore non-printing characters if ( !((0 <= ch && ch < 0x8) || (0xE <= ch && ch < 0x1B) || (0x1C <= ch && ch < 0x20)) ) { switch (ch) { case 0x8: // backspace Backspace(); break; case 0x9: // Tab (do nothing) case 0xB: // Non-printing character, ignore case 0xC: // Non-printing character, ignore break; case 0xA: // enter case 0xD: // enter OnOK(); break; case 0x1B: // escape Close(); break; case 0x7F: // Delete if (GetCursorPos() < m_strEdit.GetLength()) { MoveCursor(1); Backspace(); } break; default: //use character input Character(action.GetUnicode()); break; } } } else // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); if (handled && m_pCharCallback) { // we did _something_, so make sure our search message filter is reset m_pCharCallback(this, GetText()); } return handled; }
bool CGUIEditControl::OnAction(const CAction &action) { ValidateCursor(); if (m_inputType != INPUT_TYPE_READONLY) { if (action.GetID() == ACTION_BACKSPACE) { // backspace if (m_cursorPos) { if (!ClearMD5()) m_text2.erase(--m_cursorPos, 1); UpdateText(); } return true; } else if (action.GetID() == ACTION_MOVE_LEFT) { if (m_cursorPos > 0) { m_cursorPos--; UpdateText(false); return true; } } else if (action.GetID() == ACTION_MOVE_RIGHT) { if ((unsigned int) m_cursorPos < m_text2.size()) { m_cursorPos++; UpdateText(false); return true; } } else if (action.GetID() == ACTION_PASTE) { ClearMD5(); OnPasteClipboard(); return true; } else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) BYTE b = action.GetID() & 0xFF; if (b == XBMCVK_HOME) { m_cursorPos = 0; UpdateText(false); return true; } else if (b == XBMCVK_END) { m_cursorPos = m_text2.length(); UpdateText(false); return true; } if (b == XBMCVK_LEFT && m_cursorPos > 0) { m_cursorPos--; UpdateText(false); return true; } if (b == XBMCVK_RIGHT && m_cursorPos < m_text2.length()) { m_cursorPos++; UpdateText(false); return true; } if (b == XBMCVK_DELETE) { if (m_cursorPos < m_text2.length()) { if (!ClearMD5()) m_text2.erase(m_cursorPos, 1); UpdateText(); return true; } } if (b == XBMCVK_BACK) { if (m_cursorPos > 0) { if (!ClearMD5()) m_text2.erase(--m_cursorPos, 1); UpdateText(); } return true; } } else if (action.GetID() >= KEY_ASCII) { // input from the keyboard switch (action.GetUnicode()) { case '\t': break; case 10: case 13: { // enter - send click message, but otherwise ignore SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1); return true; } case 27: { // escape - fallthrough to default action return CGUIButtonControl::OnAction(action); } case 8: { // backspace if (m_cursorPos) { if (!ClearMD5()) m_text2.erase(--m_cursorPos, 1); } break; } default: { ClearMD5(); m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.GetUnicode()); break; } } UpdateText(); return true; } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { // input from the remote ClearMD5(); if (m_inputType == INPUT_TYPE_FILTER) { // filtering - use single number presses m_text2.insert(m_text2.begin() + m_cursorPos++, L'0' + (action.GetID() - REMOTE_0)); UpdateText(); } else OnSMSCharacter(action.GetID() - REMOTE_0); return true; } } return CGUIButtonControl::OnAction(action); }
bool CGUIWindowFullScreen::OnAction(const CAction &action) { if (m_timeCodePosition > 0 && action.GetButtonCode()) { // check whether we have a mapping in our virtual videotimeseek "window" and have a select action CKey key(action.GetButtonCode()); CAction timeSeek = CButtonTranslator::GetInstance().GetAction(WINDOW_VIDEO_TIME_SEEK, key, false); if (timeSeek.GetID() == ACTION_SELECT_ITEM) { SeekToTimeCodeStamp(SEEK_ABSOLUTE); return true; } } if (CSettings::GetInstance().GetBool(CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH) && g_infoManager.IsPlayerChannelPreviewActive() && (action.GetID() == ACTION_SELECT_ITEM || CButtonTranslator::GetInstance().GetGlobalAction(action.GetButtonCode()).GetID() == ACTION_SELECT_ITEM)) { // If confirm channel switch is active, channel preview is currently shown // and the button that caused this action matches (global) action "Select" (OK) // switch to the channel currently displayed within the preview. g_application.m_pPlayer->SwitchChannel(g_application.CurrentFileItem().GetPVRChannelInfoTag()); return true; } switch (action.GetID()) { case ACTION_SHOW_OSD: ToggleOSD(); return true; case ACTION_TRIGGER_OSD: TriggerOSD(); return true; case ACTION_SHOW_GUI: { // switch back to the menu g_windowManager.PreviousWindow(); return true; } break; case ACTION_PLAYER_PLAY: case ACTION_PAUSE: if (m_timeCodePosition > 0) { SeekToTimeCodeStamp(SEEK_ABSOLUTE); return true; } break; case ACTION_SMALL_STEP_BACK: case ACTION_STEP_BACK: case ACTION_BIG_STEP_BACK: case ACTION_CHAPTER_OR_BIG_STEP_BACK: if (m_timeCodePosition > 0) { SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_BACKWARD); return true; } break; case ACTION_STEP_FORWARD: case ACTION_BIG_STEP_FORWARD: case ACTION_CHAPTER_OR_BIG_STEP_FORWARD: if (m_timeCodePosition > 0) { SeekToTimeCodeStamp(SEEK_RELATIVE, SEEK_FORWARD); return true; } break; case ACTION_SHOW_OSD_TIME: m_bShowCurrentTime = !m_bShowCurrentTime; g_infoManager.SetShowTime(m_bShowCurrentTime); return true; break; case ACTION_SHOW_INFO: { CGUIDialogFullScreenInfo* pDialog = (CGUIDialogFullScreenInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) { CFileItem item(g_application.CurrentFileItem()); pDialog->Open(); return true; } break; } case REMOTE_0: case REMOTE_1: case REMOTE_2: case REMOTE_3: case REMOTE_4: case REMOTE_5: case REMOTE_6: case REMOTE_7: case REMOTE_8: case REMOTE_9: { if (!g_application.CurrentFileItem().IsLiveTV()) { ChangetheTimeCode(action.GetID()); return true; } } break; case ACTION_ASPECT_RATIO: { // toggle the aspect ratio mode (only if the info is onscreen) if (m_bShowViewModeInfo) { #ifdef HAS_VIDEO_PLAYBACK g_application.m_pPlayer->SetRenderViewMode(++CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode); #endif } m_bShowViewModeInfo = true; m_dwShowViewModeTimeout = XbmcThreads::SystemClockMillis(); } return true; break; case ACTION_SHOW_PLAYLIST: { CFileItem item(g_application.CurrentFileItem()); if (item.HasPVRChannelInfoTag()) g_windowManager.ActivateWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS); else if (item.HasVideoInfoTag()) g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST); else if (item.HasMusicInfoTag()) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); } return true; break; default: break; } return CGUIWindow::OnAction(action); }