From: Andy D. <kha...@us...> - 2003-07-29 23:00:36
|
Update of /cvsroot/planeshift/planeshift/src/client/paws In directory sc8-pr-cvs1:/tmp/cvs-serv32419/src/client/paws Modified Files: pawstexturemanager.h pawswidget.cpp pawswidget.h pspawsmanager.cpp pspawsmanager.h Log Message: Added fading effects to child widgets via a virtual MouseOver function (fading can be disabled by overriding MouseOver or setting fade to false) Added a GetAlpha function to images Index: pawstexturemanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/paws/pawstexturemanager.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pawstexturemanager.h 19 May 2003 00:54:05 -0000 1.3 --- pawstexturemanager.h 29 Jul 2003 23:00:32 -0000 1.4 *************** *** 192,195 **** --- 192,197 ---- void SetAlpha ( int alpha ) { alphaValue = alpha; } + int GetAlpha (void) {return alphaValue;} + /** Get the description that this image is using to draw. * @return a pointer to the psImageDescription or NULL if not found. Index: pawswidget.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/paws/pawswidget.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** pawswidget.cpp 28 Jul 2003 08:00:18 -0000 1.20 --- pawswidget.cpp 29 Jul 2003 23:00:32 -0000 1.21 *************** *** 56,59 **** --- 56,61 ---- name = "None"; attachFlags = 0; + fadeVal = 100; + fade = true; hasFocus = false; } *************** *** 268,274 **** bgImage->Description( imageDesc ); ! csRef<iDocumentAttribute> alpha = bgImageNode->GetAttribute("alpha"); ! if( alpha ) ! bgImage->SetAlpha( alpha->GetValueAsInt() ); } else --- 270,278 ---- bgImage->Description( imageDesc ); ! csRef<iDocumentAttribute> alphaattr = bgImageNode->GetAttribute("alpha"); ! if( alphaattr ) ! bgImage->SetAlpha( alphaattr->GetValueAsInt() ); ! // Get the initial alpha value ! alpha = bgImage->GetAlpha(); } else *************** *** 385,390 **** bgImage = new pawsImage( windowManager->GetObjectRegistry() ); ! bgImage->Description( imageDesc ); ! } --- 389,395 ---- bgImage = new pawsImage( windowManager->GetObjectRegistry() ); ! bgImage->Description( imageDesc ); ! // Get the initial alpha value ! alpha = bgImage->GetAlpha(); } *************** *** 394,397 **** --- 399,404 ---- { bgImage->SetAlpha( value ); + // Get the initial alpha value + alpha = value; } } *************** *** 444,447 **** --- 451,462 ---- if ( bgImage ) { + + bgImage->SetAlpha(abs(alpha * 0.01 * fadeVal)); + if (fadeVal != 0 && fadeVal < 100 && fadeVal > -100) + // Background's alpha slowly becomes 0 or original alpha + fadeVal--; + //else if (fadeVal>-100 && fadeVal < 0) + // // Background's alpha slowly becomes original alpha + // fadeVal--; bgImage->Draw( screenFrame ); } *************** *** 919,922 **** --- 934,973 ---- } + void pawsWidget::MouseOver(bool value) + { + if (!alpha || !fade) // If widget is never transparent, return + return; + if (value) + { + if (fadeVal < 0) + { + fadeVal++; + fadeVal = -fadeVal; + } + else + // Start from transparent widget + fadeVal = 99; + } + else + { + if (fadeVal > 0) + { + fadeVal--; + fadeVal = -fadeVal; + } + else + // Start from opaque widget + fadeVal = -1; + } + + // Fade children's images IF parent fades + for ( int x = children.Length()-1; x >= 0 ; x-- ) + { + if ( children[x]->IsVisible() ) + { + children[x]->MouseOver(value); + } + } + } //------------------------------------------------------------------------ Index: pawswidget.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/paws/pawswidget.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** pawswidget.h 29 Jul 2003 16:05:26 -0000 1.21 --- pawswidget.h 29 Jul 2003 23:00:32 -0000 1.22 *************** *** 280,285 **** } ! protected: --- 280,286 ---- } + virtual void MouseOver(bool value); ! void SetFade(bool value) { fade = value; } protected: *************** *** 334,337 **** --- 335,347 ---- bool hasFocus; + + /// The direction and percentage of current fade in progress. + int fadeVal; + + /// The original background alpha. + int alpha; + + /// Set to false to disable fading + bool fade; }; Index: pspawsmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/paws/pspawsmanager.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pspawsmanager.cpp 29 Jul 2003 16:07:44 -0000 1.23 --- pspawsmanager.cpp 29 Jul 2003 23:00:32 -0000 1.24 *************** *** 127,130 **** --- 127,131 ---- inModalMode = false; modalWidget = 0; + mouseoverWidget = 0; } *************** *** 275,279 **** return true; } ! return false; --- 276,300 ---- return true; } ! ! if (!inModalMode) ! { ! pawsWidget* widget = mainWidget->WidgetAt( event.Mouse.x, event.Mouse.y ); ! ! if ( widget ) ! { ! // Only fade in/out topmost parent ! for (pawsWidget* mainParent = widget->GetParent();mainParent && mainParent != mainWidget;mainParent=widget->GetParent()) ! widget = mainParent; ! ! if (widget != mouseoverWidget && widget->IsVisible()) ! { ! if (mouseoverWidget && mouseoverWidget != mainWidget) ! mouseoverWidget->MouseOver(false); // Fade out ! mouseoverWidget = widget; ! if (widget != mainWidget) ! mouseoverWidget->MouseOver(true); // Fade in ! } ! } ! } return false; Index: pspawsmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/paws/pspawsmanager.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pspawsmanager.h 9 Jul 2003 22:22:53 -0000 1.9 --- pspawsmanager.h 29 Jul 2003 23:00:32 -0000 1.10 *************** *** 130,133 **** --- 130,136 ---- pawsWidget* currentFocusedWidget; + /// The last widget that the mouse moved over. ( For alpha fade effects ). + pawsWidget* mouseoverWidget; + /// Current widget that is being moved. pawsWidget* movingWidget; |