add initial examples, replacing the 'Demos/Demos3'. Will make it work cross-platform, OpenGL3/OpenGL2 and add more examples to it.

This commit is contained in:
erwincoumans
2015-04-16 09:55:32 -07:00
parent d9feaf2d2a
commit a1bf9c5556
425 changed files with 255913 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
/*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#include "Gwen/ToolTip.h"
#include "Gwen/Utility.h"
using namespace Gwen;
using namespace Gwen::Controls;
namespace ToolTip
{
Base* g_ToolTip = NULL;
void Enable( Controls::Base* pControl )
{
if ( !pControl->GetToolTip() )
return;
g_ToolTip = pControl;
}
void Disable( Controls::Base* pControl )
{
if ( g_ToolTip == pControl )
{
g_ToolTip = NULL;
}
}
void RenderToolTip( Skin::Base* skin )
{
if ( !g_ToolTip ) return;
Gwen::Renderer::Base* render = skin->GetRender();
Gwen::Point pOldRenderOffset = render->GetRenderOffset();
Gwen::Point MousePos = Input::GetMousePosition();
Gwen::Rect Bounds = g_ToolTip->GetToolTip()->GetBounds();
Gwen::Rect rOffset = Gwen::Rect( MousePos.x - Bounds.w * 0.5f, MousePos.y - Bounds.h - 10, Bounds.w, Bounds.h );
rOffset = Utility::ClampRectToRect( rOffset, g_ToolTip->GetCanvas()->GetBounds() );
//Calculate offset on screen bounds
render->AddRenderOffset( rOffset );
render->EndClip();
skin->DrawToolTip( g_ToolTip->GetToolTip() );
g_ToolTip->GetToolTip()->DoRender( skin );
render->SetRenderOffset( pOldRenderOffset );
}
void ControlDeleted( Controls::Base* pControl )
{
Disable( pControl );
}
}