void GenericPanelList::RelinkNavigation( void ) { int i; for( i = 0; i != m_PanelItems.Count(); ++i ) { m_PanelItems[i]->SetNavUp( (vgui::Panel *)NULL ); m_PanelItems[i]->SetNavDown( (vgui::Panel *)NULL ); } if ( m_ItemSelectionModeMask & GenericPanelList::ISM_PERITEM ) { Panel *pLastValid = NULL; Panel *pFirstValid = NULL; for( i = 0; i != m_PanelItems.Count(); ++i ) { if( m_PanelItems[i]->IsVisible() ) { pFirstValid = m_PanelItems[i]; pLastValid = pFirstValid; ++ i; break; } } for( ; i != m_PanelItems.Count(); ++i ) { Panel *pCurrentPanel = m_PanelItems[i]; if( pCurrentPanel->IsVisible() ) { pLastValid->SetNavDown( pCurrentPanel ); pCurrentPanel->SetNavUp( pLastValid ); pLastValid = pCurrentPanel; } } if( pFirstValid ) { pFirstValid->SetNavUp( pLastValid ); pLastValid->SetNavDown( pFirstValid ); } } if( m_pItemNavigationChangedCallback ) { for( i = 0; i != m_PanelItems.Count(); ++i ) { m_pItemNavigationChangedCallback( this, m_PanelItems[i] ); } } }
//----------------------------------------------------------------------------- // Purpose: finds the panel which is activated by the specified key // Input : code - the keycode of the hotkey // Output : Panel * - NULL if no panel found //----------------------------------------------------------------------------- Panel *FocusNavGroup::FindPanelByHotkey(wchar_t key) { for (int i = 0; i < _mainPanel->GetChildCount(); i++) { Panel *child = _mainPanel->GetChild(i); if ( !child ) continue; Panel *hot = child->HasHotkey(key); if (hot && hot->IsVisible() && hot->IsEnabled()) { return hot; } } return NULL; }
//----------------------------------------------------------------------------- // Purpose: Gets the panel with the specified hotkey //----------------------------------------------------------------------------- Panel *EditablePanel::HasHotkey(wchar_t key) { if( !IsVisible() || !IsEnabled()) // not visible, so can't respond to a hot key { return NULL; } for (int i = 0; i < GetChildCount(); i++) { Panel *hot = GetChild(i)->HasHotkey(key); if (hot && hot->IsVisible() && hot->IsEnabled()) { return hot; } } return NULL; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void WizardPanel::ResetKeyFocus() { // set the focus on the default FocusNavGroup &navGroup = GetFocusNavGroup(); Panel *def = navGroup.GetDefaultPanel(); if (def) { if (def->IsEnabled() && def->IsVisible()) { def->RequestFocus(); } else { def->RequestFocusNext(); } } ResetDefaultButton(); }
//----------------------------------------------------------------------------- // Purpose: Sets the focus to the previous panel in the tab order // Input : *panel - panel currently with focus //----------------------------------------------------------------------------- bool FocusNavGroup::RequestFocusPrev(VPANEL panel) { if(panel==NULL) return false; _currentFocus = NULL; int newPosition = 9999999; if (panel) { newPosition = ipanel()->GetTabPosition(panel); } bool bFound = false; bool bRepeat = true; Panel *best = NULL; while (1) { newPosition--; if (newPosition > 0) { int bestPosition = 0; // look for the next tab position for (int i = 0; i < _mainPanel->GetChildCount(); i++) { Panel *child = _mainPanel->GetChild(i); if (child && child->IsVisible() && child->IsEnabled() && child->GetTabPosition()) { int tabPosition = child->GetTabPosition(); if (tabPosition == newPosition) { // we've found the right tab best = child; bestPosition = newPosition; // don't loop anymore since we've found the correct panel break; } else if (tabPosition < newPosition && tabPosition > bestPosition) { // record the match since this is the closest so far bestPosition = tabPosition; best = child; } } } if (!bRepeat) break; if (best) break; } else { // reset new position for next loop newPosition = 9999999; } // haven't found an item if (!_topLevelFocus) { // check to see if we should push the focus request up if (_mainPanel->GetVParent() && _mainPanel->GetVParent() != surface()->GetEmbeddedPanel()) { // we're not a top level panel, so forward up the request instead of looping if (ipanel()->RequestFocusPrev(_mainPanel->GetVParent(), _mainPanel->GetVPanel())) { bFound = true; SetCurrentDefaultButton(NULL); break; } } } // not found an item, loop back newPosition = 9999999; bRepeat = false; } if (best) { _currentFocus = best->GetVPanel(); best->RequestFocus(-1); bFound = true; if (!CanButtonBeDefault(best->GetVPanel())) { if (_defaultButton) { SetCurrentDefaultButton(_defaultButton); } else { SetCurrentDefaultButton(NULL); // we need to ask the parent to set its default button if (_mainPanel->GetVParent()) { ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), NULL); } } } else { SetCurrentDefaultButton(best->GetVPanel()); } } return bFound; }
//----------------------------------------------------------------------------- // Purpose: Sets the focus to the previous panel in the tab order // Input : *panel - panel currently with focus //----------------------------------------------------------------------------- bool FocusNavGroup::RequestFocusNext(VPANEL panel) { // basic recursion guard, in case user has set up a bad focus hierarchy static int stack_depth = 0; stack_depth++; _currentFocus = NULL; int newPosition = 0; if (panel) { newPosition = ipanel()->GetTabPosition(panel); } bool bFound = false; bool bRepeat = true; Panel *best = NULL; while (1) { newPosition++; int bestPosition = 999999; // look for the next tab position for (int i = 0; i < _mainPanel->GetChildCount(); i++) { Panel *child = _mainPanel->GetChild(i); if ( !child ) continue; if (child && child->IsVisible() && child->IsEnabled() && child->GetTabPosition()) { int tabPosition = child->GetTabPosition(); if (tabPosition == newPosition) { // we've found the right tab best = child; bestPosition = newPosition; // don't loop anymore since we've found the correct panel break; } else if (tabPosition > newPosition && tabPosition < bestPosition) { // record the match since this is the closest so far bestPosition = tabPosition; best = child; } } } if (!bRepeat) break; if (best) break; // haven't found an item // check to see if we should push the focus request up if (!_topLevelFocus) { if (_mainPanel->GetVParent() && _mainPanel->GetVParent() != surface()->GetEmbeddedPanel()) { // we're not a top level panel, so forward up the request instead of looping if (stack_depth < 15) { if (ipanel()->RequestFocusNext(_mainPanel->GetVParent(), _mainPanel->GetVPanel())) { bFound = true; SetCurrentDefaultButton(NULL); break; } // if we find one then we break, otherwise we loop } } } // loop back newPosition = 0; bRepeat = false; } if (best) { _currentFocus = best->GetVPanel(); best->RequestFocus(1); bFound = true; if (!CanButtonBeDefault(best->GetVPanel())) { if (_defaultButton) { SetCurrentDefaultButton(_defaultButton); } else { SetCurrentDefaultButton(NULL); // we need to ask the parent to set its default button if (_mainPanel->GetVParent()) { ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), NULL); } } } else { SetCurrentDefaultButton(best->GetVPanel()); } } stack_depth--; return bFound; }
void LoadingProgress::PaintBackground() { int screenWide, screenTall; surface()->GetScreenSize( screenWide, screenTall ); if ( m_bDrawBackground && m_pBGImage ) { int x, y, wide, tall; m_pBGImage->GetBounds( x, y, wide, tall ); surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pBGImage->GetImage()->GetID() ); surface()->DrawTexturedRect( x, y, x+wide, y+tall ); } if ( m_bDrawPoster && m_pPoster && m_pPoster->GetImage() ) { if ( m_bFullscreenPoster ) { surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pPoster->GetImage()->GetID() ); surface()->DrawTexturedRect( 0, 0, screenWide, screenTall ); } else { // fill black surface()->DrawSetColor( Color( 0, 0, 0, 255 ) ); surface()->DrawFilledRect( 0, 0, screenWide, screenTall ); // overlay poster int x, y, wide, tall; m_pPoster->GetBounds( x, y, wide, tall ); surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pPoster->GetImage()->GetID() ); surface()->DrawTexturedRect( x, y, x+wide, y+tall ); } } if ( m_bDrawPoster && m_pFooter ) { int screenWidth, screenHeight; CBaseModPanel::GetSingleton().GetSize( screenWidth, screenHeight ); int x, y, wide, tall; m_pFooter->GetBounds( x, y, wide, tall ); surface()->DrawSetColor( m_pFooter->GetBgColor() ); surface()->DrawFilledRect( 0, y, x+screenWidth, y+tall ); } // this is where the spinner draws bool bRenderSpinner = ( m_bDrawSpinner && m_pWorkingAnim ); Panel *pWaitscreen = CBaseModPanel::GetSingleton().GetWindow( WT_GENERICWAITSCREEN ); if ( pWaitscreen && pWaitscreen->IsVisible() && ( m_LoadingWindowType == LWT_BKGNDSCREEN ) ) bRenderSpinner = false; // Don't render spinner if the progress screen is displaying progress if ( bRenderSpinner ) { int x, y, wide, tall; wide = tall = scheme()->GetProportionalScaledValue( 45 ); x = scheme()->GetProportionalScaledValue( 45 ) - wide/2; y = screenTall - scheme()->GetProportionalScaledValue( 32 ) - tall/2; m_pWorkingAnim->GetImage()->SetFrame( m_pWorkingAnim->GetFrame() ); surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pWorkingAnim->GetImage()->GetID() ); surface()->DrawTexturedRect( x, y, x+wide, y+tall ); } if ( m_bDrawProgress && m_pProTotalProgress ) { int x, y, wide, tall; m_pProTotalProgress->GetBounds( x, y, wide, tall ); int iScreenWide, iScreenTall; surface()->GetScreenSize( iScreenWide, iScreenTall ); float f = m_pProTotalProgress->GetProgress(); f = clamp( f, 0, 1.0f ); // Textured bar surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); // Texture BG surface()->DrawSetTexture( m_textureID_LoadingBarBG ); surface()->DrawTexturedRect( x, y, x + wide, y + tall ); surface()->DrawSetTexture( m_textureID_LoadingBar ); // YWB 10/13/2009: If we don't crop the texture coordinate down then we will see a jitter of the texture as the texture coordinate and the rounded width // alias int nIntegerWide = f * wide; float flUsedFrac = (float)nIntegerWide / (float)wide; DrawTexturedRectParms_t params; params.x0 = x; params.y0 = y; params.x1 = x + nIntegerWide; params.y1 = y + tall; params.s0 = 0; params.s1 = flUsedFrac; surface()->DrawTexturedRectEx( ¶ms ); } // Need to call this periodically to collect sign in and sign out notifications, // do NOT dispatch events here in the middle of loading and rendering! if ( ThreadInMainThread() ) { XBX_ProcessEvents(); } }
int FilePanels::ProcessKey(const Manager::Key& Key) { auto LocalKey = Key.FarKey(); if (!LocalKey) return TRUE; if ((LocalKey==KEY_CTRLLEFT || LocalKey==KEY_CTRLRIGHT || LocalKey==KEY_CTRLNUMPAD4 || LocalKey==KEY_CTRLNUMPAD6 || LocalKey==KEY_RCTRLLEFT || LocalKey==KEY_RCTRLRIGHT || LocalKey==KEY_RCTRLNUMPAD4 || LocalKey==KEY_RCTRLNUMPAD6 /* || LocalKey==KEY_CTRLUP || LocalKey==KEY_CTRLDOWN || LocalKey==KEY_CTRLNUMPAD8 || LocalKey==KEY_CTRLNUMPAD2 */) && (CmdLine->GetLength()>0 || (!LeftPanel->IsVisible() && !RightPanel->IsVisible()))) { CmdLine->ProcessKey(Key); return TRUE; } switch (LocalKey) { case KEY_F1: { if (!m_ActivePanel->ProcessKey(Manager::Key(KEY_F1))) { Help::create(L"Contents"); } return TRUE; } case KEY_TAB: { SetAnhoterPanelFocus(); break; } case KEY_CTRLF1: case KEY_RCTRLF1: { if (LeftPanel->IsVisible()) { LeftPanel->Hide(); if (RightPanel->IsVisible()) RightPanel->SetFocus(); } else { if (!RightPanel->IsVisible()) LeftPanel->SetFocus(); LeftPanel->Show(); } Redraw(); break; } case KEY_CTRLF2: case KEY_RCTRLF2: { if (RightPanel->IsVisible()) { RightPanel->Hide(); if (LeftPanel->IsVisible()) LeftPanel->SetFocus(); } else { if (!LeftPanel->IsVisible()) RightPanel->SetFocus(); RightPanel->Show(); } Redraw(); break; } case KEY_CTRLB: case KEY_RCTRLB: { Global->Opt->ShowKeyBar=!Global->Opt->ShowKeyBar; m_KeyBarVisible = Global->Opt->ShowKeyBar; if (!m_KeyBarVisible) m_windowKeyBar->Hide(); SetScreenPosition(); Global->WindowManager->RefreshWindow(); break; } case KEY_CTRLT: case KEY_RCTRLT: if (Global->Opt->Tree.TurnOffCompletely) break; case KEY_CTRLL: case KEY_RCTRLL: case KEY_CTRLQ: case KEY_RCTRLQ: { if (m_ActivePanel->IsVisible()) { Panel *AnotherPanel = PassivePanel(); int NewType; if (LocalKey==KEY_CTRLL || LocalKey==KEY_RCTRLL) NewType=INFO_PANEL; else if (LocalKey==KEY_CTRLQ || LocalKey==KEY_RCTRLQ) NewType=QVIEW_PANEL; else NewType=TREE_PANEL; if (m_ActivePanel->GetType() == NewType) AnotherPanel = m_ActivePanel; if (!AnotherPanel->ProcessPluginEvent(FE_CLOSE,nullptr)) { if (AnotherPanel->GetType()==NewType) /* $ 19.09.2000 IS Повторное нажатие на ctrl-l|q|t всегда включает файловую панель */ AnotherPanel=ChangePanel(AnotherPanel,FILE_PANEL,FALSE,FALSE); else AnotherPanel=ChangePanel(AnotherPanel,NewType,FALSE,FALSE); /* $ 07.09.2001 VVM ! При возврате из CTRL+Q, CTRL+L восстановим каталог, если активная панель - дерево. */ if (m_ActivePanel->GetType() == TREE_PANEL) { string strCurDir(m_ActivePanel->GetCurDir()); AnotherPanel->SetCurDir(strCurDir, true); AnotherPanel->Update(0); } else AnotherPanel->Update(UPDATE_KEEP_SELECTION); AnotherPanel->Show(); } m_ActivePanel->SetFocus(); } break; } case KEY_CTRLO: case KEY_RCTRLO: { { int LeftVisible=LeftPanel->IsVisible(); int RightVisible=RightPanel->IsVisible(); int HideState=!LeftVisible && !RightVisible; if (!HideState) { LeftStateBeforeHide=LeftVisible; RightStateBeforeHide=RightVisible; LeftPanel->Hide(); RightPanel->Hide(); Global->WindowManager->RefreshWindow(); } else { if (!LeftStateBeforeHide && !RightStateBeforeHide) LeftStateBeforeHide=RightStateBeforeHide=TRUE; if (LeftStateBeforeHide) LeftPanel->Show(); if (RightStateBeforeHide) RightPanel->Show(); if (!m_ActivePanel->IsVisible()) { if (m_ActivePanel == RightPanel) LeftPanel->SetFocus(); else RightPanel->SetFocus(); } } } break; } case KEY_CTRLP: case KEY_RCTRLP: { if (m_ActivePanel->IsVisible()) { Panel *AnotherPanel = PassivePanel(); if (AnotherPanel->IsVisible()) AnotherPanel->Hide(); else AnotherPanel->Show(); CmdLine->Redraw(); } Global->WindowManager->RefreshWindow(); break; } case KEY_CTRLI: case KEY_RCTRLI: { m_ActivePanel->EditFilter(); return TRUE; } case KEY_CTRLU: case KEY_RCTRLU: { if (!LeftPanel->IsVisible() && !RightPanel->IsVisible()) CmdLine->ProcessKey(Key); else SwapPanels(); break; } /* $ 08.04.2002 IS При смене диска установим принудительно текущий каталог на активной панели, т.к. система не знает ничего о том, что у Фара две панели, и текущим для системы после смены диска может быть каталог и на пассивной панели */ case KEY_ALTF1: case KEY_RALTF1: { LeftPanel->ChangeDisk(); if (ActivePanel() != LeftPanel) ActivePanel()->SetCurPath(); break; } case KEY_ALTF2: case KEY_RALTF2: { RightPanel->ChangeDisk(); if (ActivePanel() != RightPanel) ActivePanel()->SetCurPath(); break; } case KEY_ALTF7: case KEY_RALTF7: { FindFiles(); break; } case KEY_CTRLUP: case KEY_CTRLNUMPAD8: case KEY_RCTRLUP: case KEY_RCTRLNUMPAD8: { bool Set=false; if (Global->Opt->LeftHeightDecrement<ScrY-7) { ++Global->Opt->LeftHeightDecrement; Set=true; } if (Global->Opt->RightHeightDecrement<ScrY-7) { ++Global->Opt->RightHeightDecrement; Set=true; } if(Set) { SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_CTRLDOWN: case KEY_CTRLNUMPAD2: case KEY_RCTRLDOWN: case KEY_RCTRLNUMPAD2: { bool Set=false; if (Global->Opt->LeftHeightDecrement>0) { --Global->Opt->LeftHeightDecrement; Set=true; } if (Global->Opt->RightHeightDecrement>0) { --Global->Opt->RightHeightDecrement; Set=true; } if(Set) { SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_CTRLSHIFTUP: case KEY_CTRLSHIFTNUMPAD8: case KEY_RCTRLSHIFTUP: case KEY_RCTRLSHIFTNUMPAD8: { IntOption& HeightDecrement = (m_ActivePanel == LeftPanel) ? Global->Opt->LeftHeightDecrement : Global->Opt->RightHeightDecrement; if (HeightDecrement<ScrY-7) { ++HeightDecrement; SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_CTRLSHIFTDOWN: case KEY_CTRLSHIFTNUMPAD2: case KEY_RCTRLSHIFTDOWN: case KEY_RCTRLSHIFTNUMPAD2: { IntOption& HeightDecrement = (m_ActivePanel == LeftPanel) ? Global->Opt->LeftHeightDecrement : Global->Opt->RightHeightDecrement; if (HeightDecrement>0) { --HeightDecrement; SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_CTRLLEFT: case KEY_CTRLNUMPAD4: case KEY_RCTRLLEFT: case KEY_RCTRLNUMPAD4: { if (Global->Opt->WidthDecrement<ScrX/2-10) { ++Global->Opt->WidthDecrement; SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_CTRLRIGHT: case KEY_CTRLNUMPAD6: case KEY_RCTRLRIGHT: case KEY_RCTRLNUMPAD6: { if (Global->Opt->WidthDecrement>-(ScrX/2-10)) { --Global->Opt->WidthDecrement; SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_CTRLCLEAR: case KEY_RCTRLCLEAR: { if (Global->Opt->WidthDecrement) { Global->Opt->WidthDecrement=0; SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_CTRLALTCLEAR: case KEY_RCTRLRALTCLEAR: case KEY_CTRLRALTCLEAR: case KEY_RCTRLALTCLEAR: { bool Set=false; if (Global->Opt->LeftHeightDecrement) { Global->Opt->LeftHeightDecrement=0; Set=true; } if (Global->Opt->RightHeightDecrement) { Global->Opt->RightHeightDecrement=0; Set=true; } if(Set) { SetScreenPosition(); Global->WindowManager->RefreshWindow(); } break; } case KEY_F9: { Global->Opt->ShellOptions(false,nullptr); return TRUE; } case KEY_SHIFTF10: { Global->Opt->ShellOptions(true,nullptr); return TRUE; } case KEY_F11: { // We will never get here in normal flow since F11 is processed by manager itself, // but auto-completion menu can forward keys back to the owner return Global->WindowManager->ProcessKey(Key); } default: { if (LocalKey >= KEY_CTRL0 && LocalKey <= KEY_CTRL9) ChangePanelViewMode(m_ActivePanel, LocalKey - KEY_CTRL0, TRUE); if (!m_ActivePanel->ProcessKey(Key)) CmdLine->ProcessKey(Key); break; } } return TRUE; }