소스 검색

More work on default theme.

Steve Grenier 12 년 전
부모
커밋
cd7537847e

+ 9 - 9
gameplay/src/Form.cpp

@@ -58,15 +58,6 @@ Form::~Form()
     }
 }
 
-Form* Form::create(const char* id, Theme::Style* style, Layout::Type layoutType)
-{
-    Form* form = new Form();
-    form->_id = id ? id : "";
-    form->_layout = createLayout(layoutType);
-    form->initialize("Form", style, NULL);
-    return form;
-}
-
 Form* Form::create(const char* url)
 {
     Form* form = new Form();
@@ -119,6 +110,15 @@ Form* Form::create(const char* url)
     return form;
 }
 
+Form* Form::create(const char* id, Theme::Style* style, Layout::Type layoutType)
+{
+	Form* form = new Form();
+	form->_id = id ? id : "";
+	form->_layout = createLayout(layoutType);
+	form->initialize("Form", style, NULL);
+	return form;
+}
+
 void Form::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
     Container::initialize(typeName, style, properties);

+ 2 - 2
gameplay/src/Form.h

@@ -79,8 +79,8 @@ public:
 	 * form will inherit the theme that contains the form's style.
      *
      * @param id The Form's ID.
-     * @param style The Form's custom style (optional).
-     * @param layoutType The form's layout type.
+     * @param style The Form's custom style (optional - may be NULL).
+	 * @param layoutType The form's layout type (optional).
      *
      * @return The new Form.
      * @script{create}

+ 3 - 3
gameplay/src/Properties.cpp

@@ -84,7 +84,7 @@ Properties* Properties::create(const char* url)
     std::auto_ptr<Stream> stream(FileSystem::open(fileString.c_str()));
     if (stream.get() == NULL)
     {
-        GP_ERROR("Failed to open file '%s'.", fileString.c_str());
+        GP_WARN("Failed to open file '%s'.", fileString.c_str());
         return NULL;
     }
 
@@ -961,7 +961,7 @@ bool Properties::getColor(const char* name, Vector4* out) const
             valueString[0] != '#')
         {
             // Not a color string.
-            GP_ERROR("Error attempting to parse property '%s' as an RGBA color (not specified as a color string).", name);
+            GP_WARN("Error attempting to parse property '%s' as an RGBA color (not specified as a color string).", name);
             out->set(0.0f, 0.0f, 0.0f, 0.0f);
             return false;
         }
@@ -970,7 +970,7 @@ bool Properties::getColor(const char* name, Vector4* out) const
         unsigned int color;
         if (sscanf(valueString+1, "%x", &color) != 1)
         {
-            GP_ERROR("Error attempting to parse property '%s' as an RGBA color.", name);
+            GP_WARN("Error attempting to parse property '%s' as an RGBA color.", name);
             out->set(0.0f, 0.0f, 0.0f, 0.0f);
             return false;
         }

+ 3 - 1
gameplay/src/Theme.cpp

@@ -262,7 +262,9 @@ Theme* Theme::create(const char* url)
 
             // At least the OVERLAY_NORMAL is required.
             if (!normal)
-                GP_ERROR("All themes require the normal state overlay to be defined.");
+            {
+                normal = Theme::Style::Overlay::create();
+            }
 
             space->rewind();
             innerSpace = space->getNextNamespace();

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


+ 105 - 8
samples/browser/res/common/default.theme

@@ -53,17 +53,20 @@ theme mainMenu
 
         image scrollBarTopCap
         {
-            region = 0, 99, 12, 5
+            //region = 0, 99, 12, 5
+            region = 0, 43, 17, 10
         }
 
         image verticalScrollBar
         {
-            region = 0, 104, 12, 19
+            //region = 0, 104, 12, 19
+            region = 0, 53, 17, 16
         }
 
         image scrollBarBottomCap
         {
-            region = 0, 138, 12, 5
+            //region = 0, 138, 12, 5
+            region = 0, 69, 17, 10
         }
 
         image scrollBarLeftCap
@@ -107,6 +110,104 @@ theme mainMenu
         }
     }
 
+    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 = 18
+            textAlignment = ALIGN_VCENTER_LEFT
+        }
+    }
+
+    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
+        }
+
+        stateDisabled
+		{
+			opacity = 0.6
+		}
+    }
+
+
+
+
+
+
+
     skin mainNormal
     {
         border
@@ -389,8 +490,4 @@ theme mainMenu
             textColor = #C3D9BFff
         }
     }
-
-	style form : basic
-	{
-	}
-}
+}

+ 8 - 0
samples/browser/res/common/gamepad.theme

@@ -79,4 +79,12 @@ theme gamepad
 			skin = buttonBActiveSkin
 		}
 	}
+
+    style form
+    {
+    }
+
+    style container
+    {
+    }
 }

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


+ 2 - 2
samples/browser/src/FormsSample.cpp

@@ -95,7 +95,7 @@ void FormsSample::initialize()
     form5Button->addListener(this, Control::Listener::CLICK);
     for (unsigned int i = 0; i < _formFiles.size(); i++)
     {
-        Form* form = Form::create(_formFiles[i]);
+		Form* form = Form::create(_formFiles[i]);
         form->setEnabled(false);
         _forms.push_back(form);
     }
@@ -155,7 +155,7 @@ void FormsSample::formChanged()
 
 void FormsSample::createSampleForm(Theme* theme)
 {
-    Form* form = Form::create("testForm", theme->getStyle("basicContainer"));
+    Form* form = Form::create("testForm", theme->getStyle("basicContainer"), Layout::LAYOUT_ABSOLUTE);
     form->setSize(600, 600);
 
     Label* label = Label::create("testLabel", theme->getStyle("iconNoBorder"));

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

@@ -58,7 +58,7 @@ void InputSample::initialize()
     _formNode = Node::create("Form");
     _formNodeParent->addChild(_formNode);
     Theme* theme = _inputSampleControls->getTheme();
-    Form* form = Form::create("testForm", theme->getStyle("basicContainer"));
+    Form* form = Form::create("testForm", theme->getStyle("basicContainer"), Layout::LAYOUT_ABSOLUTE);
     form->setSize(225, 100);
     Label* label = Label::create("sensorLabel", theme->getStyle("iconNoBorder"));
     label->setPosition(25, 15);

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

@@ -96,7 +96,7 @@ void LightSample::initialize()
 	_model->setMaterial(_lighting);
 
     // Create and initialize ui form
-	_form = Form::create("res/common/light.form");
+    _form = Form::create("res/common/light.form");
     _properties = static_cast<Container*>(_form->getControl("lightProperties"));
 	_redSlider = static_cast<Slider*>(_form->getControl("redSlider"));
 	_redSlider->addListener(this, Control::Listener::VALUE_CHANGED);

+ 17 - 23
samples/browser/src/SamplesGame.cpp

@@ -26,30 +26,19 @@ void SamplesGame::initialize()
     // Load camera script
     getScriptController()->loadScript("res/common/camera.lua");
 
-    // Construct a form for selecting which sample to run.
-    Theme* theme = Theme::create("res/common/default.theme");
-    Theme::Style* formStyle = theme->getStyle("basicContainer");
-    Theme::Style* buttonStyle = theme->getStyle("buttonStyle");
-    Theme::Style* titleStyle = theme->getStyle("title");
-
-    // Note: this calls addRef() on formStyle's Theme, which we created above.
-    _sampleSelectForm = Form::create("sampleSelect", formStyle, Layout::LAYOUT_VERTICAL);
-    theme->release();   // So we can release it once we're done creating forms with it.
-
-    _sampleSelectForm->setAutoHeight(true);
-    _sampleSelectForm->setWidth(200.0f);
+    // Create the selection form
+    _sampleSelectForm = Form::create("sampleSelect", NULL, Layout::LAYOUT_VERTICAL);
+    _sampleSelectForm->setWidth(200);
+    _sampleSelectForm->setAutoHeight(Control::AUTO_SIZE_STRETCH);
     _sampleSelectForm->setScroll(Container::SCROLL_VERTICAL);
-    _sampleSelectForm->setConsumeInputEvents(true);
-
     const size_t size = _samples->size();
     for (size_t i = 0; i < size; ++i)
     {
-        Label* categoryLabel = Label::create((*_categories)[i].c_str(), titleStyle);
-        categoryLabel->setAutoWidth(true);
-        categoryLabel->setTextAlignment(Font::ALIGN_BOTTOM_LEFT);
-        categoryLabel->setHeight(40);
+		Label* categoryLabel = Label::create((*_categories)[i].c_str());
+        categoryLabel->setAutoWidth(Control::AUTO_SIZE_FIT);
+        categoryLabel->setAutoHeight(Control::AUTO_SIZE_FIT);
+        categoryLabel->setFontSize(28);
         categoryLabel->setText((*_categories)[i].c_str());
-        categoryLabel->setConsumeInputEvents(false);
         _sampleSelectForm->addControl(categoryLabel);
         categoryLabel->release();
 
@@ -58,10 +47,10 @@ void SamplesGame::initialize()
         for (size_t j = 0; j < listSize; ++j)
         {
             SampleRecord sampleRecord = list[j];
-            Button* sampleButton = Button::create(sampleRecord.title.c_str(), buttonStyle);
+			Button* sampleButton = Button::create(sampleRecord.title.c_str());
             sampleButton->setText(sampleRecord.title.c_str());
-            sampleButton->setAutoWidth(true);
-            sampleButton->setHeight(60);      // Tall enough to touch easily on a BB10 device.
+            sampleButton->setAutoWidth(Control::AUTO_SIZE_STRETCH);
+            sampleButton->setAutoHeight(Control::AUTO_SIZE_FIT);
             sampleButton->addListener(this, Control::Listener::CLICK);
             _sampleSelectForm->addControl(sampleButton);
             sampleButton->release();
@@ -125,8 +114,13 @@ void SamplesGame::render(float elapsedTime)
         return;
     }
     // Clear the color and depth buffers
-    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
+    clear(CLEAR_COLOR_DEPTH, Vector4(0.46f, 0.46f, 0.46f, 1.0f), 1.0f, 0);
     _sampleSelectForm->draw();
+
+    static Font* __font = Font::create("res/common/arial.gpb");
+    __font->start();
+    __font->drawText("Draw Triangle", 220, 20, Vector4::one());
+    __font->finish();
 }
 
 void SamplesGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)