Просмотр исходного кода

Fixed issue with invisible and disabled controls still receiving input.
Reverted default theme back to original theme for now.

Steve Grenier 12 лет назад
Родитель
Сommit
245f14a149

+ 1 - 1
gameplay/src/Control.cpp

@@ -124,7 +124,7 @@ void Control::initialize(const char* typeName, Theme::Style* style, Properties*
         if (!_style)
         {
             // No style was found, use an empty style
-            _style = Theme::getDefault()->getEmptyStyle();
+            _style = style ? style->getTheme()->getEmptyStyle() : Theme::getDefault()->getEmptyStyle();
         }
     }
 

+ 7 - 0
gameplay/src/Font.cpp

@@ -676,6 +676,13 @@ void Font::drawText(const char* text, const Rectangle& area, const Vector4& colo
                     // Draw this character.
                     if (draw)
                     {
+                        if (getFormat() == DISTANCE_FIELD)
+                        {
+                            if (_cutoffParam == NULL)
+                                _cutoffParam = getSpriteBatch()->getMaterial()->getParameter("u_cutoff");
+                            // TODO: Fix me so that smaller font are much smoother
+                            _cutoffParam->setVector2(Vector2(1.0, 1.0));
+                        }
                         if (clip)
                         {
                             _batch->draw(xPos, yPos, g.width * scale, size, g.uvs[0], g.uvs[1], g.uvs[2], g.uvs[3], color, *clip);

+ 4 - 1
gameplay/src/Form.cpp

@@ -467,11 +467,14 @@ Control* Form::findInputControl(int* x, int* y, bool focus)
 
 Control* Form::findInputControl(Control* control, int x, int y, bool focus)
 {
+    if (!(control->_visible && control->_enabled))
+        return NULL;
+
     Control* result = NULL;
 
     // Does the passed in control's bounds intersect the specified coordinates - and 
     // does the control support the specified input state?
-    if (control->_consumeInputEvents && control->_visible && control->_enabled && (!focus || control->canFocus()))
+    if (control->_consumeInputEvents && (!focus || control->canFocus()))
     {
         if (control->_absoluteClipBounds.contains(x, y))
             result = control;

+ 414 - 515
samples/browser/res/common/default.theme

@@ -1,515 +1,414 @@
-theme mainMenu
-{
-    texture = res/png/default-theme.png
-
-    imageList normalImages
-    {
-        color = #ffffffff
-
-        image unchecked
-        {
-            region = 78, 1, 46, 46
-        }
-
-        image checked
-        {
-            region = 78, 46, 46, 46
-        }
-
-        image unselected
-        {
-            region = 127, 1, 46, 46
-        }
-
-        image selected
-        {
-            region = 127, 46, 46, 46
-        }
-
-        image minCap
-        {
-            region = 3, 115, 8, 11
-        }
-
-        image maxCap
-        {
-            region = 3, 115, 8, 11
-        }
-
-        image marker
-        {
-            region = 16, 113, 18, 18
-        }
-
-        image track
-        {
-            region = 42, 119, 26, 6
-        }
-
-        image textCaret
-        {
-            region = 5, 149, 11, 25
-        }
-
-        image scrollBarTopCap
-        {
-            //region = 0, 99, 12, 5
-            region = 0, 43, 17, 10
-        }
-
-        image verticalScrollBar
-        {
-            //region = 0, 104, 12, 19
-            region = 0, 53, 17, 16
-        }
-
-        image scrollBarBottomCap
-        {
-            //region = 0, 138, 12, 5
-            region = 0, 69, 17, 10
-        }
-
-        image scrollBarLeftCap
-        {
-            region = 35, 115, 5, 12
-        }
-
-        image horizontalScrollBar
-        {
-            region = 43, 115, 19, 12
-        }
-
-        image scrollBarRightCap
-        {
-            region = 65, 115, 5, 12
-        }
-    }
-
-    imageList activeImages : normalImages
-    {
-        color = #ffffffff
-
-        image unchecked
-        {
-            region = 78, 91, 46, 46
-        }
-
-        image checked
-        {
-            region = 78, 91, 46, 46
-        }
-
-        image unselected
-        {
-            region = 127, 91, 46, 46
-        }
-
-        image selected
-        {
-            region = 127, 91, 46, 46
-        }
-    }
-
-    style Container
-    {
-        stateNormal
-        {
-            imageList = normalImages
-        }
-    }
-
-    skin FormNormal
-    {
-        border
-        {
-            left = 10
-            right = 10
-            top = 10
-            bottom = 10
-        }
-
-        region = 1, 1, 40, 40
-        color = #ffffffff
-    }
-
-    style Form
-    {
-        stateNormal
-        {
-            skin = FormNormal
-            imageList = normalImages
-            font = res/common/arial.gpb
-        }
-    }
-
-    style Label
-    {
-        stateNormal
-        {
-            //textColor = #ccccccff
-            textColor = #ffffffff
-            font = res/common/arial.gpb
-            fontSize = 16
-            textAlignment = ALIGN_VCENTER_LEFT
-            imageList = normalImages
-        }
-    }
-
-    skin ButtonNormal
-    {
-        border
-        {
-            left = 10
-            right = 10
-            top = 10
-            bottom = 10
-        }
-
-        region = 176, 0, 48, 47
-        color = #ffffffff
-    }
-
-    skin ButtonActive
-    {
-        border
-        {
-            left = 10
-            right = 10
-            top = 10
-            bottom = 10
-        }
-
-        region = 176, 47, 48, 47
-        color = #ffffffff
-    }
-
-    style Button : Label
-    {
-        stateNormal
-        {
-            skin = ButtonNormal
-            textAlignment = ALIGN_VCENTER_HCENTER
-        }
-
-        stateActive
-        {
-            skin = ButtonActive
-            textColor = #ffffffff
-            imageList = activeImages
-        }
-
-        stateDisabled
-		{
-			opacity = 0.6
-		}
-    }
-
-
-
-
-
-
-
-    skin mainNormal
-    {
-        border
-        {
-            left = 10
-            right = 10
-            top = 10
-            bottom = 10
-        }
-        
-        region = 1, 1, 74, 74
-        color = #ffffffff
-    }
-
-    skin mainActive : mainNormal
-    {
-        color = #ffffffff
-    }
-
-	skin mainFocus : mainNormal
-	{
-		color = #ffffffff
-	}
-
-    skin formEntry : mainNormal
-    {
-        region = 78, 1, 46, 46
-        color = #ffffffff
-    }
-
-	skin formFocus : formEntry
-	{
-        color = #ffffffff
-	}
-    
-    skin underliner
-    {
-        border
-        {
-            bottom = 10
-        }
-        
-        region = 4, 82, 68, 5
-        color = #ffffffff
-    }
-
-    skin plusNormal
-    {
-        region = 81, 139, 40, 40
-        color = #ffffffff
-    }
-
-    skin plusActive : plusNormal
-    {
-        color = #ffffffff
-    }
-
-    skin minusNormal
-    {
-        region = 81, 184, 40, 40
-        color = #ffffffff
-    }
-
-    skin minusActive : minusNormal
-    {
-        color = #ffffffff
-    }
-
-    style plus
-    {
-        stateNormal
-        {
-            skin = plusNormal
-        }
-
-        stateActive
-        {
-            skin = plusActive
-        }
-    }
-
-    style minus
-    {
-        stateNormal
-        {
-            skin = minusNormal
-        }
-
-        stateActive
-        {
-            skin = minusActive
-        }
-    }
-
-    style underlined
-    {
-        padding
-        {
-            top = 5
-        }
-    
-        stateNormal
-        {
-            skin = underliner
-            textColor = #ffffffff
-            font = res/common/arial.gpb
-            fontSize = 24
-            textAlignment = ALIGN_BOTTOM_HCENTER
-        }
-    }
-
-    style leftAlignedUnderlined : underlined
-    {
-        stateNormal
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-    }
-	
-	style basicContainer
-	{
-		stateNormal
-        {
-            skin = mainNormal
-            imageList = normalImages
-
-            font = res/common/arial.gpb
-            textColor = #ffffffff
-            fontSize = 18
-            textAlignment = ALIGN_VCENTER_HCENTER
-        }
-
-		stateFocus
-		{
-			skin = mainFocus
-		}
-		
-		stateDisabled
-		{
-			opacity = 0.6
-		}
-	}
-
-    style basic : basicContainer
-    {
-        stateActive
-        {
-            imageList = activeImages
-        }
-		
-		stateFocus
-		{
-			skin = mainNormal
-			textColor = #ffffffff
-		}
-    }
-
-    style topLeftAlignedEntry : basic
-    {
-        stateNormal
-        {
-            skin = formEntry
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateFocus
-        {
-            skin = formFocus
-        }
-    }
-
-    style buttonStyle : basic
-    {
-        padding
-        {
-            top = -10
-            bottom = -10
-        }
-
-        stateNormal
-        {
-            font = res/common/arial.gpb
-            fontSize = 20
-        }
-
-        stateActive
-        {
-            skin = mainActive
-        }
-    }
-	
-	style buttonHover : buttonStyle
-	{
-		stateHover
-		{
-			textColor = #ffffffff
-		}
-	}
-
-    style noBorder
-    {
-        stateNormal
-        {
-            imageList = normalImages
-            font = res/common/arial.gpb
-            textColor = #ffffffff
-            fontSize = 14
-            textAlignment = ALIGN_VCENTER_HCENTER
-        }
-		
-		stateFocus
-		{
-			textColor = #ffffffff
-		}
-
-        stateActive
-        {
-            imageList = activeImages
-            textAlignment = ALIGN_VCENTER_HCENTER
-        }
-    }
-
-    style iconNoBorder : noBorder
-    {
-        stateNormal
-        {
-            font = res/common/arial.gpb
-            fontSize = 20
-            textAlignment = ALIGN_VCENTER_LEFT
-        }
-
-        stateFocus
-		{
-			textAlignment = ALIGN_VCENTER_LEFT
-		}
-
-        stateActive
-        {
-            font = res/common/arial.gpb
-            fontSize = 20
-            textAlignment = ALIGN_VCENTER_LEFT
-        }
-    }
-
-    style topLeftNoBorder : iconNoBorder
-    {
-        stateNormal
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateActive
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateFocus
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateHover
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-    }
-
-    style title
-    {
-        stateNormal
-        {
-            textColor = #ffffffff
-            font = res/common/arial.gpb
-            fontSize = 26
-            textAlignment = ALIGN_BOTTOM_HCENTER
-        }
-
-        stateActive
-        {
-            textColor = #ffffffff
-        }
-    }
-
-    style CheckBox : iconNoBorder
-    {
-    }
-
-    style RadioButton : iconNoBorder
-    {
-    }
-
-    style Slider : topLeftNoBorder
-    {
-    }
-
-    style TextBox : topLeftAlignedEntry
-    {
-    }
-
-    style Image
-    {
-    }
-}
+theme mainMenu
+{
+    texture = res/png/default-theme.png
+
+    imageList normalImages
+    {
+        color = #4A8799ff
+
+        image unchecked
+        {
+            region = 78, 1, 46, 46
+        }
+
+        image checked
+        {
+            region = 78, 46, 46, 46
+        }
+
+        image unselected
+        {
+            region = 127, 1, 46, 46
+        }
+
+        image selected
+        {
+            region = 127, 46, 46, 46
+        }
+
+        image minCap
+        {
+            region = 3, 115, 8, 11
+        }
+
+        image maxCap
+        {
+            region = 3, 115, 8, 11
+        }
+
+        image marker
+        {
+            region = 16, 113, 18, 18
+        }
+
+        image track
+        {
+            region = 42, 119, 26, 6
+        }
+
+        image textCaret
+        {
+            region = 5, 149, 11, 25
+            color = #C3D9BFff
+        }
+
+        image scrollBarTopCap
+        {
+            region = 0, 99, 12, 5
+        }
+
+        image verticalScrollBar
+        {
+            region = 0, 104, 12, 19
+        }
+
+        image scrollBarBottomCap
+        {
+            region = 0, 138, 12, 5
+        }
+
+        image scrollBarLeftCap
+        {
+            region = 35, 115, 5, 12
+        }
+
+        image horizontalScrollBar
+        {
+            region = 43, 115, 19, 12
+        }
+
+        image scrollBarRightCap
+        {
+            region = 65, 115, 5, 12
+        }
+    }
+
+    imageList activeImages : normalImages
+    {
+        color = #C3D9BFff
+
+        image unchecked
+        {
+            region = 78, 91, 46, 46
+        }
+
+        image checked
+        {
+            region = 78, 91, 46, 46
+        }
+
+        image unselected
+        {
+            region = 127, 91, 46, 46
+        }
+
+        image selected
+        {
+            region = 127, 91, 46, 46
+        }
+    }
+
+    skin mainNormal
+    {
+        border
+        {
+            left = 10
+            right = 10
+            top = 10
+            bottom = 10
+        }
+        
+        region = 1, 1, 74, 74
+        color = #4A8799ff
+    }
+
+    skin mainActive : mainNormal
+    {
+        color = #C3D9BFff
+    }
+
+	skin mainFocus : mainNormal
+	{
+		color = #2A6779ff
+	}
+
+    skin formEntry : mainNormal
+    {
+        region = 78, 1, 46, 46
+        color = #35535Cff
+    }
+
+	skin formFocus : formEntry
+	{
+        color = #15333Cff
+	}
+    
+    skin underliner
+    {
+        border
+        {
+            bottom = 10
+        }
+        
+        region = 4, 82, 68, 5
+        color = #ffffffff
+    }
+
+    skin plusNormal
+    {
+        region = 81, 139, 40, 40
+        color = #4A8799ff
+    }
+
+    skin plusActive : plusNormal
+    {
+        color = #C3D9BFff
+    }
+
+    skin minusNormal
+    {
+        region = 81, 184, 40, 40
+        color = #4A8799ff
+    }
+
+    skin minusActive : minusNormal
+    {
+        color = #C3D9BFff
+    }
+
+    style plus
+    {
+        stateNormal
+        {
+            skin = plusNormal
+        }
+
+        stateActive
+        {
+            skin = plusActive
+        }
+    }
+
+    style minus
+    {
+        stateNormal
+        {
+            skin = minusNormal
+        }
+
+        stateActive
+        {
+            skin = minusActive
+        }
+    }
+
+    style underlined
+    {
+        padding
+        {
+            top = 5
+        }
+    
+        stateNormal
+        {
+            skin = underliner
+            textColor = #ffffffff
+            font = res/common/arial.gpb
+            fontSize = 16
+            textAlignment = ALIGN_BOTTOM_HCENTER
+        }
+    }
+
+    style leftAlignedUnderlined : underlined
+    {
+        stateNormal
+        {
+            textAlignment = ALIGN_TOP_LEFT
+        }
+    }
+	
+	style basicContainer
+	{
+		stateNormal
+        {
+            skin = mainNormal
+            imageList = normalImages
+
+            font = res/common/arial.gpb
+            textColor = #ffffffff
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_HCENTER
+        }
+
+		stateFocus
+		{
+			skin = mainFocus
+		}
+		
+		stateDisabled
+		{
+			opacity = 0.6
+		}
+	}
+
+    style basic : basicContainer
+    {
+        stateActive
+        {
+            imageList = activeImages
+        }
+		
+		stateFocus
+		{
+			skin = mainNormal
+			textColor = #aaa000ff
+		}
+    }
+
+    style topLeftAlignedEntry : basic
+    {
+        stateNormal
+        {
+            skin = formEntry
+            textAlignment = ALIGN_TOP_LEFT
+        }
+
+        stateFocus
+        {
+            skin = formFocus
+        }
+    }
+
+    style buttonStyle : basic
+    {
+        padding
+        {
+            top = -10
+            bottom = -10
+        }
+
+        stateNormal
+        {
+            font = res/common/arial.gpb
+            fontSize = 16
+        }
+
+        stateActive
+        {
+            skin = mainActive
+        }
+    }
+	
+	style buttonHover : buttonStyle
+	{
+		stateHover
+		{
+			textColor = #ff0000ff
+		}
+	}
+
+    style noBorder
+    {
+        stateNormal
+        {
+            imageList = normalImages
+            font = res/common/arial.gpb
+            textColor = #ffffffff
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_HCENTER
+        }
+		
+		stateFocus
+		{
+			textColor = #aaa000ff
+		}
+
+        stateActive
+        {
+            imageList = activeImages
+            textAlignment = ALIGN_VCENTER_HCENTER
+        }
+    }
+
+    style iconNoBorder : noBorder
+    {
+        stateNormal
+        {
+            font = res/common/arial.gpb
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_LEFT
+        }
+
+        stateActive
+        {
+            font = res/common/arial.gpb
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_LEFT
+        }
+    }
+
+    style topLeftNoBorder : iconNoBorder
+    {
+        stateNormal
+        {
+            textAlignment = ALIGN_TOP_LEFT
+        }
+
+        stateActive
+        {
+            textAlignment = ALIGN_TOP_LEFT
+        }
+    }
+
+    style title
+    {
+        stateNormal
+        {
+            textColor = #ffffffff
+            font = res/common/title.gpb
+            fontSize = 24
+            textAlignment = ALIGN_BOTTOM_HCENTER
+        }
+
+        stateActive
+        {
+            textColor = #C3D9BFff
+        }
+    }
+
+    style Form : basicContainer
+    {
+    }
+
+    style Container
+    {
+    }
+
+    style Label : iconNoBorder
+    {
+    }
+
+    style Button : buttonStyle
+    {
+    }
+
+    style CheckBox : iconNoBorder
+    {
+    }
+
+    style RadioButton : iconNoBorder
+    {
+    }
+
+    style TextBox : topLeftAlignedEntry
+    {
+    }
+
+    style Slider : topLeftNoBorder
+    {
+    }
+
+    style Image
+    {
+    }
+}

+ 4 - 3
samples/browser/res/common/forms/formSelect.form

@@ -2,8 +2,8 @@ form formSelect
 {
     layout = LAYOUT_VERTICAL
     alignment = ALIGN_TOP_LEFT
-    width = 200
-    autoHeight = true
+    width = 220
+    autoHeight = AUTO_SIZE_FIT
 	consumeInputEvents = false
 
 	radioButton form0
@@ -11,7 +11,8 @@ form formSelect
 		style = Button
 		text = Basic Controls
 		group = formSelection
-		size = 180, 60
+        autoWidth = AUTO_SIZE_STRETCH
+		height = 60
 		textAlignment = ALIGN_VCENTER_LEFT
 		selected = true
 	}

+ 5 - 3
samples/browser/res/common/terrain/terrain.form

@@ -24,8 +24,8 @@ form terrainForm
 
         padding
         {
-            top = -8
-            left = -8
+            top = -5
+            left = -5
         }
 
         button plusButton
@@ -143,9 +143,11 @@ form terrainForm
 
         label message
         {
+            consumeInputEvents = false
             autoWidth = true
             autoHeight = true
-            fontSize = 30
+            font = res/common/title.gpb
+            fontSize = 24
             textAlignment = ALIGN_VCENTER_HCENTER
         }
     }

BIN
samples/browser/res/common/title.gpb


BIN
samples/browser/res/png/default-theme.png


+ 4 - 1
samples/browser/src/SamplesGame.cpp

@@ -27,6 +27,7 @@ void SamplesGame::initialize()
     getScriptController()->loadScript("res/common/camera.lua");
 
     // Create the selection form
+    Font* titleFont = Font::create("res/common/title.gpb");
     _sampleSelectForm = Form::create("sampleSelect", NULL, Layout::LAYOUT_VERTICAL);
     _sampleSelectForm->setWidth(200);
     _sampleSelectForm->setAutoHeight(Control::AUTO_SIZE_STRETCH);
@@ -37,7 +38,8 @@ void SamplesGame::initialize()
 		Label* categoryLabel = Label::create((*_categories)[i].c_str());
         categoryLabel->setAutoWidth(Control::AUTO_SIZE_FIT);
         categoryLabel->setAutoHeight(Control::AUTO_SIZE_FIT);
-        categoryLabel->setFontSize(24);
+        categoryLabel->setFont(titleFont);
+        categoryLabel->setFontSize(22);
         categoryLabel->setText((*_categories)[i].c_str());
         _sampleSelectForm->addControl(categoryLabel);
         categoryLabel->release();
@@ -57,6 +59,7 @@ void SamplesGame::initialize()
         }
     }
     _sampleSelectForm->setFocus();
+    SAFE_RELEASE(titleFont);
 
     // Disable virtual gamepads.
     unsigned int gamepadCount = getGamepadCount();

+ 1 - 1
samples/browser/src/TextSample.cpp

@@ -18,7 +18,7 @@ std::string _fontNames[] =
 };
 
 TextSample::TextSample()
-    : _form(NULL), _stateBlock(NULL), _size(18), _wrap(true), _ignoreClip(false), _useViewport(true), _rightToLeft(false), _simple(false), _alignment(Font::ALIGN_LEFT),
+    : _form(NULL), _stateBlock(NULL), _size(16), _wrap(true), _ignoreClip(false), _useViewport(true), _rightToLeft(false), _simple(false), _alignment(Font::ALIGN_LEFT),
       _fontsCount(FONT_COUNT), _fontIndex(0), _font(NULL), _viewport(250, 100, 512, 200)
 {
 }

+ 17 - 16
tools/encoder/gameplay-encoder.vcxproj.user

@@ -1,17 +1,18 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LocalDebuggerCommandArguments>-p C:\Users\sgrenier\Documents\Sourcecode\GamePlay\bin\windows\arial.ttf C:\Users\sgrenier\Documents\Sourcecode\GamePlay\samples\browser\res\common\arial.gpb</LocalDebuggerCommandArguments>
-    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
-    <LocalDebuggerEnvironment>
-    </LocalDebuggerEnvironment>
-    <LocalDebuggerWorkingDirectory>.\Debug</LocalDebuggerWorkingDirectory>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LocalDebuggerEnvironment>
-    </LocalDebuggerEnvironment>
-    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
-    <LocalDebuggerCommandArguments>C:\Users\sgrenier\Documents\Sourcecode\GamePlay\samples\browser\res\common\arial.ttf</LocalDebuggerCommandArguments>
-    <LocalDebuggerWorkingDirectory>.\Release</LocalDebuggerWorkingDirectory>
-  </PropertyGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LocalDebuggerCommandArguments>
+    </LocalDebuggerCommandArguments>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+    <LocalDebuggerEnvironment>
+    </LocalDebuggerEnvironment>
+    <LocalDebuggerWorkingDirectory>.\Debug</LocalDebuggerWorkingDirectory>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LocalDebuggerEnvironment>
+    </LocalDebuggerEnvironment>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+    <LocalDebuggerCommandArguments>C:\Users\sgrenier\Documents\Sourcecode\GamePlay\samples\browser\res\common\arial.ttf</LocalDebuggerCommandArguments>
+    <LocalDebuggerWorkingDirectory>.\Release</LocalDebuggerWorkingDirectory>
+  </PropertyGroup>
 </Project>