Explorar o código

Merge branch 'master' of https://github.com/urho3d/Urho3D

Lasse Öörni %!s(int64=12) %!d(string=hai) anos
pai
achega
5f535f7999

+ 2 - 1
Bin/Data/Scripts/Editor/EditorUI.as

@@ -462,7 +462,8 @@ bool Exit()
 
 void HandleExitRequested()
 {
-    Exit();
+    if (!ui.HasModalElement())
+        Exit();
 }
 
 bool PickFile()

+ 3 - 0
Bin/Data/UI/DefaultStyle.xml

@@ -10,6 +10,9 @@
         <attribute name="Hover Image Offset" value="0 16" />
         <attribute name="Pressed Child Offset" value="-1 1" />
     </element>
+    <element type="CommandButton" style="Button" auto="false">
+        <attribute name="Focus Mode" value="Focusable" />
+    </element>
     <element type="CheckBox" style="BorderImage">
         <attribute name="Min Size" value="16 16" />
         <attribute name="Max Size" value="16 16" />

+ 2 - 2
Bin/Data/UI/MessageBox.xml

@@ -35,7 +35,7 @@
 		<attribute name="Layout Mode" value="Horizontal" />
 		<attribute name="Layout Spacing" value="4" />
 		<element />
-		<element type="Button">
+		<element type="Button" style="CommandButton">
 			<attribute name="Name" value="CancelButton" />
 			<attribute name="Min Size" value="70 17" />
 			<attribute name="Max Size" value="70 17" />
@@ -47,7 +47,7 @@
 				<attribute name="Text Alignment" value="Center" />
 			</element>
 		</element>
-		<element type="Button">
+		<element type="Button" style="CommandButton">
 			<attribute name="Name" value="OkButton" />
 			<attribute name="Min Size" value="70 17" />
 			<attribute name="Max Size" value="70 17" />

+ 2 - 4
Source/Engine/UI/Button.cpp

@@ -44,7 +44,6 @@ Button::Button(Context* context) :
     pressed_(false)
 {
     enabled_ = true;
-    focusMode_ = FM_FOCUSABLE;
 }
 
 Button::~Button()
@@ -88,7 +87,7 @@ void Button::Update(float timeStep)
 void Button::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
 {
     IntVector2 offset(IntVector2::ZERO);
-    if (hovering_)
+    if (hovering_ || HasFocus())
         offset += hoverOffset_;
     if (pressed_ || selected_)
         offset += pressedOffset_;
@@ -133,8 +132,7 @@ void Button::OnDragMove(const IntVector2& position, const IntVector2& screenPosi
 
 void Button::OnKey(int key, int buttons, int qualifiers)
 {
-    UI* ui = GetSubsystem<UI>();
-    if (ui->GetFocusElement() == this && (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER || key == KEY_SPACE))
+    if (HasFocus() && (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER || key == KEY_SPACE))
     {
         // Simulate LMB click
         OnClickBegin(IntVector2(), IntVector2(), MOUSEB_LEFT, 0, 0, 0);

+ 1 - 1
Source/Engine/UI/Font.cpp

@@ -668,7 +668,7 @@ FontFace* Font::GetFaceFreeType(int pointSize)
     // Load each of the glyphs to see the sizes & store other information
     int maxWidth = 0;
     int maxHeight = 0;
-    int loadMode = GetSubsystem<UI>()->GetForceAutoHint() ? FT_LOAD_FORCE_AUTOHINT : FT_LOAD_DEFAULT;
+    int loadMode = ui->GetForceAutoHint() ? FT_LOAD_FORCE_AUTOHINT : FT_LOAD_DEFAULT;
     int ascender = face->size->metrics.ascender >> 6;
     int descender = face->size->metrics.descender >> 6;
     

+ 1 - 2
Source/Engine/UI/Menu.cpp

@@ -424,8 +424,7 @@ void Menu::HandleKeyDown(StringHash eventType, VariantMap& eventData)
         acceleratorQualifiers_) && eventData[P_REPEAT].GetBool() == false)
     {
         // Ignore if UI has modal element
-        UI* ui = GetSubsystem<UI>();
-        if (ui->HasModalElement())
+        if (GetSubsystem<UI>()->HasModalElement())
             return;
 
         HandlePressedReleased(eventType, eventData);

+ 1 - 5
Source/Engine/UI/UIElement.cpp

@@ -807,9 +807,6 @@ void UIElement::SetFocus(bool enable)
         enable = false;
 
     UI* ui = GetSubsystem<UI>();
-    if (!ui)
-        return;
-
     if (enable)
     {
         if (ui->GetFocusElement() != this)
@@ -1321,8 +1318,7 @@ float UIElement::GetDerivedOpacity() const
 
 bool UIElement::HasFocus() const
 {
-    UI* ui = GetSubsystem<UI>();
-    return ui ? ui->GetFocusElement() == this : false;
+    return GetSubsystem<UI>()->GetFocusElement() == this;
 }
 
 const String& UIElement::GetAppliedStyle() const

+ 1 - 2
Source/Engine/UI/Window.cpp

@@ -248,8 +248,7 @@ void Window::SetResizeBorder(const IntRect& rect)
 
 void Window::SetModal(bool modal)
 {
-    UI* ui = GetSubsystem<UI>();
-    if (ui->SetModalElement(this, modal))
+    if (GetSubsystem<UI>()->SetModalElement(this, modal))
     {
         modal_ = modal;