⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guitoolwindowctrl.cc

📁 五行MMORPG引擎系统V1.0
💻 CC
📖 第 1 页 / 共 3 页
字号:
   //dglDrawRect(myRect, ColorI(0, 0, 0)); // Taken out, this is controled via mProfile->mBorder
}


void GuiToolWindowCtrl::onPreRender()
{
	//自动展开
	if(!m_bAlwaysShow && m_nExpandExpire > 0 && (ms_pAutoExpandTool == NULL || ms_pAutoExpandTool == this))
	{
	   Point2I localPoint = getParent()->globalToLocalCoord(Canvas->getCursorPos());

		if(mMinimized)
		{
			if(m_nExpandTimer == 0)
			{
				if(pointInControl(localPoint))
				{
					m_nExpandTimer = Platform::getRealMilliseconds();
				}
			}
			else if(m_nExpandTimer > 0)
			{
				if(pointInControl(localPoint))
				{
					if(Platform::getRealMilliseconds() - (U32)m_nExpandTimer >= (U32)m_nExpandExpire)
					{
						ms_pAutoExpandTool = this;
						selectWindow();

						ToggleMiniMode(false);
						m_nExpandTimer = 0;
					}
				}
				else
				{
					m_nExpandTimer = Platform::getRealMilliseconds();
				}
			}
		}
		else
		{
			//鼠标已经进行autoExpand了
			if(m_nExpandTimer == 0)
			{
				if(!pointInControl(localPoint))
				{
					m_nExpandTimer = Platform::getRealMilliseconds();
				}
			}
			//鼠标已离开,等收缩窗口,保证在窗口外边,否则置一直获取计时,保证为存活状态
			else if(m_nExpandTimer > 0)
			{
				//if(!mBounds.pointInRect(localPoint))//Canvas->getCursorPos()) )
				if(!pointInControl(localPoint))
				{
					if(Platform::getRealMilliseconds() - (U32)m_nExpandTimer >= (U32)m_nExpandExpire)
					{
						ms_pAutoExpandTool = NULL;
						m_nExpandTimer = 0;
						ToggleMiniMode(true);
					}
				}
				else
				{
					m_nExpandTimer = Platform::getRealMilliseconds();
				}
			}
		}
	}

}



void GuiToolWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
{
   //draw the outline
   RectI winRect;

	
   winRect.point = offset;
   winRect.extent = mBounds.extent;
   GuiCanvas *root = getRoot();

   //GuiControl *firstResponder = root ? root->getFirstResponder() : NULL;

	/// TGE_Theme
	//mTextureHandle = mProfile->mTextureHandle;


	////////////////////////////////////////////////////
	//这里需要绘画纹理较复杂的边框,需要进行边框tile

   //bool	isKey		= (!firstResponder || ControlIsChild(firstResponder));

   bool	isKey;
	S32	nNum		= mProfile->constructBitmapArray();  
   U32	topBase;

   RectI destRect(0,0,0,0);
	RectI stretchRect(0,0,0,0);
   GuiControl *parent = getParent();
	
	isKey = (parent && parent->last() == this);




	if(!m_bVerticalBar)
	{
	   topBase	= isKey ? BorderTopLeftKey : BorderTopLeftNoKey;

		//在非mini状态下,绘画客户区
		if(!mMinimized)
		{
			///////////////////////////////////////////////////////////
			//填充背景
			winRect.point.x += mBitmapBounds[BorderLeft].extent.x;
			winRect.point.y += mBitmapBounds[topBase + 2].extent.y;

			winRect.extent.x -= mBitmapBounds[BorderLeft].extent.x + mBitmapBounds[BorderRight].extent.x;
			winRect.extent.y -= mBitmapBounds[topBase + 2].extent.y + mBitmapBounds[BorderBottom].extent.y;


			//设有填充背景,则Tile背景图案
			if(nNum >= NumBitmaps)
			{
				dglClearBitmapModulation();

				stretchRect = mBitmapBounds[BmpFill];
				stretchRect.inset(1,1);
				//dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);
				dglDrawBitmapTile(mTextureHandle, winRect, stretchRect);
			}
			else
			{
				dglDrawRectFill(winRect, mProfile->mFillColor);
				dglClearBitmapModulation();
			}


			/////////////////////
			//左边框 Tile
			destRect.point.x = offset.x;
			destRect.point.y = offset.y + mBitmapBounds[topBase].extent.y;
			destRect.extent.x = mBitmapBounds[BorderLeft].extent.x;
			destRect.extent.y = mBounds.extent.y - mBitmapBounds[topBase].extent.y - mBitmapBounds[BorderBottomLeft].extent.y;
			stretchRect = mBitmapBounds[BorderLeft];
			stretchRect.inset(0,1);
			dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);

			////////////////////////
			//右边框
			destRect.point.x = offset.x + mBounds.extent.x - mBitmapBounds[BorderRight].extent.x;
			destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
			destRect.point.y = offset.y + mBitmapBounds[topBase + 1].extent.y;
			destRect.extent.y = mBounds.extent.y - mBitmapBounds[topBase + 1].extent.y - mBitmapBounds[BorderBottomRight].extent.y;

			stretchRect = mBitmapBounds[BorderRight];
			stretchRect.inset(0,1);
			dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);

			////////////////////////////////
			//左下 直画
			dglDrawBitmapSR(mTextureHandle, 
				offset + Point2I(0, mBounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y), 
				mBitmapBounds[BorderBottomLeft]);
			//右下 右对齐直画
			dglDrawBitmapSR(mTextureHandle, 
				offset + mBounds.extent - mBitmapBounds[BorderBottomRight].extent,
				mBitmapBounds[BorderBottomRight]);

			////////////////////////////////
			//底边框 Tile
			destRect.point.x = offset.x + mBitmapBounds[BorderBottomLeft].extent.x;
			destRect.extent.x = mBounds.extent.x - mBitmapBounds[BorderBottomLeft].extent.x - mBitmapBounds[BorderBottomRight].extent.x;

			destRect.point.y = offset.y + mBounds.extent.y - mBitmapBounds[BorderBottom].extent.y;
			destRect.extent.y = mBitmapBounds[BorderBottom].extent.y;
			stretchRect = mBitmapBounds[BorderBottom];
			stretchRect.inset(1,0);

			dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);

		}// if(!mMinimized)
		else
			dglClearBitmapModulation();


		//////////////////////////////////////////////////////
		//任何情况下,都绘画标题栏
		///////////////////////////////////
		//左上 直画
		dglDrawBitmapSR(mTextureHandle, offset, mBitmapBounds[topBase]);
		//右上 直画
		dglDrawBitmapSR(mTextureHandle, Point2I(offset.x + mBounds.extent.x - mBitmapBounds[topBase+1].extent.x, offset.y),
			mBitmapBounds[topBase + 1]);

		////////////////////
		//上标题框 Tile
		destRect.point.x = offset.x + mBitmapBounds[topBase].extent.x;
		destRect.point.y = offset.y;
		destRect.extent.x = mBounds.extent.x - mBitmapBounds[topBase].extent.x - mBitmapBounds[topBase + 1].extent.x;
		destRect.extent.y = mBitmapBounds[topBase + 2].extent.y;
		stretchRect = mBitmapBounds[topBase + 2];
		stretchRect.inset(1,0);
		dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);

	}
	else
	{
	   topBase	= isKey ? VBorderBottomLeftKey : VBorderBottomLeftNoKey;


		//在非mini状态下,绘画客户区
		if(!mMinimized)
		{
			///////////////////////////////////////////////////////////
			//填充背景
			winRect.point.x += mBitmapBounds[topBase + 2].extent.x;
			winRect.point.y += mBitmapBounds[VBorderTop].extent.y;

			winRect.extent.x -= mBitmapBounds[topBase + 2].extent.x + mBitmapBounds[VBorderRight].extent.x;
			winRect.extent.y -= mBitmapBounds[VBorderTop].extent.y + mBitmapBounds[VBorderBottom].extent.y;


			//设有填充背景,则Tile背景图案
			if(nNum >= NumBitmaps)
			{
				dglClearBitmapModulation();

				stretchRect = mBitmapBounds[BmpFill];
				stretchRect.inset(1,1);
				//dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);
				dglDrawBitmapTile(mTextureHandle, winRect, stretchRect);
			}
			else
			{
				dglDrawRectFill(winRect, mProfile->mFillColor);
				dglClearBitmapModulation();
			}


			/////////////////////
			//下底边框 Tile
			stretchRect = mBitmapBounds[VBorderBottom];
			stretchRect.inset(1,0);
			destRect.point.x	= offset.x + mBitmapBounds[topBase].extent.x;
			destRect.extent.x = mBounds.extent.x - mBitmapBounds[topBase].extent.x - mBitmapBounds[VBorderBottomRight].extent.x;

			destRect.point.y	= offset.y + mBounds.extent.y - mBitmapBounds[VBorderBottom].extent.y;
			destRect.extent.y = mBitmapBounds[VBorderBottom].extent.y;

			dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);

			////////////////////////
			//上端边框
			destRect.point.x	= offset.x + mBitmapBounds[topBase+1].extent.x;
			destRect.point.y	= offset.y;
			destRect.extent.x = mBounds.extent.x - mBitmapBounds[topBase+1].extent.x - mBitmapBounds[VBorderTopRight].extent.x;
			destRect.extent.y = mBitmapBounds[VBorderTop].extent.y;
			stretchRect			= mBitmapBounds[VBorderTop];
			stretchRect.inset(1,0);
			dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);

			////////////////////////////////
			//右下 直画
			dglDrawBitmapSR(mTextureHandle, 
				offset + mBounds.extent - mBitmapBounds[VBorderBottomRight].extent,
				mBitmapBounds[VBorderBottomRight]);

			////////////////////////////////
			//右上 右对齐直画
			dglDrawBitmapSR(mTextureHandle, 
				Point2I(offset.x + mBounds.extent.x - mBitmapBounds[VBorderTopRight].extent.x, offset.y),
				mBitmapBounds[VBorderTopRight]);

			////////////////////////////////
			//右边框 Tile
			destRect.point.x	= offset.x + mBounds.extent.x - mBitmapBounds[VBorderRight].extent.x;
			destRect.point.y	= offset.y + mBitmapBounds[VBorderTopRight].extent.y;
			destRect.extent.x = mBitmapBounds[VBorderRight].extent.x;
			destRect.extent.y = mBounds.extent.y - mBitmapBounds[VBorderTopRight].extent.y - mBitmapBounds[VBorderBottomRight].extent.y;

			stretchRect = mBitmapBounds[VBorderRight];
			stretchRect.inset(0,1);
			dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);
		}//if(!mMinimized)
		else
			dglClearBitmapModulation();

		//////////////////////////////////////////////////////
		//任何情况下,都绘画标题栏

		///////////////////////////////////
		//左下 直画
		dglDrawBitmapSR(mTextureHandle, 
			offset + Point2I(0, mBounds.extent.y - mBitmapBounds[topBase].extent.y), 
			mBitmapBounds[topBase]);
		//左上 直画
		dglDrawBitmapSR(mTextureHandle, offset, mBitmapBounds[topBase+1]);

		////////////////////
		//左标题框 Tile
		destRect.point.x	= offset.x;
		destRect.point.y	= offset.y + mBitmapBounds[topBase+1].extent.y;
		destRect.extent.x = mBitmapBounds[topBase+2].extent.x;
		destRect.extent.y = mBounds.extent.y - mBitmapBounds[topBase+1].extent.y - mBitmapBounds[topBase].extent.y;
		stretchRect = mBitmapBounds[topBase+2];
		stretchRect.inset(0,1);
		dglDrawBitmapTile(mTextureHandle, destRect, stretchRect);

	}






   //draw the title
   // dhc addition: copied/modded from renderJustifiedText, since we enforce a
   // different color usage here. NOTE: it currently CAN overdraw the controls
   // if mis-positioned or 'scrunched' in a small width.

	if(mText[0])
	{
		S32 fontHeight = mFont->getHeight();
		S32 textWidth = mProfile->mFont->getStrWidth((const UTF8 *)mText);
		Point2I start(0,0);

		dglSetBitmapModulation(mProfile->mFontColor);

		// align the horizontal
		if ( mProfile->mAlignment == GuiControlProfile::RightJustify )
			start.set( winRect.extent.x - textWidth, 0 );
		else if ( mProfile->mAlignment == GuiControlProfile::CenterJustify )
			start.set( ( winRect.extent.x - textWidth) / 2, 0 );
		else // GuiControlProfile::LeftJustify or garbage... ;)
			start.set( 0, 0 );
		// If the text is longer then the box size, (it'll get clipped) so force Left Justify
		if( textWidth > winRect.extent.x )
			start.set( 0, 0 );

		dglDrawText(mFont, start + offset + mProfile->mTextOffset, mText);
	}



   // deal with rendering the titlebar controls
   AssertFatal(root, "Unable to get the root Canvas.");
   Point2I localPoint = globalToLocalCoord(root->getCursorPos());

   //draw the close button
   Point2I tempUL;
   Point2I tempLR;
   S32 bmp = BmpStates * BmpClose;


   if( mCanClose ) 
	{
      if( mCloseButton.pointInRect( localPoint ))
		{
			if(mPressClose)
				bmp += BmpDepress;
			else
				bmp += BmpHilite;
		}

      dglClearBitmapModulation();
      dglDrawBitmapSR(mTextureHandle, offset + mCloseButton.point, mBitmapBounds[bmp]);
   }


   if( !mMinimized )
   {
      renderChildControls( offset, updateRect );
   }
}


ConsoleMethod( GuiToolWindowCtrl, toggleVisible, bool, 2, 2, "")
{
	return object->toggleVisible();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -