Browse Source

Minor consistency fix in Text::GetFont(), the filename version. Move UIComponent getters to implementation to avoid requiring class definitions.

Lasse Öörni 8 years ago
parent
commit
a7dc56b5a3

+ 1 - 1
Source/Urho3D/AngelScript/UIAPI.cpp

@@ -378,7 +378,7 @@ static void RegisterText(asIScriptEngine* engine)
     engine->RegisterEnumValue("TextEffect", "TE_STROKE", TE_STROKE);
     engine->RegisterEnumValue("TextEffect", "TE_STROKE", TE_STROKE);
 
 
     RegisterUIElement<Text>(engine, "Text");
     RegisterUIElement<Text>(engine, "Text");
-    engine->RegisterObjectMethod("Text", "bool SetFont(const String&in, int)", asMETHODPR(Text, SetFont, (const String&, int), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Text", "bool SetFont(const String&in, float)", asMETHODPR(Text, SetFont, (const String&, float), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "bool SetFont(Font@+, float)", asMETHODPR(Text, SetFont, (Font*, float), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "bool SetFont(Font@+, float)", asMETHODPR(Text, SetFont, (Font*, float), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "void SetSelection(uint, uint arg1 = M_MAX_UNSIGNED)", asMETHOD(Text, SetSelection), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "void SetSelection(uint, uint arg1 = M_MAX_UNSIGNED)", asMETHOD(Text, SetSelection), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "void ClearSelection()", asMETHOD(Text, ClearSelection), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "void ClearSelection()", asMETHOD(Text, ClearSelection), asCALL_THISCALL);

+ 1 - 1
Source/Urho3D/UI/Text.cpp

@@ -267,7 +267,7 @@ void Text::OnIndentSet()
     charLocationsDirty_ = true;
     charLocationsDirty_ = true;
 }
 }
 
 
-bool Text::SetFont(const String& fontName, int size)
+bool Text::SetFont(const String& fontName, float size)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     return SetFont(cache->GetResource<Font>(fontName), size);
     return SetFont(cache->GetResource<Font>(fontName), size);

+ 1 - 1
Source/Urho3D/UI/Text.h

@@ -94,7 +94,7 @@ public:
     virtual void OnIndentSet();
     virtual void OnIndentSet();
 
 
     /// Set font by looking from resource cache by name and font size. Return true if successful.
     /// Set font by looking from resource cache by name and font size. Return true if successful.
-    bool SetFont(const String& fontName, int size = DEFAULT_FONT_SIZE);
+    bool SetFont(const String& fontName, float size = DEFAULT_FONT_SIZE);
     /// Set font and font size. Return true if successful.
     /// Set font and font size. Return true if successful.
     bool SetFont(Font* font, float size = DEFAULT_FONT_SIZE);
     bool SetFont(Font* font, float size = DEFAULT_FONT_SIZE);
     /// Set font size only while retaining the existing font. Return true if successful.
     /// Set font size only while retaining the existing font. Return true if successful.

+ 16 - 0
Source/Urho3D/UI/UIComponent.cpp

@@ -71,6 +71,22 @@ void UIComponent::RegisterObject(Context* context)
     context->RegisterFactory<UIComponent>();
     context->RegisterFactory<UIComponent>();
 }
 }
 
 
+UIElement* UIComponent::GetRoot() const
+{
+    return rootElement_;
+}
+
+Material* UIComponent::GetMaterial() const
+{
+    return material_;
+}
+
+Texture2D* UIComponent::GetTexture() const
+{
+    return texture_;
+}
+
+
 void UIComponent::OnNodeSet(Node* node)
 void UIComponent::OnNodeSet(Node* node)
 {
 {
     if (node)
     if (node)

+ 7 - 8
Source/Urho3D/UI/UIComponent.h

@@ -21,10 +21,8 @@
 //
 //
 #pragma once
 #pragma once
 
 
-
 #include "../Scene/Component.h"
 #include "../Scene/Component.h"
 
 
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -39,18 +37,19 @@ class VertexBuffer;
 class URHO3D_API UIComponent : public Component
 class URHO3D_API UIComponent : public Component
 {
 {
     URHO3D_OBJECT(UIComponent, Component);
     URHO3D_OBJECT(UIComponent, Component);
+
 public:
 public:
     /// Construct.
     /// Construct.
     UIComponent(Context* context);
     UIComponent(Context* context);
     /// Register object factory.
     /// Register object factory.
     static void RegisterObject(Context* context);
     static void RegisterObject(Context* context);
 
 
-    /// Get UIElement.
-    UIElement* GetRoot() { return rootElement_; }
-    /// Get material which will be used for rendering UI texture.
-    Material* GetMaterial() { return material_; }
-    /// Get texture which will be used for rendering UI to.
-    Texture2D* GetTexture() { return texture_; }
+    /// Return UIElement.
+    UIElement* GetRoot() const;
+    /// Return material which will be used for rendering UI texture.
+    Material* GetMaterial() const;
+    /// Return texture which will be used for rendering UI to.
+    Texture2D* GetTexture() const;
 
 
 protected:
 protected:
     /// Material that is set to the model.
     /// Material that is set to the model.