Browse Source

Merge branch 'next' of git://github.com/blackberry/GamePlay into next

Rcmaniac25 12 years ago
parent
commit
03f4441c74

+ 3 - 0
gameplay/src/Container.cpp

@@ -502,7 +502,10 @@ void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needs
     }
 
     if (!_visible)
+    {
+        _dirty = false;
         return;
+    }
 
     spriteBatch->start();
     Control::drawBorder(spriteBatch, clip);

+ 3 - 0
gameplay/src/Control.cpp

@@ -1132,7 +1132,10 @@ void Control::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsCl
     }
 
     if (!_visible)
+    {
+        _dirty = false;
         return;
+    }
 
     spriteBatch->start();
     drawBorder(spriteBatch, clip);

+ 7 - 1
gameplay/src/RenderState.cpp

@@ -400,7 +400,13 @@ const Vector3& RenderState::autoBindingGetLightDirection() const
 {
     static Vector3 down(0, -1, 0);
     Scene* scene = _nodeBinding ? _nodeBinding->getScene() : NULL;
-    return scene ? scene->getLightDirection() : down;
+    if (scene) {
+        static Vector3 lightDirection;
+        lightDirection.set(scene->getLightDirection());
+        _nodeBinding->getViewMatrix().transformVector(&lightDirection);
+        return lightDirection;
+    }
+    return down;
 }
 
 void RenderState::bind(Pass* pass)

+ 3 - 0
gameplay/src/Slider.cpp

@@ -494,7 +494,10 @@ void Slider::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsCle
     }
 
     if (!_visible)
+    {
+        _dirty = false;
         return;
+    }
 
     spriteBatch->start();
     drawBorder(spriteBatch, clip);

+ 17 - 6
gameplay/src/TextBox.cpp

@@ -130,16 +130,27 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                 }
                 case Keyboard::KEY_HOME:
                 {
-                    // TODO: Move cursor to beginning of line.
-                    // This only works for left alignment...
-                        
-                    //_caretLocation.x = _viewportClipBounds.x;
-                    //_dirty = true;
+                    Font* font = getFont(_state);
+                    GP_ASSERT(font);
+                    unsigned int fontSize = getFontSize(_state);
+                    Font::Justify textAlignment = getTextAlignment(_state);
+                    bool rightToLeft = getTextRightToLeft(_state);
+                    font->getLocationAtIndex(getDisplayedText().c_str(), _textBounds, fontSize, &_caretLocation, 0,
+                        textAlignment, true, rightToLeft);
+                    _dirty = true;
                     break;
                 }
                 case Keyboard::KEY_END:
                 {
-                    // TODO: Move cursor to end of line.
+                    Font* font = getFont(_state);
+                    GP_ASSERT(font);
+                    unsigned int fontSize = getFontSize(_state);
+                    Font::Justify textAlignment = getTextAlignment(_state);
+                    bool rightToLeft = getTextRightToLeft(_state);
+                    const std::string displayedText = getDisplayedText();
+                    font->getLocationAtIndex(displayedText.c_str(), _textBounds, fontSize, &_caretLocation, displayedText.size(),
+                        textAlignment, true, rightToLeft);
+                    _dirty = true;
                     break;
                 }
                 case Keyboard::KEY_DELETE: