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,750 @@
#pragma once
#ifndef GWEN_SKINS_SIMPLE_H
#define GWEN_SKINS_SIMPLE_H
#include "Gwen/Skin.h"
#include "Gwen/Gwen.h"
#include "Gwen/Controls/Base.h"
namespace Gwen
{
namespace Skin
{
class Simple : public Gwen::Skin::Base
{
public:
Gwen::Color m_colBorderColor;
Gwen::Color m_colControlOutlineLight;
Gwen::Color m_colControlOutlineLighter;
Gwen::Color m_colBG;
Gwen::Color m_colBGDark;
Gwen::Color m_colControl;
Gwen::Color m_colControlBorderHighlight;
Gwen::Color m_colControlDarker;
Gwen::Color m_colControlOutlineNormal;
Gwen::Color m_colControlBright;
Gwen::Color m_colControlDark;
Gwen::Color m_colHighlightBG;
Gwen::Color m_colHighlightBorder;
Gwen::Color m_colToolTipBackground;
Gwen::Color m_colToolTipBorder;
Gwen::Color m_colModal;
Simple()
{
m_colBorderColor = Gwen::Color( 80, 80, 80, 255 );
m_colBG = Gwen::Color( 248, 248, 248, 255 );
m_colBGDark = Gwen::Color( 235, 235, 235, 255 );
m_colControl = Gwen::Color( 240, 240, 240, 255 );
m_colControlBright = Gwen::Color( 255, 255, 255, 255 );
m_colControlDark = Gwen::Color( 214, 214, 214, 255 );
m_colControlDarker = Gwen::Color( 180, 180, 180, 255 );
m_colControlOutlineNormal = Gwen::Color( 112, 112, 112, 255 );
m_colControlOutlineLight = Gwen::Color( 144, 144, 144, 255 );
m_colControlOutlineLighter = Gwen::Color( 210, 210, 210, 255 );
m_colHighlightBG = Gwen::Color( 192, 221, 252, 255 );
m_colHighlightBorder = Gwen::Color( 51, 153, 255, 255 );
m_colToolTipBackground = Gwen::Color( 255, 255, 225, 255 );
m_colToolTipBorder = Gwen::Color( 0, 0, 0, 255 );
m_colModal = Gwen::Color( 25, 25, 25, 150 );
m_DefaultFont.facename = L"Microsoft Sans Serif";
m_DefaultFont.size = 11;
}
virtual void DrawButton( Gwen::Controls::Base* control, bool bDepressed, bool bHovered )
{
int w = control->Width();
int h = control->Height();
DrawButton( w, h, bDepressed, bHovered );
}
virtual void DrawMenuItem( Gwen::Controls::Base* control, bool bSubmenuOpen, bool bChecked )
{
if ( bSubmenuOpen || control->IsHovered() )
{
m_Render->SetDrawColor( m_colHighlightBG );
m_Render->DrawFilledRect( control->GetRenderBounds() );
m_Render->SetDrawColor( m_colHighlightBorder );
m_Render->DrawLinedRect( control->GetRenderBounds() );
}
// Gwen::Rect rect = control->GetRenderBounds();
if ( bChecked )
{
m_Render->SetDrawColor( Color( 0, 0, 0, 255) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
DrawCheck( r );
}
}
virtual void DrawMenuStrip( Gwen::Controls::Base* control )
{
int w = control->Width();
int h = control->Height();
m_Render->SetDrawColor( Gwen::Color( 246, 248, 252, 255 ) );
m_Render->DrawFilledRect( Gwen::Rect( 0, 0, w, h ) );
m_Render->SetDrawColor( Gwen::Color( 218, 224, 241, 150 ) );
m_Render->DrawFilledRect( Gwen::Rect( 0, h*0.4f, w, h*0.6f ) );
m_Render->DrawFilledRect( Gwen::Rect( 0, h*0.5f, w, h*0.5f ) );
}
virtual void DrawMenu( Gwen::Controls::Base* control, bool bPaddingDisabled )
{
int w = control->Width();
int h = control->Height();
m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawFilledRect( Gwen::Rect( 0, 0, w, h ) );
if ( !bPaddingDisabled )
{
m_Render->SetDrawColor( m_colControl );
m_Render->DrawFilledRect( Gwen::Rect( 1, 0, 22, h ) );
}
m_Render->SetDrawColor( m_colControlOutlineNormal );
m_Render->DrawLinedRect( Gwen::Rect( 0, 0, w, h ) );
}
virtual void DrawShadow( Gwen::Controls::Base* control )
{
int w = control->Width();
int h = control->Height();
int x = 4;
int y = 6;
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 10 ) );
m_Render->DrawFilledRect( Gwen::Rect( x, y, w, h ) );
x+=2;
m_Render->DrawFilledRect( Gwen::Rect( x, y, w, h ) );
y+=2;
m_Render->DrawFilledRect( Gwen::Rect( x, y, w, h ) );
}
virtual void DrawButton( int w, int h, bool bDepressed, bool bHovered, bool bSquared = false )
{
if ( bDepressed ) m_Render->SetDrawColor( m_colControlDark );
else if ( bHovered )m_Render->SetDrawColor( m_colControlBright );
else m_Render->SetDrawColor( m_colControl );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, w-2, h-2 ) );
if ( bDepressed ) m_Render->SetDrawColor( m_colControlDark );
else if ( bHovered )m_Render->SetDrawColor( m_colControl );
else m_Render->SetDrawColor( m_colControlDark );
m_Render->DrawFilledRect( Gwen::Rect( 1, h*0.5, w-2, h*0.5-2 ) );
if ( !bDepressed )
{
m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawShavedCornerRect( Gwen::Rect( 1, 1, w-2, h-2 ), bSquared );
}
else
{
m_Render->SetDrawColor( m_colControlDarker );
m_Render->DrawShavedCornerRect( Gwen::Rect( 1, 1, w-2, h-2 ), bSquared );
}
// Border
m_Render->SetDrawColor( m_colControlOutlineNormal );
m_Render->DrawShavedCornerRect( Gwen::Rect( 0, 0, w, h ), bSquared );
}
virtual void DrawRadioButton( Gwen::Controls::Base* control, bool bSelected, bool bDepressed)
{
Gwen::Rect rect = control->GetRenderBounds();
// Inside colour
if ( control->IsHovered() ) m_Render->SetDrawColor( Gwen::Color( 220, 242, 254, 255 ) );
else m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
// Border
if ( control->IsHovered() ) m_Render->SetDrawColor( Gwen::Color( 85, 130, 164, 255 ) );
else m_Render->SetDrawColor( m_colControlOutlineLight );
m_Render->DrawShavedCornerRect( rect );
m_Render->SetDrawColor( Gwen::Color( 0, 50, 60, 15 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w-4, rect.h-4 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w*0.3f, rect.h-4 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w-4, rect.h*0.3f ) );
if ( control->IsHovered() ) m_Render->SetDrawColor( Gwen::Color( 121, 198, 249, 255 ) );
else m_Render->SetDrawColor( Gwen::Color( 0, 50, 60, 50 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+3, 1, rect.h-5 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+3, rect.y+2, rect.w-5, 1 ) );
if ( bSelected )
{
m_Render->SetDrawColor( Gwen::Color( 40, 230, 30, 255 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w -4, rect.h-4 ) );
}
}
virtual void DrawCheckBox( Gwen::Controls::Base* control, bool bSelected, bool bDepressed)
{
Gwen::Rect rect = control->GetRenderBounds();
// Inside colour
if ( control->IsHovered() ) m_Render->SetDrawColor( Gwen::Color( 220, 242, 254, 255 ) );
else m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawFilledRect( rect );
// Border
if ( control->IsHovered() ) m_Render->SetDrawColor( Gwen::Color( 85, 130, 164, 255 ) );
else m_Render->SetDrawColor( m_colControlOutlineLight );
m_Render->DrawLinedRect( rect );
m_Render->SetDrawColor( Gwen::Color( 0, 50, 60, 15 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w-4, rect.h-4 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w*0.3f, rect.h-4 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w-4, rect.h*0.3f ) );
if ( control->IsHovered() ) m_Render->SetDrawColor( Gwen::Color( 121, 198, 249, 255 ) );
else m_Render->SetDrawColor( Gwen::Color( 0, 50, 60, 50 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, 1, rect.h-4 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+2, rect.y+2, rect.w-4, 1 ) );
if ( bDepressed )
{
m_Render->SetDrawColor( Color( 100, 100, 100, 255) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
DrawCheck( r );
}
else if ( bSelected )
{
m_Render->SetDrawColor( Color( 0, 0, 0, 255) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
DrawCheck( r );
}
}
virtual void DrawGroupBox( Gwen::Controls::Base* control, int textStart, int textHeight, int textWidth )
{
Gwen::Rect rect = control->GetRenderBounds();
rect.y += textHeight * 0.5f;
rect.h -= textHeight * 0.5f;
Gwen::Color m_colDarker = Gwen::Color( 0, 50, 60, 50 );
Gwen::Color m_colLighter = Gwen::Color( 255, 255, 255, 150 );
m_Render->SetDrawColor( m_colLighter );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+1, textStart-3, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1+textStart+textWidth, rect.y+1, rect.w-textStart+textWidth-2, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, (rect.y + rect.h)-1, rect.w-2, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+1, 1, rect.h ) );
m_Render->DrawFilledRect( Gwen::Rect( (rect.x + rect.w)-2, rect.y+1, 1, rect.h-1 ) );
m_Render->SetDrawColor( m_colDarker );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y, textStart-3, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1+textStart+textWidth, rect.y, rect.w-textStart-textWidth-2, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, (rect.y + rect.h) -1, rect.w-2, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x, rect.y+1, 1, rect.h-1 ) );
m_Render->DrawFilledRect( Gwen::Rect( (rect.x + rect.w)-1, rect.y+1, 1, rect.h-1 ) );
}
virtual void DrawTextBox( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
bool bHasFocus = control->HasFocus();
// Box inside
m_Render->SetDrawColor( Gwen::Color( 255, 255, 255, 255 ) );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
m_Render->SetDrawColor( m_colControlOutlineLight );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y, rect.w-2, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x, rect.y+1, 1, rect.h-2 ) );
m_Render->SetDrawColor( m_colControlOutlineLighter );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, (rect.y + rect.h)-1, rect.w-2, 1 ) );
m_Render->DrawFilledRect( Gwen::Rect( (rect.x + rect.w)-1, rect.y+1, 1, rect.h-2 ) );
if ( bHasFocus )
{
m_Render->SetDrawColor( Gwen::Color( 50, 200, 255, 150 ) );
m_Render->DrawLinedRect( rect );
}
}
virtual void DrawTabButton( Gwen::Controls::Base* control, bool bActive )
{
Gwen::Rect rect = control->GetRenderBounds();
bool bHovered = control->IsHovered();
if ( bActive )
{
m_Render->SetDrawColor( m_colControl );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+1, rect.w-2, rect.h-1 ) );
}
else
{
if ( bHovered )m_Render->SetDrawColor( m_colControlBright );
else m_Render->SetDrawColor( m_colControl );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-1 ) );
if ( bHovered )m_Render->SetDrawColor( m_colControl );
else m_Render->SetDrawColor( m_colControlDark );
m_Render->DrawFilledRect( Gwen::Rect( 1, rect.h*0.5, rect.w-2, rect.h*0.5-1 ) );
m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawShavedCornerRect( Gwen::Rect( 1, 1, rect.w-2, rect.h ) );
}
m_Render->SetDrawColor( m_colBorderColor );
m_Render->DrawShavedCornerRect( Gwen::Rect( 0, 0, rect.w, rect.h ) );
}
virtual void DrawTabControl( Gwen::Controls::Base* control, Gwen::Rect CurrentButtonRect )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( m_colControl );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colBorderColor );
m_Render->DrawLinedRect( rect );
m_Render->SetDrawColor( m_colControl );
m_Render->DrawFilledRect( CurrentButtonRect );
}
virtual void DrawWindow( Gwen::Controls::Base* control, int topHeight, bool inFocus )
{
Gwen::Rect rect = control->GetRenderBounds();
// Titlebar
if ( inFocus )
m_Render->SetDrawColor( Gwen::Color( 87, 164, 232, 230 ) );
else
m_Render->SetDrawColor( Gwen::Color( 87*0.70, 164*0.70, 232*0.70, 230 ) );
int iBorderSize = 5;
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+1, rect.w-2, topHeight-1 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+topHeight-1, iBorderSize, rect.h-2-topHeight ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+rect.w-iBorderSize, rect.y+topHeight-1, iBorderSize, rect.h-2-topHeight ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+rect.h-iBorderSize, rect.w-2, iBorderSize ) );
// Main inner
m_Render->SetDrawColor( Gwen::Color( m_colControlDark.r, m_colControlDark.g, m_colControlDark.b, 230 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x+iBorderSize+1, rect.y+topHeight, rect.w-iBorderSize*2-2, rect.h-topHeight-iBorderSize-1 ) );
// Light inner border
m_Render->SetDrawColor( Gwen::Color( 255, 255, 255, 100 ) );
m_Render->DrawShavedCornerRect( Gwen::Rect( rect.x+1, rect.y+1, rect.w-2, rect.h-2 ) );
// Dark line between titlebar and main
m_Render->SetDrawColor( m_colBorderColor );
// Inside border
m_Render->SetDrawColor( m_colControlOutlineNormal );
m_Render->DrawLinedRect( Gwen::Rect( rect.x+iBorderSize, rect.y+topHeight-1, rect.w - 10, rect.h - topHeight - (iBorderSize - 1) ) );
// Dark outer border
m_Render->SetDrawColor( m_colBorderColor );
m_Render->DrawShavedCornerRect( Gwen::Rect( rect.x, rect.y, rect.w, rect.h ) );
}
virtual void DrawHighlight( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( Gwen::Color( 255, 100, 255, 255 ) );
m_Render->DrawFilledRect( rect );
}
virtual void DrawScrollBar( Gwen::Controls::Base* control, bool isHorizontal, bool bDepressed )
{
Gwen::Rect rect = control->GetRenderBounds();
if (bDepressed)
m_Render->SetDrawColor( m_colControlDarker );
else
m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawFilledRect( rect );
}
virtual void DrawScrollBarBar( Controls::Base* control, bool bDepressed, bool isHovered, bool isHorizontal )
{
//TODO: something specialized
DrawButton( control, bDepressed, isHovered );
}
virtual void DrawTabTitleBar( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( Gwen::Color( 177, 193, 214, 255 ) );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colBorderColor );
rect.h += 1;
m_Render->DrawLinedRect( rect );
}
virtual void DrawProgressBar( Gwen::Controls::Base* control, bool isHorizontal, float progress)
{
Gwen::Rect rect = control->GetRenderBounds();
Gwen::Color FillColour( 0, 211, 40, 255 );
if ( isHorizontal )
{
//Background
m_Render->SetDrawColor( m_colControlDark );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
//Right half
m_Render->SetDrawColor( FillColour );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w*progress-2, rect.h-2 ) );
m_Render->SetDrawColor( Gwen::Color( 255, 255, 255, 150 ) );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h*0.45f ) );
}
else
{
//Background
m_Render->SetDrawColor( m_colControlDark );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
//Top half
m_Render->SetDrawColor( FillColour );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1 + (rect.h * (1 - progress)), rect.w-2, rect.h * progress - 2 ) );
m_Render->SetDrawColor( Gwen::Color( 255, 255, 255, 150 ) );
m_Render->DrawFilledRect( Gwen::Rect( 1, 1, rect.w*0.45f, rect.h-2 ) );
}
m_Render->SetDrawColor( Gwen::Color( 255, 255, 255, 150 ) );
m_Render->DrawShavedCornerRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
m_Render->SetDrawColor( Gwen::Color( 255, 255, 255, 70 ) );
m_Render->DrawShavedCornerRect( Gwen::Rect( 2, 2, rect.w-4, rect.h-4 ) );
m_Render->SetDrawColor( m_colBorderColor );
m_Render->DrawShavedCornerRect( rect );
}
virtual void DrawListBox( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colBorderColor );
m_Render->DrawLinedRect( rect );
}
virtual void DrawListBoxLine( Gwen::Controls::Base* control, bool bSelected )
{
Gwen::Rect rect = control->GetRenderBounds();
if ( bSelected )
{
m_Render->SetDrawColor( m_colHighlightBorder );
m_Render->DrawFilledRect( rect );
}
else if ( control->IsHovered() )
{
m_Render->SetDrawColor( m_colHighlightBG );
m_Render->DrawFilledRect( rect );
}
}
virtual void DrawSlider( Gwen::Controls::Base* control, bool bIsHorizontal, int numNotches, int barSize)
{
Gwen::Rect rect = control->GetRenderBounds();
// Gwen::Rect notchRect = rect;
if ( bIsHorizontal )
{
rect.y += rect.h * 0.4;
rect.h -= rect.h * 0.8;
}
else
{
rect.x += rect.w * 0.4;
rect.w -= rect.w * 0.8;
}
m_Render->SetDrawColor( m_colBGDark );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colControlDarker );
m_Render->DrawLinedRect( rect );
}
virtual void DrawComboBox( Gwen::Controls::Base* control )
{
DrawTextBox( control );
}
virtual void DrawBackground( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( m_colBGDark );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colControlDarker);
m_Render->DrawLinedRect( rect );
}
virtual void DrawKeyboardHighlight( Gwen::Controls::Base* control, const Gwen::Rect& r, int iOffset )
{
Gwen::Rect rect = r;
rect.x += iOffset;
rect.y += iOffset;
rect.w -= iOffset*2;
rect.h -= iOffset*2;
//draw the top and bottom
bool skip = true;
for(int i=0; i< rect.w*0.5; i++)
{
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 255 ) );
if (!skip)
{
m_Render->DrawPixel(rect.x + (i*2), rect.y);
m_Render->DrawPixel(rect.x + (i*2), rect.y+rect.h-1);
}
else
skip = !skip;
}
skip = false;
for(int i=0; i< rect.h*0.5; i++)
{
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 255 ) );
if (!skip)
{
m_Render->DrawPixel(rect.x , rect.y +i*2);
m_Render->DrawPixel(rect.x +rect.w-1, rect.y +i*2 );
}
else
skip = !skip;
}
}
virtual void DrawToolTip( Gwen::Controls::Base* control )
{
Gwen::Rect rct = control->GetRenderBounds();
rct.x -= 3;
rct.y -= 3;
rct.w += 6;
rct.h += 6;
m_Render->SetDrawColor( m_colToolTipBackground );
m_Render->DrawFilledRect( rct );
m_Render->SetDrawColor( m_colToolTipBorder );
m_Render->DrawLinedRect( rct );
}
virtual void DrawScrollButton( Gwen::Controls::Base* control, int iDirection, bool bDepressed )
{
DrawButton( control, bDepressed, false );
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 240 ) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
if ( iDirection == Gwen::Pos::Top ) DrawArrowUp( r );
else if ( iDirection == Gwen::Pos::Bottom ) DrawArrowDown( r );
else if ( iDirection == Gwen::Pos::Left ) DrawArrowLeft( r );
else DrawArrowRight( r );
}
virtual void DrawComboBoxButton( Gwen::Controls::Base* control, bool bDepressed )
{
//DrawButton( control->Width(), control->Height(), bDepressed, false, true );
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 240 ) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
DrawArrowDown( r );
}
virtual void DrawNumericUpDownButton( Gwen::Controls::Base* control, bool bDepressed, bool bUp )
{
//DrawButton( control->Width(), control->Height(), bDepressed, false, true );
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 240 ) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
if ( bUp ) DrawArrowUp( r );
else DrawArrowDown( r );
}
virtual void DrawTreeButton( Controls::Base* control, bool bOpen )
{
Gwen::Rect rect = control->GetRenderBounds();
rect.x += 2;
rect.y += 2;
rect.w -= 4;
rect.h -= 4;
m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colBorderColor );
m_Render->DrawLinedRect( rect );
m_Render->SetDrawColor( m_colBorderColor );
if ( !bOpen ) // ! because the button shows intention, not the current state
m_Render->DrawFilledRect( Gwen::Rect( rect.x + rect.w/2, rect.y + 2, 1, rect.h - 4 ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x +2, rect.y + rect.h/2, rect.w-4, 1 ) );
}
virtual void DrawTreeControl( Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( m_colControlBright );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colBorderColor );
m_Render->DrawLinedRect( rect );
}
void DrawTreeNode( Controls::Base* ctrl, bool bOpen, bool bSelected, int iLabelHeight, int iLabelWidth, int iHalfWay, int iLastBranch, bool bIsRoot )
{
if ( bSelected )
{
m_Render->SetDrawColor( Color( 0, 150, 255, 100 ) );
m_Render->DrawFilledRect( Gwen::Rect( 17, 0, iLabelWidth + 2, iLabelHeight-1 ) );
m_Render->SetDrawColor( Color( 0, 150, 255, 200 ) );
m_Render->DrawLinedRect( Gwen::Rect( 17, 0, iLabelWidth + 2, iLabelHeight-1 ) );
}
m_Render->SetDrawColor( Color( 0, 0, 0, 50 ) );
if ( !bIsRoot )
m_Render->DrawFilledRect( Gwen::Rect( 9, iHalfWay, 16-9, 1 ) );
if ( !bOpen ) return;
m_Render->DrawFilledRect( Gwen::Rect( 14 + 8, iLabelHeight, 1, iLastBranch + iHalfWay - iLabelHeight ) );
}
virtual void DrawStatusBar( Controls::Base* control )
{
DrawBackground( control );
}
virtual void DrawPropertyRow( Controls::Base* control, int iWidth, bool bBeingEdited )
{
Gwen::Rect rect = control->GetRenderBounds();
if ( bBeingEdited )
{
m_Render->SetDrawColor( m_colHighlightBG );
m_Render->DrawFilledRect( Gwen::Rect( 0, rect.y, iWidth, rect.h ) );
}
m_Render->SetDrawColor( m_colControlOutlineLighter );
m_Render->DrawFilledRect( Gwen::Rect( iWidth, rect.y, 1, rect.h ) );
rect.y += rect.h-1;
rect.h = 1;
m_Render->DrawFilledRect( rect );
}
virtual void DrawPropertyTreeNode( Controls::Base* control, int BorderLeft, int BorderTop )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( m_colControlOutlineLighter );
m_Render->DrawFilledRect( Gwen::Rect( rect.x, rect.y, BorderLeft, rect.h ) );
m_Render->DrawFilledRect( Gwen::Rect( rect.x + BorderLeft, rect.y, rect.w - BorderLeft, BorderTop ) );
}
void DrawColorDisplay( Controls::Base* control, Gwen::Color color )
{
Gwen::Rect rect = control->GetRenderBounds();
if ( color.a != 255 )
{
GetRender()->SetDrawColor( Gwen::Color( 255, 255, 255, 255 ) );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( Gwen::Color( 128, 128, 128, 128 ) );
GetRender()->DrawFilledRect( Gwen::Rect( 0, 0, rect.w * 0.5, rect.h * 0.5) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.w * 0.5, rect.h * 0.5, rect.w * 0.5,rect.h * 0.5) );
}
GetRender()->SetDrawColor( color );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( Gwen::Color( 0, 0, 0, 255 ) );
GetRender()->DrawLinedRect( rect );
}
virtual void DrawModalControl( Controls::Base* control )
{
if ( control->ShouldDrawBackground() )
{
Gwen::Rect rect = control->GetRenderBounds();
GetRender()->SetDrawColor( m_colModal );
GetRender()->DrawFilledRect( rect );
}
}
virtual void DrawMenuDivider( Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
GetRender()->SetDrawColor( m_colBGDark );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( m_colControlDarker);
GetRender()->DrawLinedRect( rect );
}
};
}
}
#endif

View File

@@ -0,0 +1,625 @@
#pragma once
#ifndef GWEN_SKINS_TEXTUREDBASE_H
#define GWEN_SKINS_TEXTUREDBASE_H
#include "Gwen/Skin.h"
#include "Gwen/Gwen.h"
#include "Gwen/Controls/Base.h"
#include "Gwen/Texture.h"
#include "Gwen/Skins/Texturing.h"
namespace Gwen
{
namespace Skin
{
class TexturedBase : public Gwen::Skin::Base
{
public:
Gwen::Color m_colBorderColor;
Gwen::Color m_colControlOutlineLight;
Gwen::Color m_colControlOutlineLighter;
Gwen::Color m_colBG;
Gwen::Color m_colBGDark;
Gwen::Color m_colControl;
Gwen::Color m_colControlBorderHighlight;
Gwen::Color m_colControlDarker;
Gwen::Color m_colControlOutlineNormal;
Gwen::Color m_colControlBright;
Gwen::Color m_colControlDark;
Gwen::Color m_colHighlightBG;
Gwen::Color m_colHighlightBorder;
Gwen::Color m_colToolTipBackground;
Gwen::Color m_colToolTipBorder;
Gwen::Color m_colModal;
Texture m_Texture;
Texturing::Bordered m_texButton;
Texturing::Bordered m_texButton_Hovered;
Texturing::Bordered m_texButton_Pressed;
Texturing::Bordered m_texMenu_Strip, m_texMenu_Panel, m_texMenu_Panel_Border;
Texturing::Bordered m_texMenu_Hover;
Texturing::Bordered m_texShadow;
Texturing::Bordered m_texTextBox, m_texTextBox_Focus;
Texturing::Bordered m_texTab_Control, m_texTab, m_texTab_Inactive, m_texTab_Gap, m_texTabBar;
Texturing::Bordered m_texWindow, m_texWindow_Inactive;
Texturing::Bordered m_texTreeBG;
Texturing::Single m_Checkbox, m_Checkbox_Checked;
Texturing::Single m_RadioButton, m_RadioButton_Checked;
Texturing::Single m_CheckMark;
Texturing::Single m_TreeMinus, m_TreePlus;
virtual void Init( const TextObject& TextureName )
{
m_colBorderColor = Gwen::Color( 80, 80, 80, 255 );
m_colBG = Gwen::Color( 248, 248, 248, 255 );
m_colBGDark = Gwen::Color( 235, 235, 235, 255 );
m_colControl = Gwen::Color( 240, 240, 240, 255 );
m_colControlBright = Gwen::Color( 255, 255, 255, 255 );
m_colControlDark = Gwen::Color( 214, 214, 214, 255 );
m_colControlDarker = Gwen::Color( 180, 180, 180, 255 );
m_colControlOutlineNormal = Gwen::Color( 112, 112, 112, 255 );
m_colControlOutlineLight = Gwen::Color( 144, 144, 144, 255 );
m_colControlOutlineLighter = Gwen::Color( 210, 210, 210, 255 );
m_colHighlightBG = Gwen::Color( 192, 221, 252, 255 );
m_colHighlightBorder = Gwen::Color( 51, 153, 255, 255 );
m_colToolTipBackground = Gwen::Color( 255, 255, 225, 255 );
m_colToolTipBorder = Gwen::Color( 0, 0, 0, 255 );
m_colModal = Gwen::Color( 25, 25, 25, 150 );
m_DefaultFont.facename = L"Microsoft Sans Serif";
m_DefaultFont.size = 11;
m_Texture.Load( TextureName, GetRender() );
m_texButton.Init( &m_Texture, 194, 0, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texButton_Hovered.Init( &m_Texture, 194, 25, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texButton_Pressed.Init( &m_Texture, 194, 50, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texMenu_Strip.Init( &m_Texture, 194, 75, 62, 21, Margin( 8, 8, 8, 8 ) );
m_texMenu_Panel.Init( &m_Texture, 194, 130, 62, 32, Margin( 8, 8, 8, 8 ) );
m_texMenu_Panel_Border.Init( &m_Texture, 194, 97, 62, 32, Margin( 24, 8, 8, 8 ) );
m_texMenu_Hover.Init( &m_Texture, 219, 50, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texShadow.Init( &m_Texture, 223, 0, 32, 32, Margin( 8, 8, 8, 8 ) );
m_texTextBox.Init( &m_Texture, 0, 122, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texTextBox_Focus.Init( &m_Texture, 25, 122, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texTab.Init( &m_Texture, 0, 97, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texTab_Inactive.Init( &m_Texture, 25, 97, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texTab_Control.Init( &m_Texture, 50, 97, 24, 24, Margin( 8, 8, 8, 8 ) );
m_texTab_Gap.Init( &m_Texture, 50+8, 97+8, 8, 8, Margin( 8, 8, 8, 8 ) );
m_texTabBar.Init( &m_Texture, 0, 147, 74, 16, Margin( 4, 4, 4, 4 ) );
m_texWindow.Init( &m_Texture, 0, 0, 96, 96, Margin( 16, 32, 16, 16 ) );
m_texWindow_Inactive.Init( &m_Texture, 97, 0, 96, 96, Margin( 16, 32, 16, 16 ) );
m_Checkbox.Init( &m_Texture, 75, 97, 16, 16 );
m_Checkbox_Checked.Init( &m_Texture, 93, 97, 16, 16 );
m_RadioButton.Init( &m_Texture, 110, 97, 16, 16 );
m_RadioButton_Checked.Init( &m_Texture, 127, 97, 16, 16 );
m_CheckMark.Init( &m_Texture, 145, 97, 16, 16 );
m_TreeMinus.Init( &m_Texture, 75, 115, 11, 11 );
m_TreePlus.Init( &m_Texture, 93, 115, 11, 11 );
m_texTreeBG.Init( &m_Texture, 0, 164, 49, 49, Margin( 16, 16, 16, 16 ) );
}
virtual void DrawButton( Gwen::Controls::Base* control, bool bDepressed, bool bHovered )
{
if ( bDepressed )
m_texButton_Pressed.Draw( GetRender(), control->GetRenderBounds() );
else
m_texButton.Draw( GetRender(), control->GetRenderBounds() );
if ( bHovered )
m_texButton_Hovered.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawMenuItem( Gwen::Controls::Base* control, bool bSubmenuOpen, bool bChecked )
{
if ( bSubmenuOpen || control->IsHovered() )
m_texMenu_Hover.Draw( GetRender(), control->GetRenderBounds() );
if ( bChecked )
m_CheckMark.Draw( GetRender(), Gwen::Rect( control->GetRenderBounds().x+2, control->GetRenderBounds().y+2, 16, 16 ));
}
virtual void DrawMenuStrip( Gwen::Controls::Base* control )
{
m_texMenu_Strip.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawMenu( Gwen::Controls::Base* control, bool bPaddingDisabled )
{
if ( !bPaddingDisabled )
{
return m_texMenu_Panel_Border.Draw( GetRender(), control->GetRenderBounds() );
}
m_texMenu_Panel.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawShadow( Gwen::Controls::Base* control )
{
Gwen::Rect r = control->GetRenderBounds();
r.x -= 8;
r.y -= 8;
r.w += 16;
r.h += 16;
// m_texShadow.Draw( r );
}
virtual void DrawRadioButton( Gwen::Controls::Base* control, bool bSelected, bool bDepressed)
{
if ( bSelected )
m_RadioButton_Checked.Draw( GetRender(), control->GetRenderBounds() );
else
m_RadioButton.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawCheckBox( Gwen::Controls::Base* control, bool bSelected, bool bDepressed)
{
if ( bSelected )
m_Checkbox_Checked.Draw( GetRender(), control->GetRenderBounds() );
else
m_Checkbox.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawGroupBox( Gwen::Controls::Base* control, int textStart, int textHeight, int textWidth )
{
Gwen::Rect rect = control->GetRenderBounds();
rect.y += textHeight * 0.5f;
rect.h -= textHeight * 0.5f;
Gwen::Color m_colDarker = Gwen::Color( 0, 50, 60, 50 );
Gwen::Color m_colLighter = Gwen::Color( 255, 255, 255, 150 );
GetRender()->SetDrawColor( m_colLighter );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+1, textStart-3, 1 ) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x+1+textStart+textWidth, rect.y+1, rect.w-textStart+textWidth-2, 1 ) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x+1, (rect.y + rect.h)-1, rect.x+rect.w-2, 1 ) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y+1, 1, rect.h ) );
GetRender()->DrawFilledRect( Gwen::Rect( (rect.x + rect.w)-2, rect.y+1, 1, rect.h-1 ) );
GetRender()->SetDrawColor( m_colDarker );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x+1, rect.y, textStart-3, 1 ) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x+1+textStart+textWidth, rect.y, rect.w-textStart-textWidth-2, 1 ) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x+1, (rect.y + rect.h)-1, rect.x+rect.w-2, 1 ) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x, rect.y+1, 1, rect.h-1 ) );
GetRender()->DrawFilledRect( Gwen::Rect( (rect.x + rect.w)-1, rect.y+1, 1, rect.h-1 ) );
}
virtual void DrawTextBox( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
bool bHasFocus = control->HasFocus();
if ( bHasFocus )
m_texTextBox_Focus.Draw( GetRender(), control->GetRenderBounds() );
else
m_texTextBox.Draw( GetRender(), control->GetRenderBounds() );
//I dunno what this is for yet
/*
if ( CursorRect.w == 1 )
{
if ( bHasFocus )
{
GetRender()->SetDrawColor( Gwen::Color( 0, 0, 0, 200 ) );
GetRender()->DrawFilledRect( CursorRect );
}
}
else
{
if ( bHasFocus )
{
GetRender()->SetDrawColor( Gwen::Color( 50, 150, 255, 250 ) );
GetRender()->DrawFilledRect( CursorRect );
}
}
*/
}
virtual void DrawTabButton( Gwen::Controls::Base* control, bool bActive )
{
if ( bActive )
m_texTab.Draw( GetRender(), control->GetRenderBounds() );
else
m_texTab_Inactive.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawTabControl( Gwen::Controls::Base* control, Gwen::Rect CurrentButtonRect )
{
m_texTab_Control.Draw( GetRender(), control->GetRenderBounds() );
if ( CurrentButtonRect.w > 0 && CurrentButtonRect.h > 0 )
m_texTab_Gap.Draw( GetRender(), CurrentButtonRect );
}
virtual void DrawTabTitleBar( Gwen::Controls::Base* control )
{
m_texTabBar.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawWindow( Gwen::Controls::Base* control, int topHeight, bool inFocus )
{
Gwen::Rect rect = control->GetRenderBounds();
if ( inFocus ) m_texWindow.Draw( GetRender(), control->GetRenderBounds() );
else m_texWindow_Inactive.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawHighlight( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
GetRender()->SetDrawColor( Gwen::Color( 255, 100, 255, 255 ) );
GetRender()->DrawFilledRect( rect );
}
virtual void DrawScrollBar( Gwen::Controls::Base* control, bool isHorizontal, bool bDepressed )
{
Gwen::Rect rect = control->GetRenderBounds();
if (bDepressed)
GetRender()->SetDrawColor( m_colControlDarker );
else
GetRender()->SetDrawColor( m_colControlBright );
GetRender()->DrawFilledRect( rect );
}
virtual void DrawScrollBarBar( Controls::Base* control, bool bDepressed, bool isHovered, bool isHorizontal )
{
//TODO: something specialized
DrawButton( control, bDepressed, isHovered );
}
virtual void DrawProgressBar( Gwen::Controls::Base* control, bool isHorizontal, float progress)
{
Gwen::Rect rect = control->GetRenderBounds();
Gwen::Color FillColour( 0, 211, 40, 255 );
if ( isHorizontal )
{
//Background
GetRender()->SetDrawColor( m_colControlDark );
GetRender()->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
//Right half
GetRender()->SetDrawColor( FillColour );
GetRender()->DrawFilledRect( Gwen::Rect( 1, 1, rect.w*progress-2, rect.h-2 ) );
GetRender()->SetDrawColor( Gwen::Color( 255, 255, 255, 150 ) );
GetRender()->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h*0.45f ) );
}
else
{
//Background
GetRender()->SetDrawColor( m_colControlDark );
GetRender()->DrawFilledRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
//Top half
GetRender()->SetDrawColor( FillColour );
GetRender()->DrawFilledRect( Gwen::Rect( 1, 1 + (rect.h * (1 - progress)), rect.w-2, rect.h * progress - 2 ) );
GetRender()->SetDrawColor( Gwen::Color( 255, 255, 255, 150 ) );
GetRender()->DrawFilledRect( Gwen::Rect( 1, 1, rect.w*0.45f, rect.h-2 ) );
}
GetRender()->SetDrawColor( Gwen::Color( 255, 255, 255, 150 ) );
GetRender()->DrawShavedCornerRect( Gwen::Rect( 1, 1, rect.w-2, rect.h-2 ) );
GetRender()->SetDrawColor( Gwen::Color( 255, 255, 255, 70 ) );
GetRender()->DrawShavedCornerRect( Gwen::Rect( 2, 2, rect.w-4, rect.h-4 ) );
GetRender()->SetDrawColor( m_colBorderColor );
GetRender()->DrawShavedCornerRect( rect );
}
virtual void DrawListBox( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
GetRender()->SetDrawColor( m_colControlBright );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( m_colBorderColor );
GetRender()->DrawLinedRect( rect );
}
virtual void DrawListBoxLine( Gwen::Controls::Base* control, bool bSelected )
{
Gwen::Rect rect = control->GetRenderBounds();
if ( bSelected )
{
GetRender()->SetDrawColor( m_colHighlightBorder );
GetRender()->DrawFilledRect( rect );
}
else if ( control->IsHovered() )
{
GetRender()->SetDrawColor( m_colHighlightBG );
GetRender()->DrawFilledRect( rect );
}
}
virtual void DrawSlider( Gwen::Controls::Base* control, bool bIsHorizontal, int numNotches, int barSize)
{
Gwen::Rect rect = control->GetRenderBounds();
Gwen::Rect notchRect = rect;
if ( bIsHorizontal )
{
rect.y += rect.h * 0.4;
rect.h -= rect.h * 0.8;
}
else
{
rect.x += rect.w * 0.4;
rect.w -= rect.w * 0.8;
}
GetRender()->SetDrawColor( m_colBGDark );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( m_colControlDarker );
GetRender()->DrawLinedRect( rect );
}
virtual void DrawComboBox( Gwen::Controls::Base* control )
{
DrawTextBox( control );
}
virtual void DrawKeyboardHighlight( Gwen::Controls::Base* control, const Gwen::Rect& r, int iOffset )
{
Gwen::Rect rect = r;
rect.x += iOffset;
rect.y += iOffset;
rect.w -= iOffset*2;
rect.h -= iOffset*2;
//draw the top and bottom
bool skip = true;
for(int i=0; i< rect.w*0.5; i++)
{
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 255 ) );
if (!skip)
{
GetRender()->DrawPixel(rect.x + (i*2), rect.y);
GetRender()->DrawPixel(rect.x + (i*2), rect.y+rect.h-1);
}
else
skip = !skip;
}
skip = false;
for(int i=0; i< rect.h*0.5; i++)
{
GetRender()->SetDrawColor( Gwen::Color( 0, 0, 0, 255 ) );
if (!skip)
{
GetRender()->DrawPixel(rect.x , rect.y +i*2);
GetRender()->DrawPixel(rect.x +rect.w-1, rect.y +i*2 );
}
else
skip = !skip;
}
}
virtual void DrawToolTip( Gwen::Controls::Base* control )
{
Gwen::Rect rct = control->GetRenderBounds();
rct.x -= 3;
rct.y -= 3;
rct.w += 6;
rct.h += 6;
GetRender()->SetDrawColor( m_colToolTipBackground );
GetRender()->DrawFilledRect( rct );
GetRender()->SetDrawColor( m_colToolTipBorder );
GetRender()->DrawLinedRect( rct );
}
virtual void DrawScrollButton( Gwen::Controls::Base* control, int iDirection, bool bDepressed )
{
DrawButton( control, bDepressed, false );
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 240 ) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
if ( iDirection == Gwen::Pos::Top ) DrawArrowUp( r );
else if ( iDirection == Gwen::Pos::Bottom ) DrawArrowDown( r );
else if ( iDirection == Gwen::Pos::Left ) DrawArrowLeft( r );
else DrawArrowRight( r );
}
virtual void DrawComboBoxButton( Gwen::Controls::Base* control, bool bDepressed )
{
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 240 ) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
DrawArrowDown( r );
}
virtual void DrawNumericUpDownButton( Gwen::Controls::Base* control, bool bDepressed, bool bUp )
{
// DrawButton( control->Width(), control->Height(), bDepressed, false, true );
m_Render->SetDrawColor( Gwen::Color( 0, 0, 0, 240 ) );
Gwen::Rect r( control->Width() / 2 - 2, control->Height() / 2 - 2, 5, 5 );
if ( bUp ) DrawArrowUp( r );
else DrawArrowDown( r );
}
virtual void DrawStatusBar( Controls::Base* control )
{
DrawBackground( control );
}
virtual void DrawBackground( Gwen::Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
m_Render->SetDrawColor( m_colBGDark );
m_Render->DrawFilledRect( rect );
m_Render->SetDrawColor( m_colControlDarker);
m_Render->DrawLinedRect( rect );
}
virtual void DrawTreeButton( Controls::Base* control, bool bOpen )
{
Gwen::Rect rect = control->GetRenderBounds();
rect.x += 2;
rect.y += 2;
rect.w -= 2;
rect.h -= 2;
if ( bOpen )
{
m_TreeMinus.Draw( GetRender(), rect );
}
else
m_TreePlus.Draw( GetRender(), rect );
}
virtual void DrawTreeControl( Controls::Base* control )
{
m_texTreeBG.Draw( GetRender(), control->GetRenderBounds() );
}
virtual void DrawPropertyRow( Controls::Base* control, int iWidth, bool bBeingEdited )
{
Gwen::Rect rect = control->GetRenderBounds();
if ( bBeingEdited )
{
GetRender()->SetDrawColor( m_colHighlightBG );
GetRender()->DrawFilledRect( Gwen::Rect( 0, rect.y, iWidth, rect.h ) );
}
GetRender()->SetDrawColor( m_colControlOutlineLighter );
GetRender()->DrawFilledRect( Gwen::Rect( iWidth, rect.y, 1, rect.h ) );
rect.y += rect.h-1;
rect.h = 1;
GetRender()->DrawFilledRect( rect );
}
virtual void DrawPropertyTreeNode( Controls::Base* control, int BorderLeft, int BorderTop )
{
Gwen::Rect rect = control->GetRenderBounds();
GetRender()->SetDrawColor( m_colControlOutlineLighter );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x, rect.y, BorderLeft, rect.h ) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.x + BorderLeft, rect.y, rect.w - BorderLeft, BorderTop ) );
}
void DrawTreeNode( Controls::Base* ctrl, bool bOpen, bool bSelected, int iLabelHeight, int iLabelWidth, int iHalfWay, int iLastBranch, bool bIsRoot )
{
if ( bSelected )
{
GetRender()->SetDrawColor( Color( 0, 150, 255, 100 ) );
GetRender()->DrawFilledRect( Gwen::Rect( 17, 0, iLabelWidth + 2, iLabelHeight-1 ) );
GetRender()->SetDrawColor( Color( 0, 150, 255, 200 ) );
GetRender()->DrawLinedRect( Gwen::Rect( 17, 0, iLabelWidth + 2, iLabelHeight-1 ) );
}
GetRender()->SetDrawColor( Color( 0, 0, 0, 50 ) );
if ( !bIsRoot )
GetRender()->DrawFilledRect( Gwen::Rect( 9, iHalfWay, 16-9, 1 ) );
if ( !bOpen ) return;
GetRender()->DrawFilledRect( Gwen::Rect( 14 + 8, iLabelHeight, 1, iLastBranch + iHalfWay - iLabelHeight ) );
}
void DrawColorDisplay( Controls::Base* control, Gwen::Color color )
{
Gwen::Rect rect = control->GetRenderBounds();
if ( color.a != 255)
{
GetRender()->SetDrawColor( Gwen::Color( 255, 255, 255, 255 ) );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( Gwen::Color( 128, 128, 128, 128 ) );
GetRender()->DrawFilledRect( Gwen::Rect( 0, 0, rect.w * 0.5, rect.h * 0.5) );
GetRender()->DrawFilledRect( Gwen::Rect( rect.w * 0.5, rect.h * 0.5, rect.w * 0.5,rect.h * 0.5) );
}
GetRender()->SetDrawColor( color );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( Gwen::Color( 0, 0, 0, 255 ) );
GetRender()->DrawLinedRect( rect );
}
virtual void DrawModalControl( Controls::Base* control )
{
if ( control->ShouldDrawBackground() )
{
Gwen::Rect rect = control->GetRenderBounds();
GetRender()->SetDrawColor( m_colModal );
GetRender()->DrawFilledRect( rect );
}
}
virtual void DrawMenuDivider( Controls::Base* control )
{
Gwen::Rect rect = control->GetRenderBounds();
GetRender()->SetDrawColor( m_colBGDark );
GetRender()->DrawFilledRect( rect );
GetRender()->SetDrawColor( m_colControlDarker);
GetRender()->DrawLinedRect( rect );
}
};
}
}
#endif

View File

@@ -0,0 +1,147 @@
#pragma once
#ifndef GWEN_SKINS_TEXTURING_H
#define GWEN_SKINS_TEXTURING_H
#include "Gwen/Gwen.h"
#include "Gwen/Texture.h"
namespace Gwen
{
namespace Skin
{
namespace Texturing
{
struct Single
{
Single()
{
texture = NULL;
}
void Init( Texture* pTexture, float x, float y, float w, float h )
{
texture = pTexture;
float texw = texture->width;
float texh = texture->height;
uv[0] = x / texw;
uv[1] = y / texh;
uv[2] = (x+w) / texw;
uv[3] = (y+h) / texh;
}
void Draw( Gwen::Renderer::Base* render, Gwen::Rect r, const Gwen::Color& col = Gwen::Colors::White )
{
render->SetDrawColor( col );
render->DrawTexturedRect( texture, r, uv[0], uv[1],uv[2], uv[3] );
}
Texture* texture;
float uv[4];
};
struct Bordered
{
Bordered()
{
texture = NULL;
}
void Init( Texture* pTexture, float x, float y, float w, float h, Margin in_margin, float DrawMarginScale = 1.0f )
{
texture = pTexture;
margin = in_margin;
SetRect( 0, x, y, margin.left, margin.top );
SetRect( 1, x+margin.left, y, w - margin.left - margin.right - 1, margin.top );
SetRect( 2, (x + w) - margin.right, y, margin.right, margin.top );
SetRect( 3, x, y+margin.top, margin.left, h - margin.top - margin.bottom - 1 );
SetRect( 4, x+margin.left, y+margin.top, w - margin.left - margin.right - 1, h - margin.top - margin.bottom - 1 );
SetRect( 5, (x + w) - margin.right, y+margin.top, margin.right, h - margin.top - margin.bottom - 1 );
SetRect( 6, x, (y+h)-margin.bottom, margin.left, margin.bottom );
SetRect( 7, x+margin.left, (y+h)-margin.bottom, w - margin.left - margin.right - 1, margin.bottom );
SetRect( 8, (x + w) - margin.right, (y+h)-margin.bottom, margin.right, margin.bottom );
margin.left *= DrawMarginScale;
margin.right *= DrawMarginScale;
margin.top *= DrawMarginScale;
margin.bottom *= DrawMarginScale;
width = w - x;
height = h - y;
}
void SetRect( int iNum, float x, float y, float w, float h )
{
float texw = texture->width;
float texh = texture->height;
//x -= 1.0f;
//y -= 1.0f;
rects[iNum].uv[0] = x / texw;
rects[iNum].uv[1] = y / texh;
rects[iNum].uv[2] = (x+w) / texw;
rects[iNum].uv[3] = (y+h) / texh;
// rects[iNum].uv[0] += 1.0f / texture->width;
// rects[iNum].uv[1] += 1.0f / texture->width;
}
void Draw( Gwen::Renderer::Base* render, Gwen::Rect r, const Gwen::Color& col = Gwen::Colors::White )
{
render->SetDrawColor( col );
if ( r.w < width && r.h < height )
{
render->DrawTexturedRect( texture,
r,
rects[0].uv[0], rects[0].uv[1], rects[8].uv[2], rects[8].uv[3] );
return;
}
DrawRect( render, 0, r.x, r.y, margin.left, margin.top );
DrawRect( render, 1, r.x + margin.left, r.y, r.w - margin.left - margin.right, margin.top );
DrawRect( render, 2, (r.x + r.w) - margin.right, r.y, margin.right, margin.top );
DrawRect( render, 3, r.x, r.y+margin.top, margin.left, r.h - margin.top - margin.bottom );
DrawRect( render, 4, r.x + margin.left, r.y+margin.top, r.w - margin.left - margin.right, r.h - margin.top - margin.bottom );
DrawRect( render, 5, (r.x + r.w) - margin.right, r.y+margin.top, margin.right, r.h - margin.top - margin.bottom );
DrawRect( render, 6, r.x, (r.y+r.h) - margin.bottom, margin.left, margin.bottom );
DrawRect( render, 7, r.x + margin.left, (r.y+r.h) - margin.bottom, r.w - margin.left - margin.right, margin.bottom );
DrawRect( render, 8, (r.x + r.w) - margin.right, (r.y+r.h) - margin.bottom, margin.right, margin.bottom );
}
void DrawRect( Gwen::Renderer::Base* render, int i, int x, int y, int w, int h )
{
render->DrawTexturedRect( texture,
Gwen::Rect( x, y, w, h ),
rects[i].uv[0], rects[i].uv[1], rects[i].uv[2], rects[i].uv[3] );
}
Texture* texture;
struct SubRect
{
float uv[4];
};
SubRect rects[9];
Margin margin;
float width;
float height;
};
}
}
}
#endif