Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 00665 00666 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 00685 00686 00687 00688 00689 00690 00691 00692 00693 00694 00695 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 00706 00707 00708 00709 00710 00711 00712 00713 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 00748 00749 00750 00751 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 00768 00769 00770 00771 00772 00773 00774 00775 00776 00777 00778 00779 00780 00781 00782 00783 00784 00785 00786 00787 00788 00789 00790 00791 00792 00793 00794 00795 00796 00797 00798 00799 00800 00801 00802 00803 00804 00805 00806 00807 00808 00809 00810 00811 00812 00813 00814 00815 00816 00817 00818 00819 00820 00821 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 00849 00850 00851 00852 00853 00854 00855 00856 00857 00858 00859 00860 00861 00862 00863 00864 00865 00866 00867 00868 00869 00870 00871 00872 00873 00874 00875 00876 00877 00878 00879 00880 00881 00882 00883 00884 00885 00886 00887 00888 00889 00890 00891 00892 00893 00894 00895 00896 00897 00898 00899 00900 00901 00902 00903 00904 00905 00906 00907 00908 00909 00910 00911 00912 00913 00914 00915 00916 00917 00918 00919 00920 00921 00922 00923 00924 00925 00926 00927 00928 00929 00930 00931 00932 00933 00934 00935 00936 00937 00938 00939 00940 00941 00942 00943 00944 00945 00946 00947 00948 00949 00950 00951 00952 00953 00954 00955 00956 00957 00958 00959 00960 00961 00962 00963 00964 00965 00966 00967 00968 00969 00970 00971 00972 00973 00974 00975 00976 00977 00978 00979 00980 00981 00982 00983 00984 00985 00986 00987 00988 00989 00990 00991 00992 00993 00994 00995 00996 00997 00998 00999 01000 01001 01002 01003 01004 01005 01006 01007 01008 01009 01010 01011 01012 01013 01014 01015 01016 01017 01018 01019 01020 01021 01022 01023 01024 01025 01026 01027 01028 01029 01030 01031 01032 01033 01034 01035 01036 01037 01038 01039 01040 01041 01042 01043 01044 01045 01046 01047 01048 01049 01050 01051 01052 01053 01054 01055 01056 01057 01058 01059 01060 01061 01062 01063 01064 01065 01066 01067 01068 01069 01070 01071 01072 01073 01074 01075 01076 01077 01078 01079 01080 01081 01082 01083 01084 01085 01086 01087 01088 01089 01090 01091 01092 01093 01094 01095 01096 01097 01098 01099 01100 01101 01102 01103 01104 01105 01106 01107 01108 01109 01110 01111 01112 01113 01114 01115 01116 01117 01118 01119 01120 01121 01122 01123 01124 01125 01126 01127 01128 01129 01130 01131 01132 01133 01134 01135 01136 01137 01138 01139 01140 01141 01142 01143 01144 01145 01146 01147 01148 01149 01150 01151 01152 01153 01154 01155 01156 01157 01158 01159 01160 01161 01162 01163 01164 01165 01166 01167 01168 01169 01170 01171 01172 01173 01174 01175 01176 01177 01178 01179 01180 01181 01182 01183 01184 01185 01186 01187 01188 01189 01190 01191 01192 01193 01194 01195 01196 01197 01198 01199 01200 01201 01202 01203 01204 01205 01206 01207 01208 01209 01210 01211 01212 01213 01214 01215 01216 01217 01218 01219 01220 01221 01222 01223 01224 01225 01226 01227 01228 01229 01230 01231 01232 01233 01234 01235 01236 01237 01238 01239 01240 01241 01242 01243 01244 01245 01246 01247 01248 01249 01250 01251 01252 01253 01254 01255 01256 01257 01258 |
#linenumber 1 /** * This widget manages a collection of panels. Only one panel can be active at a time. Each panel is associated with a tab, * which is displayed in a row across one edge of the tab control. Users select the tab corresponding to the panel they wish * to interact with by clicking with the mouse or using the keyboard/gamepad to activate neighboring panels. * * A UITabControl is composed of two main areas - the "tab region" and the "client region". The tab region is where the * tabs are rendered, while the client region is where the currently active panel is rendered. * * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved */ class UITabControl extends UIObject native(UIPrivate) config(UI) placeable; #linenumber 18 /* - implement TAST_Manual - implement tabs docking on the left and right */ // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) /** * Different ways to adjust the sizes of tab buttons used in this control. */ enum EUITabAutosizeType { /** No autosizing; the size for each tab button will be set manually. */ TAST_Manual, /** all tab buttons will be the same width, and will be expanded to fill the entire width of this control */ TAST_Fill, /** Standard autosizing; all tab buttons will be resized to fit their captions */ TAST_Auto, /** All tabs will have the width of the widest tab, which is auto-sized according to its caption */ // TAST_Justified, }; /*================================================ Components ================================================*/ /** * the list of tab pages managed by this UITabControl */ var() protected{protected} editinline editfixedsize editconst array<UITabPage> Pages; /** * Reference to the currently active page */ var() editconst editinline transient UITabPage ActivePage; /** * Reference to the page which is about to become active. */ var() editconst editinline transient UITabPage PendingPage; /*================================================ Configuration ================================================*/ /** * Controls which face of this UITabControl the tab buttons will be docked to * @todo ronp - currently only top and bottom are properly supported. In order to support left & right, we'll probably * need to rotate the buttons, but first need to figure out what the docking relationship should be in that case. */ var(Presentation) EUIWidgetFace TabDockFace; /** The mode to use for sizing the tab buttons */ var(Presentation) EUITabAutosizeType TabSizeMode; /** * The size to use for the tab buttons along the orientation of the TabDockFace (i.e. if tabs are docked at top or bottom, * this determines the height of the tabs) */ var(Presentation) UIScreenValue_Extent TabButtonSize; /** * The amount of padding to apply to each button's text. The specified value will be evenly distributed to each sides of * the button's caption. */ var(Presentation) UIScreenValue_Extent TabButtonPadding[EUIOrientation.UIORIENT_MAX]; /** The style to use for the tab button background image */ var private UIStyleReference TabButtonBackgroundStyle; /** The style to use for the tab button labels */ var private UIStyleReference TabButtonCaptionStyle; /** Controls whether tab buttons are allowed to enter the targeted state */ var(Presentation) config bool bAllowPagePreviews; /*================================================ Sounds ================================================*/ /** this sound is played when a new tab is activated */ var(Sound) name ActivateTabCue; /*================================================ Runtime ================================================*/ /** set to indicate that the tab control should layout the buttons and panels during the next tick */ var transient bool bUpdateLayout; //@todo ronp - implement this //var UIDataStoreBinding InitiallyActiveTab; /* == Delegates == */ /** * Called when a new page is activated. * * @param Sender the tab control that activated the page * @param NewlyActivePage the page that was just activated * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this event. */ delegate OnPageActivated( UITabControl Sender, UITabPage NewlyActivePage, int PlayerIndex ); /** * Called when a new page is added to this tab control. * * @param Sender the tab control that added the page * @param NewPage the page that was just added * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this event. */ delegate OnPageInserted( UITabControl Sender, UITabPage NewPage, int PlayerIndex ); /** * Called when a page is removed from this tab control. * * @param Sender the tab control that removed the page * @param OldPage the page that was removed * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this event. */ delegate OnPageRemoved( UITabControl Sender, UITabPage OldPage, int PlayerIndex ); /* == Natives == */ /** * Enables the bUpdateLayout flag and triggers a scene update to occur during the next frame. */ native final function RequestLayoutUpdate(); /** * Returns the number of pages in this tab control. */ native final function int GetPageCount() const; /** * Returns a reference to the page at the specified index. */ native final function UITabPage GetPageAtIndex( int PageIndex ) const; /** * Returns a reference to the tab button which is currently in the Targeted state, or NULL if no buttons are in that state. */ native final function UITabButton FindTargetedTab( int PlayerIndex ) const; /** * Creates a new UITabPage of the specified class as well as its associated tab button. * * @param TabPageClass the class to use for creating the tab page. * @param PagePrefab if specified, the prefab to use for creating this tab page. * * @return a pointer to a new instance of the specified UITabPage class */ native function UITabPage CreateTabPage( class<UITabPage> TabPageClass, optional UITabPage PagePrefab ); /* == Events == */ /** * Worker method for setting a new active page. Handles deactivating the previously active page and firing the appropriate notifications. * * @param PageToActivate the tab page that should be become the active page * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player to activate this tab for. * * @return TRUE if the specified page was successfully activated. */ protected event PrivateActivatePage( UITabPage PageToActivate, int PlayerIndex ) { // de-activate the currently active page if ( ActivePage != None && PageToActivate != ActivePage ) { ActivePage.ActivatePage(PlayerIndex, false); } // clear the pending page ref PendingPage = None; // assign the active page ref ActivePage = PageToActivate; // fire the page changed delegate -- CAUTION! ActivePage might be none! OnPageActivated(Self, ActivePage, PlayerIndex); } /** * Inserts a page at the specified location. * * @param PageToInsert the tab page to insert * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this action. * @param InsertIndex location to insert the page in the Pages array. If not specified, page is inserted at the end. * @param bActivateImmediately * if TRUE, immediately activates the page and gives it focus * * @return TRUE if the page was successfully added to this tab control */ event bool InsertPage( UITabPage PageToInsert, int PlayerIndex, int InsertIndex=INDEX_NONE, optional bool bActivateImmediately=true ) { local bool bResult; local UITabButton NewTab; local int ChildInsertIndex, EventIdx; local array<UIEvent> InsertedPageEvents; // `log(">>>" @ `location @ `showobj(PageToInsert) @ `showvar(bActivateImmediately),,'DevUI' ); if ( PageToInsert != None && Pages.Find(PageToInsert) == INDEX_NONE ) { // if this is the first page being inserted, we always activate it bActivateImmediately = bActivateImmediately || (Pages.Length == 1 && IsVisible()); // call the CreateButton() method on the page to get a UITabButton NewTab = PageToInsert.GetTabButton(Self); if ( NewTab != None ) { // verify that we have a valid insertion index if ( InsertIndex < 0 || InsertIndex >= Pages.Length ) { InsertIndex = Pages.Length; } // for now, let's try having the tab button in our Children array, and having the page as a child of the tab if ( InsertIndex > 0 ) { Assert(Pages[InsertIndex-1]!=None); // hmmm, this might happen if this page was a custom class and that class was removed Assert(Pages[InsertIndex-1].GetTabButton()!=None); // hmmm, this might happen if this page was a custom class and that class was removed // find the location of the previous page's button in the Children array; we'll insert this new page's // button into the Children array just after that one ChildInsertIndex = Children.Find(Pages[InsertIndex - 1].GetTabButton()); Assert(ChildInsertIndex!=INDEX_NONE); // the previous page's button should be in the Children array. ChildInsertIndex++; } else { ChildInsertIndex = InsertIndex; } // make sure that the page is linked to the tab PageToInsert.LinkToTabButton(NewTab, Self); // add the tab to our Children array if ( InsertChild(NewTab, ChildInsertIndex, false) != INDEX_NONE ) { // add the page to the list Pages.Insert(InsertIndex, 1); Pages[InsertIndex] = PageToInsert; // set the TabIndex for the button to the same value as its index in the Pages array so that // our FocusPropagation references are set correctly (i.e. the first tab button is our FirstFocusedControl, etc.) NewTab.TabIndex = ChildInsertIndex; // allow the page to perform additional initialization PageToInsert.AddedToTabControl(Self); // fire the notification that we've added a new page OnPageInserted(Self, PageToInsert, PlayerIndex); // and the kismet notification PageToInsert.ActivateEventByClass( PlayerIndex, class'Engine.UIEvent_TabPageInserted', PageToInsert,false,,InsertedPageEvents ); for ( EventIdx = 0; EventIdx < InsertedPageEvents.Length; EventIdx++ ) { UIEvent_TabPageInserted(InsertedPageEvents[EventIdx]).InsertedIndex = InsertIndex; } // if we want to activate the page as well, do that now. if ( !bActivateImmediately || !ActivatePage(PageToInsert, PlayerIndex, true) ) { // otherwise, hide it PageToInsert.SetVisibility(false); } RequestLayoutUpdate(); bResult = true; } } } // `log("<<<" @ `location @ `showobj(PageToInsert) @ `showvar(bActivateImmediately) @ `showvar(bResult),,'DevUI'); return bResult; } /** * Removes the specified page from this tab control's list of pages. * * @param PageToRemove the tab page to remove * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this action. * * @return TRUE if the page was successfully removed from the pages array. */ event bool RemovePage( UITabPage PageToRemove, int PlayerIndex ) { local bool bResult; local int PageIndex; local UITabButton TabButton; // `log(">>>" @ `location @ `showobj(PageToRemove),,'DevUI' ); if ( PageToRemove != None ) { // locate the page that should be removed PageIndex = FindPageIndexByPageRef(PageToRemove); if ( PageIndex >= 0 && PageIndex < Pages.Length ) { Pages.Remove(PageIndex,1); TabButton = PageToRemove.GetTabButton(); // remove the tab page's button from our children array; this will clear the button's OnClicked delegate. if (TabButton != None) { //Make sure the tabbutton isn't focused TabButton.KillFocus(None, PlayerIndex); RemoveChild(TabButton); } // fire the notication that we've removed a page OnPageRemoved(Self, PageToRemove, PlayerIndex); // and the kismet notification PageToRemove.ActivateEventByClass( PlayerIndex, class'Engine.UIEvent_TabPageRemoved' ); // notify both panel and button that they are being removed? // if this was the active tab, attempt to activate the next tab in the list if ( PageToRemove == ActivePage ) { ActivePage = None; ActivateBestTab( PlayerIndex, true, PageIndex ); } // anything else? RequestLayoutUpdate(); bResult = true; } } // `log("<<<" @ `location @ `showobj(PageToRemove) @ `showvar(bResult),,'DevUI'); return bResult; } /** * Replaces one tab page with another one. * * @param ExistingPage the tab page to replace; must be a page that is currently in this tab control's Pages array. * @param NewPage the tab page that will replace the existing one. * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this action. * @param bFocusPage if TRUE, immediately activates the page and gives it focus * * @return TRUE if the page was successfully replaced. */ event bool ReplacePage( UITabPage ExistingPage, UITabPage NewPage, int PlayerIndex, optional bool bFocusPage=true ) { local bool bResult; local int PageIndex; // `log(">>>" @ `location @ `showobj(ExistingPage) @ `showobj(NewPage) @ `showvar(bFocusPage),,'DevUI' ); if ( ExistingPage != None && NewPage != None ) { PageIndex = FindPageIndexByPageRef(ExistingPage); if ( PageIndex != INDEX_NONE ) { //@todo ronp - might be able to optimize this // insert new page at the location of the old page if ( InsertPage(NewPage, PlayerIndex, PageIndex, bFocusPage) ) { // remove old page if ( RemovePage(ExistingPage, PlayerIndex) ) { bResult = true; RequestLayoutUpdate(); } else { // if we couldn't remove the old page, abort the whole thing which means we need // to undo the insertion of the new page RemovePage(NewPage, PlayerIndex); } } } } // `log("<<<" @ `location @ `showobj(ExistingPage) @ `showobj(NewPage) @ `showvar(bResult),,'DevUI'); return bResult; } /** * Attempts to activate the specified tab page. * * @param PageToActivate the tab page that should be become the active page * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player to activate this tab for. * @param bFocusPage specify FALSE if the tab control itself should maintain focus. * * @return TRUE if the specified page was successfully activated. */ event bool ActivatePage( UITabPage PageToActivate, int PlayerIndex, optional bool bFocusPage=true ) { local bool bResult; // `log(">>>" @ `location @ `showobj(PageToActivate) @ `showvar(bFocusPage) @ "(" $ `showobj(ActivePage) $ ")",,'DevUI' ); // verify that the tab can become active (button might call into its panel to see if something would prevent the panel from becoming active) // and that we don't have a PendingPage (which indicates that another page is currently in the process of becoming the active page) if ( PageToActivate != None && PendingPage == None && PageToActivate.CanActivatePage(PlayerIndex) ) { // PageToActivate.bForceFlash = false; if ( PageToActivate != ActivePage ) { // set pending tab PendingPage = PageToActivate; if ( PendingPage.ActivatePage(PlayerIndex, true, bFocusPage) ) { // call the activatepage worker (PrivateActivatePage), which actually switches the active page ref. //@todo ronp - here is where we would insert the code to perform any type of transition animations // see the UT2004 source.... PrivateActivatePage(PageToActivate, PlayerIndex); // play tab switched sound PlayUISound(ActivateTabCue); bResult = true; } else { PendingPage = None; } } else { bResult = ActivePage.ActivatePage(PlayerIndex, true, bFocusPage); } } // `log("<<<" @ `location @ `showobj(PageToActivate) @ `showvar(bResult) @ "(" $ `showobj(ActivePage) $ ")",,'DevUI'); return bResult; } /** * Activates the page immediately after the currently active page. If the currently active page is the last one, * activates the first page. * * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this event. * @param bFocusPage specify FALSE if the tab control itself should maintain focus. * @param bAllowWrapping specify false to prevent the first page from being activated if the currently active page * is the last page in the stack. * * @return TRUE if the next page was successfully activated. */ event bool ActivateNextPage( int PlayerIndex, optional bool bFocusPage=true, optional bool bAllowWrapping=true ) { local bool bResult; local int PageIndex, NumPages; local UITabPage NextPage; // `log(">>>" @ `location,,'DevUI'); NumPages = GetPageCount(); if ( NumPages > 1 ) { PageIndex = FindPageIndexByPageRef(ActivePage); if ( PageIndex >= 0 && PageIndex < NumPages - 1 ) { // if the index of currently active page is valid, increment the index so that we activate the next one PageIndex++; } else if ( ActivePage == None || bAllowWrapping ) { // otherwise, reset back to zero so that we activate the first one PageIndex = 0; } else { PageIndex = NumPages; } NextPage = GetPageAtIndex(PageIndex); bResult = ActivatePage(NextPage, PlayerIndex, bFocusPage); } // `log("<<<" @ `location @ `showvar(bResult),,'DevUI'); return bResult; } /** * Activates the page immediately before the currently active page. If the currently active page is the first one, * activates the last page. * * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this event. * @param bFocusPage specify FALSE if the tab control itself should maintain focus. * @param bAllowWrapping specify false to prevent the first page from being activated if the currently active page * is the last page in the stack. * * @return TRUE if the previous page was successfully activated. */ event bool ActivatePreviousPage( int PlayerIndex, optional bool bFocusPage=true, optional bool bAllowWrapping=true ) { local bool bResult; local int PageIndex, NumPages; local UITabPage PreviousPage; // `log(">>>" @ `location,,'DevUI'); NumPages = GetPageCount(); if ( NumPages > 1 ) { PageIndex = FindPageIndexByPageRef(ActivePage); if ( PageIndex > 0 && PageIndex < NumPages ) { // if the index of currently active page is valid, decrement the index so that we activate the previous one PageIndex--; } else if ( ActivePage == None || bAllowWrapping ) { // otherwise, reset back to the last index so that we activate the last one PageIndex = NumPages - 1; } else { PageIndex = INDEX_NONE; } PreviousPage = GetPageAtIndex(PageIndex); bResult = ActivatePage(PreviousPage, PlayerIndex, bFocusPage); } // `log("<<<" @ `location @ `showvar(bResult),,'DevUI'); return bResult; } /** * Enables/disables a tab page and its associated tab button. * * @param PageToEnable the page to enable/disable. * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that generated this event. * @param bEnablePage controls whether the page should be enabled or disabled. * @param bActivatePage if true, the page will also be activated (only relevant if bEnablePage is true). * @param bFocusPage specify FALSE if the new page should not become the focused control (only relevant if bActivatePage is true) * * @return TRUE if the page was successfully enabled/disabled. */ event bool EnableTabPage( UITabPage PageToEnable, int PlayerIndex, bool bEnablePage=true, optional bool bActivatePage, optional bool bFocusPage=true ) { local bool bResult; local int PageIndex; if ( PageToEnable != None ) { // we want to enable the page if ( bEnablePage ) { // if the page is already enabled, just perform the activation if ( PageToEnable.IsEnabled(PlayerIndex) ) { // page is already enabled - indicate success bResult = true; // make sure the button is also enabled. PageToEnable.GetTabButton().EnableWidget(PlayerIndex); } else { // enable the page's button if ( PageToEnable.GetTabButton().EnableWidget(PlayerIndex) ) { // enable the page bResult = PageToEnable.EnableWidget(PlayerIndex); } } if ( bResult && bActivatePage ) { ActivatePage(PageToEnable, PlayerIndex, bFocusPage); } } else { // disable its button first PageToEnable.GetTabButton().DisableWidget(PlayerIndex); // we want to disable the page - this is a bit trickier if ( !PageToEnable.IsEnabled(PlayerIndex) ) { bResult = true; } else { PageIndex = FindPageIndexByPageRef(PageToEnable); //@fixme ronp - no check for valid PageIndex // next, before we disable the page itself, we need to make sure if ( PageToEnable == ActivePage ) //@todo ronp - what about PendingPage? { ActivePage = None; PendingPage = None; ActivateBestTab(PlayerIndex, PageToEnable.IsFocused(PlayerIndex), PageIndex); //@fixme ronp - no check for ActivateBestTab failure. } bResult = PageToEnable.DisableWidget(PlayerIndex); } } } return bResult; } /* === UIScreenObject interface === */ /** * Called after this screen object's children have been initialized */ event PostInitialize() { Super.PostInitialize(); // because the FocusPropagation arrays haven't been setup by this point, this won't actually set focus // but it will put the tab button for the initially active page in a state which allows it to recieve focus as soon // as the FocusPropagation arrays are initialized. ActivateBestTab(GetBestPlayerIndex()); } /** * Called immediately after a child has been added to this screen object. * * This version hooks up the OnClicked delegate for the newly added button. * * @param WidgetOwner the screen object that the NewChild was added as a child for * @param NewChild the widget that was added */ event AddedChild( UIScreenObject WidgetOwner, UIObject NewChild ) { local UITabButton TabButton; Super.AddedChild(WidgetOwner, NewChild); if ( WidgetOwner == Self ) { TabButton = UITabButton(NewChild); if ( TabButton != None ) { TabButton.OnClicked = TabButtonClicked; } } } /* == Unrealscript == */ /** * Attempts to activate the specified tab page. * * @param PageToActivate the tab page that should be become the active page * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player to activate this tab for. * @param bFocusPage specify FALSE if the tab control itself should maintain focus. * * @return TRUE if the specified page was successfully activated. */ function bool ActivatePageByCaption( string PageCaption, int PlayerIndex, optional bool bFocusPage=true ) { local int PageIndex; local bool bResult; PageIndex = FindPageIndexByCaption(PageCaption); if ( PageIndex != INDEX_NONE ) { bResult = ActivatePage(Pages[PageIndex], PlayerIndex, bFocusPage); } return bResult; } /** * Chooses the best tab to activate and activates it. * * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player to activate this tab for. * @param bFocusPage specify FALSE if the tab control itself should maintain focus. * @param StartIndex if specified, starts the iteration at this index when searching for a new tab to activate. * * @return TRUE if a tab was successfully activated. */ function bool ActivateBestTab( int PlayerIndex, optional bool bFocusPage=true, optional int StartIndex=0 ) { local int PageIndex; local bool bResult; if ( Pages.Length > 0 ) { // make sure we have a valid starting index so that the loop can eventually stop if ( StartIndex < 0 || StartIndex >= Pages.Length ) { StartIndex = 0; } PageIndex = StartIndex; do { // attempt to activate the next page in the list if ( ActivatePage(Pages[PageIndex], PlayerIndex, bFocusPage) ) { bResult = true; break; } // couldn't activate that one, so try to next one if ( ++PageIndex >= Pages.Length ) { PageIndex = 0; } } until ( PageIndex == StartIndex ); } return bResult; } /** * Returns the index [into the Pages array] for the page which has a button with the specified caption. * * @param PageCaption the caption to use for searching for the page * @param bMarkupString if TRUE, searches for the button that has PageCaption as its data store binding. * * @return INDEX_NONE if no page was found with the specified caption. */ function int FindPageIndexByCaption( string PageCaption, optional bool bMarkupString ) { local int PageIndex; local UITabButton btn; PageIndex = INDEX_NONE; if ( Len(PageCaption) > 0 ) { for ( PageIndex = Pages.Length - 1; PageIndex >= 0; PageIndex-- ) { if ( Pages[PageIndex] != None ) { btn = Pages[PageIndex].GetTabButton(); if ( btn != None ) { if ( bMarkupString ) { if ( btn.GetDataStoreBinding() ~= PageCaption ) { break; } } else { if ( btn.GetCaption() ~= PageCaption ) { break; } } } } } } return PageIndex; } /** * Returns the index [into the Pages array] for the page which has the specified button. * * @return INDEX_NONE if no page was found with the specified button. */ function int FindPageIndexByButton( UITabButton SearchButton ) { local int PageIndex; PageIndex = INDEX_NONE; if ( SearchButton != None ) { for ( PageIndex = Pages.Length - 1; PageIndex >= 0; PageIndex-- ) { if ( Pages[PageIndex] != None && Pages[PageIndex].GetTabButton() == SearchButton ) { break; } } } return PageIndex; } /** * Returns the index [into the Pages array] for the specified page. * * @return INDEX_NONE if the specified was None or isn't in the Pages array. */ function int FindPageIndexByPageRef( UITabPage SearchPage ) { local int PageIndex; PageIndex = INDEX_NONE; if ( SearchPage != None ) { for ( PageIndex = Pages.Length - 1; PageIndex >= 0; PageIndex-- ) { if ( Pages[PageIndex] == SearchPage ) { break; } } } return PageIndex; } /** * Provides a hook for unrealscript to respond to input using actual input key names (i.e. Left, Tab, etc.) * * Called when an input key event is received which this widget responds to and is in the correct state to process. The * keys and states widgets receive input for is managed through the UI editor's key binding dialog (F8). * * This delegate is called BEFORE kismet is given a chance to process the input. * * Allows the user to use the left/right arrow keys to preview other panels if this widget is the globally focused control * * @param EventParms information about the input event. * * @return TRUE to indicate that this input key was processed; no further processing will occur on this input key event. */ function bool ProcessInputKey( const out InputEventParameters EventParms ) { local bool bResult; local name PrevKey, NextKey; // tab page preview mode is only active when the tab control is focused but doesn't have a focused control of its own if ( IsVisible() && bAllowPagePreviews && (EventParms.EventType == IE_Pressed || EventParms.EventType == IE_Repeat) && IsFocused(EventParms.PlayerIndex) && GetFocusedControl(false, EventParms.PlayerIndex) == None ) { switch ( TabDockFace ) { case UIFACE_Top: case UIFACE_Bottom: PrevKey = 'Left'; NextKey = 'Right'; break; case UIFACE_Left: case UIFACE_Right: PrevKey = 'Up'; NextKey = 'Down'; break; } if ( EventParms.InputKeyName == PrevKey ) { // Send false for bFocusPanel to ActivatePreviousPage so that we remain the focused control and the user // can continue using left/right to preview other pages. ActivatePreviousPage(EventParms.PlayerIndex, false, true); bResult = true; } else if ( EventParms.InputKeyName == NextKey ) { // Send false for bFocusPanel to ActivateNextPage so that we remain the focused control and the user // can continue using left/right to preview other pages. ActivateNextPage(EventParms.PlayerIndex, false, true); bResult = true; } } return bResult; } /** * Called when the user clicks on a tab button and releases the mouse. Begins activating the associated tab page. * * @param EventObject Object that issued the event. * @param PlayerIndex Player that performed the action that issued the event. * * @return return TRUE to prevent the kismet OnClick event from firing. */ function bool TabButtonClicked(UIScreenObject EventObject, int PlayerIndex) { local UITabButton ClickedButton; local UITabPage PageToActivate; local bool bResult; ClickedButton = UITabButton(EventObject); if ( ClickedButton != None ) { PageToActivate = ClickedButton.GetTabPage(); if ( PageToActivate != None && Pages.Find(PageToActivate) != INDEX_NONE ) { // activate the page ActivatePage(PageToActivate, PlayerIndex, true); // if the page was in our list, don't allow kismet to process it even if ActivatePage returned false. bResult = true; } // if this page wasn't in our list, allow kismet to process it } return bResult; } defaultproperties { TabDockFace=UIFACE_Top TabSizeMode=TAST_Auto TabButtonSize=(Value=0.020000,ScaleType=UIEXTENTEVAL_PercentOwner,Orientation=UIORIENT_Vertical) TabButtonPadding(0)=(Value=0.020000,ScaleType=UIEXTENTEVAL_PercentOwner) TabButtonPadding(1)=(Value=0.020000,ScaleType=UIEXTENTEVAL_PercentOwner,Orientation=UIORIENT_Vertical) TabButtonBackgroundStyle=(DefaultStyleTag="TabButtonBackgroundStyle",RequiredStyleClass=Class'Engine.UIStyle_Image') TabButtonCaptionStyle=(DefaultStyleTag="DefaultTabButtonStringStyle",RequiredStyleClass=Class'Engine.UIStyle_Combo') bAllowPagePreviews=True bSupportsPrimaryStyle=False DefaultStates(2)=Class'Engine.UIState_Focused' DefaultStates(3)=Class'Engine.UIState_Pressed' DefaultStates(4)=Class'Engine.UIState_Active' Begin Object Class=UIComp_Event Name=WidgetEventComponent ObjName=WidgetEventComponent Archetype=UIComp_Event'Engine.Default__UIObject:WidgetEventComponent' ObjectArchetype=UIComp_Event'Engine.Default__UIObject:WidgetEventComponent' End Object EventProvider=WidgetEventComponent __OnRawInputKey__Delegate=Default__UITabControl.ProcessInputKey Name="Default__UITabControl" ObjectArchetype=UIObject'Engine.Default__UIObject' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |