GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — mainui_cpp/WindowSystem.cpp at master · FWGS/mainui_cpp Expand file tree/ Copy pathWindowSystem.cppMore file actions 345 lines (283 loc) · 7.17 KB / Copy pathWindowSystem.cppFile metadata and controls345 lines (283 loc) · 7.17 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 /* WindowSystem.cpp -- window system Copyright (C) 2019 a1batross This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #include "Primitive.h" #include "WindowSystem.h" #include "BaseWindow.h" #include "con_nprint.h" void CWindowStack::VidInit( bool calledOnce ) { // now recalc all the menus in stack FOR_EACH_LL( stack, i ) { CMenuBaseWindow *item = stack[i]; if( item ) { int cursor, cursorPrev; bool valid = false; // HACKHACK: Save cursor values when VidInit is called once // this don't let menu "forget" actual cursor values after, for example, window resizing if( calledOnce && item->GetCursor() > 0 // ignore 0, because useless && item->GetCursor() < item->ItemCount() && item->GetCursorPrev() > 0 && item->GetCursorPrev() < item->ItemCount() ) { valid = true; cursor = item->GetCursor(); cursorPrev = item->GetCursorPrev(); } // do vid restart for all pushed elements item->VidInit(); item->Reload(); if( valid ) { // don't notify menu widget about cursor changes item->SetCursor( cursorPrev, false ); item->SetCursor( cursor, false ); } } } } bool CWindowStack::IsVisible( const CMenuBaseWindow *menu ) const { if( menu == Current() ) return true; if( FBitSet( menu->iFlags, QMF_HIDDEN )) return false; // for some reason const_cast need here if( stack.Find( const_cast<CMenuBaseWindow*>( menu )) == stack.InvalidIndex()) return false; return true; } void CWindowStack::Update( ) { if( !IsActive() ) return; CUtlVector<CMenuBaseWindow *> drawList( 16 ); CUtlVector<int> removeList( 16 ); bool stop = Current()->IsRoot(); // always add current window drawList.AddToTail( Current() ); FOR_EACH_LL_BACK( stack, i ) { stack[i]->Think(); // any window must think if( i == active ) continue; // will be added last if( stack[i]->eTransitionType ) { drawList.AddToTail( stack[i] ); continue; } if( FBitSet( stack[i]->iFlags, QMF_CLOSING )) { // it's better to not change stack while we traverse it ClearBits( stack[i]->iFlags, QMF_CLOSING ); removeList.AddToTail( i ); continue; } // minimized windows if( stack[i]->iFlags & QMF_HIDDEN ) continue; if( stop ) // we don't need to search windows to draw continue; // maximized, no need to go further anymore, // but we need to check for closing windows, so don't break if( stack[i]->IsRoot() ) { stop = true; } else { // start region test bool inside = false; Rect window( stack[i]->GetRenderPosition(), stack[i]->GetRenderSize() ); if( !inside ) { FOR_EACH_VEC( drawList, j ) { if( drawList[j]->eTransitionType ) continue; // skip animating window Rect drawnWindow( drawList[j]->GetRenderPosition(), drawList[j]->GetRenderSize() ); if( drawnWindow.IsInside( window )) inside = true; } } // region test complete if( inside ) continue; } // add to draw list drawList.AddToTail( stack[i] ); } FOR_EACH_VEC( removeList, j ) { stack.Remove( removeList[j] ); } FOR_EACH_VEC_BACK( drawList, k ) { CMenuBaseWindow *window = drawList[k]; if( window->eTransitionType > CMenuBaseWindow::ANIM_CLOSING ) { if( window->DrawAnimation( ) ) window->DisableTransition(); } if( !window->eTransitionType ) drawList[k]->Draw(); if( k != drawList.Count() - 1 ) { window = drawList[k+1]; if( window->eTransitionType == CMenuBaseWindow::ANIM_CLOSING ) { if( window->DrawAnimation( ) ) window->DisableTransition(); } } } if( ui_show_window_stack && ui_show_window_stack->value ) { con_nprint_t con; con.index = 0; con.time_to_live = 0.01f; con.color[0] = con.color[1] = con.color[2] = 1.0f; Con_NXPrintf( &con, "Stack:\n" ); FOR_EACH_LL( stack, l ) { con.index++; if( active == l ) { con.color[0] = 0.0f; con.color[1] = 1.0f; con.color[2] = 0.0f; } else if( FBitSet( stack[l]->iFlags, QMF_CLOSING )) { // bloody :) con.color[0] = 1.0f; con.color[1] = 0.0f; con.color[2] = 0.0f; } else { con.color[0] = con.color[1] = con.color[2] = 1.0f; } char visible = '-'; if( drawList.Find( stack[l] ) != drawList.InvalidIndex() ) visible = '+'; if( stack[l]->IsRoot() ) { Con_NXPrintf( &con, "%c %p - %s\n", visible, stack[l], stack[l]->szName ); } else { Con_NXPrintf( &con, "%c %p - %s\n", visible, stack[l], stack[l]->szName ); } } } } void CWindowStack::Add( CMenuBaseWindow *menu ) { if( menu == Current() ) return; // do nothing if( stack.IsValidIndex( active )) { if( stack[active]->IsRoot() && menu->IsRoot() ) { stack[active]->EnableTransition( CMenuBaseWindow::ANIM_CLOSING ); } } // check if menu already in stack and set it active int i; if( ( i = stack.Find( menu )) != stack.InvalidIndex() ) { active = i; ClearBits( menu->iFlags, QMF_CLOSING ); return; } active = stack.AddToTail( menu ); ClearBits( menu->iFlags, QMF_CLOSING ); if( this == &uiStatic.menu ) // hack! { uiStatic.firstDraw = true; EngFuncs::KEY_SetDest( KEY_MENU ); } } void CWindowStack::Remove( CMenuBaseWindow *menu ) { int min; int idx = stack.Find( menu ); if( idx == stack.InvalidIndex() ) { Con_DPrintf( "CWindowStack::Remove: can't remove not opened window\n" ); } if( this == &uiStatic.menu ) // hack! min = 1; // main menu can't close last menu else min = 0; if( stack.Count() > min ) { SetBits( menu->iFlags, QMF_CLOSING ); FOR_EACH_LL_BACK( stack, i ) { if( !FBitSet( stack[i]->iFlags, QMF_CLOSING )) { active = i; // maybe isn't best solution if( stack[active]->IsRoot() && menu->IsRoot() ) stack[active]->EnableTransition( CMenuBaseWindow::ANIM_OPENING ); // notify new active window about changed mouse position stack[active]->MouseMove( uiStatic.cursorX, uiStatic.cursorY ); break; } } } else { if( CL_IsActive() ) { UI_CloseMenu(); } else { EngFuncs::KEY_SetDest( KEY_CONSOLE ); } } // hacks for demos and some environments where we can't play them on background if( this == &uiStatic.menu && uiStatic.m_fDemosPlayed && uiStatic.m_iOldMenuDepth == stack.Count() - 1 ) { EngFuncs::ClientCmd( false, "demos\n" ); uiStatic.m_fDemosPlayed = false; uiStatic.m_iOldMenuDepth = 0; } } void CWindowStack::InputMethodResized( void ) { if( Current() && Current()->ItemAtCursor() ) { Current()->ItemAtCursor()->_Event( QM_IMRESIZED ); } } void CWindowStack::KeyUpEvent( int key ) { if( Current() ) Current()->KeyUp( key ); } void CWindowStack::KeyDownEvent( int key ) { if( Current() ) Current()->KeyDown( key ); } void CWindowStack::CharEvent( int key ) { if( Current() ) Current()->Char( key ); } void CWindowStack::MouseEvent( int x, int y ) { if( Current() ) Current()->MouseMove( x, y ); } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |