Преглед на файлове

Removed GuiScriptNotifyCtrl

This removes the GuiScriptNotifyCtrl. It adds a few optional script callbacks that this ancient control tried to cover.
Peter Robinson преди 3 години
родител
ревизия
8574ca89af
променени са 4 файла, в които са добавени 50 реда и са изтрити 338 реда
  1. 49 8
      engine/source/gui/guiControl.cc
  2. 1 1
      engine/source/gui/guiControl.h
  3. 0 230
      engine/source/gui/guiScriptNotifyControl.cc
  4. 0 99
      engine/source/gui/guiScriptNotifyControl.h

+ 49 - 8
engine/source/gui/guiControl.cc

@@ -162,6 +162,19 @@ void GuiControl::onChildAdded( GuiControl *child )
 		//This will cause the child control to be centered if it needs to be.
 		RectI innerRect = this->getInnerRect(mBounds.point, mBounds.extent, GuiControlState::NormalState, mProfile);
 		child->parentResized(innerRect.extent, innerRect.extent);
+
+		if (isMethod("onChildAdded"))
+		{
+			Con::executef(this, 3, "onChildAdded", child->getIdString());
+		}
+	}
+}
+
+void GuiControl::onChildRemoved(GuiControl* child)
+{
+	if (mProfile && isMethod("onChildRemoved"))
+	{
+		Con::executef(this, 3, "onChildRemoved", child->getIdString());
 	}
 }
 
@@ -421,6 +434,11 @@ void GuiControl::resize(const Point2I &newPosition, const Point2I &newExtent)
       if (parent)
          parent->childResized(this);
       setUpdate();
+
+	  if (isMethod("onResize"))
+	  {
+		  Con::executef(this, 2, "onResize");
+	  }
    }
    else {
       mBounds.point = newPosition;
@@ -464,6 +482,11 @@ void GuiControl::setHeight( S32 newHeight )
 void GuiControl::childResized(GuiControl *child)
 {
    // Default to do nothing. Do not call resize from here as it will create an infinite loop.
+
+	if (isMethod("onChildResized"))
+	{
+		Con::executef(this, 3, "onChildResized", child->getIdString());
+	}
 }
 
 void GuiControl::parentResized(const Point2I &oldParentExtent, const Point2I &newParentExtent)
@@ -1660,6 +1683,15 @@ void GuiControl::onLoseFirstResponder()
 {
     // Since many controls have visual cues when they are the firstResponder...
     setUpdate();
+
+	if (isMethod("onLoseFirstResponder"))
+	{
+		Con::executef(this, 2, "onLoseFirstResponder");
+	}
+	else if (isMethod("onBlur"))
+	{
+		Con::executef(this, 2, "onBlur");
+	}
 }
 
 bool GuiControl::ControlIsChild(GuiControl *child)
@@ -1708,14 +1740,23 @@ void GuiControl::setFirstResponder()
 {
     if ( mAwake && mVisible )
     {
-       GuiControl *parent = getParent();
-       if (mProfile->mCanKeyFocus == true && parent != NULL )
-      {
-         parent->setFirstResponder(this);
-
-         // Since many controls have visual cues when they are the firstResponder...
-         this->setUpdate();	
-      }
+		GuiControl *parent = getParent();
+		if (mProfile->mCanKeyFocus == true && parent != NULL )
+		{
+			parent->setFirstResponder(this);
+
+			// Since many controls have visual cues when they are the firstResponder...
+			this->setUpdate();	
+
+			if (isMethod("onGainFirstResponder"))
+			{
+				Con::executef(this, 2, "onGainFirstResponder");
+			}
+			else if (isMethod("onFocus"))
+			{
+				Con::executef(this, 2, "onFocus");
+			}
+		}
     }
 }
 

+ 1 - 1
engine/source/gui/guiControl.h

@@ -506,7 +506,7 @@ public:
     virtual void onChildAdded( GuiControl *child );
 
 	/// Called when a child is removed.
-	virtual inline void onChildRemoved(GuiControl* child) {};
+	virtual void onChildRemoved(GuiControl* child);
 
     /// @}
 

+ 0 - 230
engine/source/gui/guiScriptNotifyControl.cc

@@ -1,230 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2013 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#include "gui/guiScriptNotifyControl.h"
-#include "console/consoleTypes.h"
-//------------------------------------------------------------------------------
-
-IMPLEMENT_CONOBJECT(GuiScriptNotifyCtrl);
-
-GuiScriptNotifyCtrl::GuiScriptNotifyCtrl()
-{
-   mOnChildAdded = false;
-   mOnChildRemoved = false;
-   mOnResize = false;
-   mOnChildResized = false;
-   mOnParentResized = false;
-}
-
-GuiScriptNotifyCtrl::~GuiScriptNotifyCtrl()
-{
-}
-
-void GuiScriptNotifyCtrl::initPersistFields()
-{
-   // Callbacks Group
-   addGroup("Callbacks");
-   addField("onChildAdded", TypeBool, Offset( mOnChildAdded, GuiScriptNotifyCtrl ) );
-   addField("onChildRemoved", TypeBool, Offset( mOnChildRemoved, GuiScriptNotifyCtrl ) );
-   addField("onChildResized", TypeBool, Offset( mOnChildResized, GuiScriptNotifyCtrl ) );
-   addField("onParentResized", TypeBool, Offset( mOnParentResized, GuiScriptNotifyCtrl ) );
-   addField("onResize", TypeBool, Offset( mOnResize, GuiScriptNotifyCtrl ) );
-   addField("onLoseFirstResponder", TypeBool, Offset( mOnLoseFirstResponder, GuiScriptNotifyCtrl ) );
-   addField("onGainFirstResponder", TypeBool, Offset( mOnGainFirstResponder, GuiScriptNotifyCtrl ) );
-   endGroup("Callbacks");
-
-   Parent::initPersistFields();
-}
-
-// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //
-void GuiScriptNotifyCtrl::onChildAdded( GuiControl *child )
-{
-   Parent::onChildAdded( child );
-
-   // Call Script.
-   if( mOnChildAdded && isMethod( "onChildAdded" ) )
-      Con::executef(this, 3, "onChildAdded", child->getIdString() );
-}
-
-void GuiScriptNotifyCtrl::onChildRemoved( GuiControl *child )
-{
-   Parent::onChildRemoved( child );
-
-   // Call Script.
-   if( mOnChildRemoved && isMethod( "onChildRemoved" ) )
-      Con::executef(this, 3, "onChildRemoved", child->getIdString() ); 
-}
-//----------------------------------------------------------------
-
-void GuiScriptNotifyCtrl::resize(const Point2I &newPosition, const Point2I &newExtent)
-{
-   Parent::resize( newPosition, newExtent );
-
-   // Call Script.
-   if( mOnResize && isMethod( "onResize" ) )
-      Con::executef(this, 2, "onResize" );
-
-}
-
-void GuiScriptNotifyCtrl::childResized(GuiScriptNotifyCtrl *child)
-{
-   Parent::childResized( child );
-
-   // Call Script.
-   if( mOnChildResized && isMethod( "onChildResized" ) )
-      Con::executef(this, 3, "onChildResized", child->getIdString() );
-}
-
-void GuiScriptNotifyCtrl::parentResized(const Point2I &oldParentExtent, const Point2I &newParentExtent)
-{
-   Parent::parentResized( oldParentExtent, newParentExtent );
-
-   // Call Script.
-   if( mOnParentResized && isMethod( "onParentResized" ) )
-      Con::executef(this, 2, "onParentResized" );
-
-}
- 
-void GuiScriptNotifyCtrl::onLoseFirstResponder()
-{
-   Parent::onLoseFirstResponder();
-
-   // Call Script.
-   if( mOnLoseFirstResponder && isMethod( "onLoseFirstResponder" ) )
-      Con::executef(this, 2, "onLoseFirstResponder" );
-
-}
-
-void GuiScriptNotifyCtrl::setFirstResponder( GuiControl* firstResponder )
-{
-   Parent::setFirstResponder( firstResponder );
-
-   // Call Script.
-   if( mOnGainFirstResponder && isFirstResponder() && isMethod( "onGainFirstResponder" ) )
-      Con::executef(this, 2, "onGainFirstResponder" );
-
-}
-
-void GuiScriptNotifyCtrl::setFirstResponder()
-{
-   Parent::setFirstResponder();
-
-   // Call Script.
-   if( mOnGainFirstResponder && isFirstResponder() && isMethod( "onGainFirstResponder" ) )
-      Con::executef(this, 2, "onGainFirstResponder" );
-}
-
-void GuiScriptNotifyCtrl::onMessage(GuiScriptNotifyCtrl *sender, S32 msg)
-{
-   Parent::onMessage( sender, msg );
-}
-
-void GuiScriptNotifyCtrl::onDialogPush()
-{
-   Parent::onDialogPush();
-}
-
-void GuiScriptNotifyCtrl::onDialogPop()
-{
-   Parent::onDialogPop();
-}
-
-
-//void GuiScriptNotifyCtrl::onMouseUp(const GuiEvent &event)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMouseDown(const GuiEvent &event)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMouseMove(const GuiEvent &event)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMouseDragged(const GuiEvent &event)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMouseEnter(const GuiEvent &)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMouseLeave(const GuiEvent &)
-//{
-//}
-//
-//bool GuiScriptNotifyCtrl::onMouseWheelUp( const GuiEvent &event )
-//{
-//}
-//
-//bool GuiScriptNotifyCtrl::onMouseWheelDown( const GuiEvent &event )
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onRightMouseDown(const GuiEvent &)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onRightMouseUp(const GuiEvent &)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onRightMouseDragged(const GuiEvent &)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMiddleMouseDown(const GuiEvent &)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMiddleMouseUp(const GuiEvent &)
-//{
-//}
-//
-//void GuiScriptNotifyCtrl::onMiddleMouseDragged(const GuiEvent &)
-//{
-//}
-//void GuiScriptNotifyCtrl::onMouseDownEditor(const GuiEvent &event, Point2I offset)
-//{
-//}
-//void GuiScriptNotifyCtrl::onRightMouseDownEditor(const GuiEvent &event, Point2I offset)
-//{
-//}
-
-//bool GuiScriptNotifyCtrl::onKeyDown(const GuiEvent &event)
-//{
-//  if ( Parent::onKeyDown( event ) )
-//     return true;
-//}
-//
-//bool GuiScriptNotifyCtrl::onKeyRepeat(const GuiEvent &event)
-//{
-//   // default to just another key down.
-//   return onKeyDown(event);
-//}
-//
-//bool GuiScriptNotifyCtrl::onKeyUp(const GuiEvent &event)
-//{
-//  if ( Parent::onKeyUp( event ) )
-//     return true;
-//}

+ 0 - 99
engine/source/gui/guiScriptNotifyControl.h

@@ -1,99 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2013 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#ifndef _GUISCRIPTNOTIFYCTRL_H_
-#define _GUISCRIPTNOTIFYCTRL_H_
-
-#ifndef _GUICONTROL_H_
-#include "gui/guiControl.h"
-#endif
-
-class GuiScriptNotifyCtrl : public GuiControl
-{
-private:
-   typedef GuiControl Parent;
-public:
-
-    /// @name Event Callbacks
-    /// @{ 
-   bool mOnChildAdded;         ///< Script Notify : onAddObject(%object)  
-   bool mOnChildRemoved;       ///< Script Notify : onRemoveObject(%object)
-   bool mOnResize;             ///< Script Notify : onResize()
-   bool mOnChildResized;       ///< Script Notify : onChildResized(%child)
-   bool mOnParentResized;      ///< Script Notify : onParentResized()
-   bool mOnLoseFirstResponder; ///< Script Notify : onLoseFirstResponder()
-   bool mOnGainFirstResponder; ///< Script Notify : onGainFirstResponder()
-    /// @}
-
-public:
-    /// @name Initialization
-    /// @{
-    DECLARE_CONOBJECT(GuiScriptNotifyCtrl);
-    GuiScriptNotifyCtrl();
-    virtual ~GuiScriptNotifyCtrl();
-    static void initPersistFields();
-
-    virtual void resize(const Point2I &newPosition, const Point2I &newExtent);
-    virtual void childResized(GuiScriptNotifyCtrl *child);
-    virtual void parentResized(const Point2I &oldParentExtent, const Point2I &newParentExtent);
-    virtual void onChildRemoved( GuiControl *child );
-    virtual void onChildAdded( GuiControl *child );
-    //virtual void onMouseUp(const GuiEvent &event);
-    //virtual void onMouseDown(const GuiEvent &event);
-    //virtual void onMouseMove(const GuiEvent &event);
-    //virtual void onMouseDragged(const GuiEvent &event);
-    //virtual void onMouseEnter(const GuiEvent &event);
-    //virtual void onMouseLeave(const GuiEvent &event);
-
-    //virtual bool onMouseWheelUp(const GuiEvent &event);
-    //virtual bool onMouseWheelDown(const GuiEvent &event);
-
-    //virtual void onRightMouseDown(const GuiEvent &event);
-    //virtual void onRightMouseUp(const GuiEvent &event);
-    //virtual void onRightMouseDragged(const GuiEvent &event);
-
-    //virtual void onMiddleMouseDown(const GuiEvent &event);
-    //virtual void onMiddleMouseUp(const GuiEvent &event);
-    //virtual void onMiddleMouseDragged(const GuiEvent &event);
-
-    //virtual void onMouseDownEditor(const GuiEvent &event, Point2I offset);
-    //virtual void onRightMouseDownEditor(const GuiEvent &event, Point2I offset);
-
-    virtual void setFirstResponder(GuiControl *firstResponder);
-    virtual void setFirstResponder();
-    void clearFirstResponder();
-    virtual void onLoseFirstResponder();
-
-    //virtual void acceleratorKeyPress(U32 index);
-    //virtual void acceleratorKeyRelease(U32 index);
-    //virtual bool onKeyDown(const GuiEvent &event);
-    //virtual bool onKeyUp(const GuiEvent &event);
-    //virtual bool onKeyRepeat(const GuiEvent &event);
-
-    virtual void onMessage(GuiScriptNotifyCtrl *sender, S32 msg);    ///< Receive a message from another control
-
-    virtual void onDialogPush();
-    virtual void onDialogPop();
-
-};
-
-#endif