Browse Source

[Complex Text Layouts] Add UI mirroring demo.

bruvzg 4 years ago
parent
commit
44daa8ac89

+ 92 - 0
gui/ui_mirroring/LICENSE.Noto.txt

@@ -0,0 +1,92 @@
+This Font Software is licensed under the SIL Open Font License,
+Version 1.1.
+
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font
+creation efforts of academic and linguistic communities, and to
+provide a free and open framework in which fonts may be shared and
+improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply to
+any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software
+components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to,
+deleting, or substituting -- in part or in whole -- any of the
+components of the Original Version, by changing formats or by porting
+the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed,
+modify, redistribute, and sell modified and unmodified copies of the
+Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in
+Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the
+corresponding Copyright Holder. This restriction only applies to the
+primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created using
+the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.

+ 12 - 0
gui/ui_mirroring/README.md

@@ -0,0 +1,12 @@
+# UI Mirroring Demo
+
+A demo showing how to use UI mirroring.
+
+Language: GDScript
+
+Renderer: Vulkan
+
+## Screenshots
+
+![Screenshot](screenshots/ui_mirroring_ar.png)
+![Screenshot](screenshots/ui_mirroring_en.png)

BIN
gui/ui_mirroring/fonts/NotoNaskhArabic-Bold.ttf


BIN
gui/ui_mirroring/fonts/NotoSans-Bold.ttf


BIN
gui/ui_mirroring/icon.png


+ 34 - 0
gui/ui_mirroring/icon.png.import

@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="StreamTexture2D"
+path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://icon.png"
+dest_files=[ "res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/bptc_ldr=0
+compress/normal_map=0
+compress/channel_pack=0
+compress/streamed=false
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/invert_color=false
+process/HDR_as_SRGB=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0

+ 8 - 0
gui/ui_mirroring/noto_font.tres

@@ -0,0 +1,8 @@
+[gd_resource type="Font" load_steps=3 format=2]
+
+[ext_resource path="res://fonts/NotoSans-Bold.ttf" type="FontData" id=1]
+[ext_resource path="res://fonts/NotoNaskhArabic-Bold.ttf" type="FontData" id=2]
+
+[resource]
+data/0 = ExtResource( 1 )
+data/1 = ExtResource( 2 )

+ 15 - 0
gui/ui_mirroring/project.godot

@@ -0,0 +1,15 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+;   [section] ; section goes between []
+;   param=value ; assign values to parameters
+
+config_version=4
+
+[application]
+
+config/name="UI Mirroring Demo"
+run/main_scene="res://ui_mirroring.tscn"
+config/icon="res://icon.png"

BIN
gui/ui_mirroring/screenshots/ui_mirroring_ar.png


BIN
gui/ui_mirroring/screenshots/ui_mirroring_en.png


+ 381 - 0
gui/ui_mirroring/ui_mirroring.tscn

@@ -0,0 +1,381 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://noto_font.tres" type="Font" id=1]
+
+[sub_resource type="GDScript" id=1]
+script/source = "extends Control
+
+func _ready():
+	$Label.text = TranslationServer.get_locale()
+
+func _on_Button_pressed():
+	if TranslationServer.get_locale() != \"ar\":
+		TranslationServer.set_locale(\"ar\")
+	else:
+		TranslationServer.set_locale(\"en\")
+	$Label.text = TranslationServer.get_locale()
+"
+
+[node name="Control" type="Control"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+script = SubResource( 1 )
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="PanelLTR" type="Panel" parent="."]
+self_modulate = Color( 0.494118, 1, 0.737255, 1 )
+anchor_top = 1.0
+anchor_bottom = 1.0
+margin_left = 35.0
+margin_top = -200.0
+margin_right = 275.0
+margin_bottom = -50.0
+layout_direction = 2
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="GridContainer" type="GridContainer" parent="PanelLTR"]
+margin_right = 40.0
+margin_bottom = 40.0
+columns = 3
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="ButtonNW" type="Button" parent="PanelLTR/GridContainer"]
+margin_right = 77.3438
+margin_bottom = 23.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "NorthWest"
+script = null
+
+[node name="ButtonN" type="Button" parent="PanelLTR/GridContainer"]
+margin_left = 81.0
+margin_right = 128.719
+margin_bottom = 23.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "North"
+script = null
+
+[node name="ButtonNE" type="Button" parent="PanelLTR/GridContainer"]
+margin_left = 132.0
+margin_right = 204.859
+margin_bottom = 23.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "NorthEast"
+script = null
+
+[node name="ButtonW" type="Button" parent="PanelLTR/GridContainer"]
+margin_top = 27.0
+margin_right = 77.0
+margin_bottom = 50.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "West"
+script = null
+
+[node name="ButtonCenter" type="Button" parent="PanelLTR/GridContainer"]
+margin_left = 81.0
+margin_top = 27.0
+margin_right = 128.0
+margin_bottom = 50.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "*"
+script = null
+
+[node name="ButtonE" type="Button" parent="PanelLTR/GridContainer"]
+margin_left = 132.0
+margin_top = 27.0
+margin_right = 204.0
+margin_bottom = 50.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Еast"
+script = null
+
+[node name="ButtonSW" type="Button" parent="PanelLTR/GridContainer"]
+margin_top = 54.0
+margin_right = 77.0
+margin_bottom = 77.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "SouthWest"
+script = null
+
+[node name="ButtonS" type="Button" parent="PanelLTR/GridContainer"]
+margin_left = 81.0
+margin_top = 54.0
+margin_right = 128.016
+margin_bottom = 77.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "South"
+script = null
+
+[node name="ButtonSE" type="Button" parent="PanelLTR/GridContainer"]
+margin_left = 132.0
+margin_top = 54.0
+margin_right = 204.156
+margin_bottom = 77.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "SouthEast"
+script = null
+
+[node name="PanelLocale" type="Panel" parent="PanelLTR"]
+self_modulate = Color( 0.819608, 0.254902, 0.254902, 1 )
+margin_left = 20.0
+margin_top = 90.0
+margin_right = 170.0
+margin_bottom = 130.0
+layout_direction = 1
+script = null
+
+[node name="HBoxContainer" type="HBoxContainer" parent="PanelLTR/PanelLocale"]
+margin_right = 107.0
+margin_bottom = 34.0005
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="ButtonPrev" type="Button" parent="PanelLTR/PanelLocale/HBoxContainer"]
+margin_left = -0.34375
+margin_right = 63.0
+margin_bottom = 34.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Previous"
+script = null
+
+[node name="ButtonNext" type="Button" parent="PanelLTR/PanelLocale/HBoxContainer"]
+margin_left = 66.2656
+margin_right = 107.0
+margin_bottom = 34.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Next"
+script = null
+
+[node name="PanelRTL" type="Panel" parent="."]
+self_modulate = Color( 0.0705882, 0.235294, 1, 1 )
+anchor_top = 1.0
+anchor_bottom = 1.0
+margin_left = 33.9999
+margin_top = -200.0
+margin_right = 284.0
+margin_bottom = -50.0
+layout_direction = 3
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="GridContainer" type="GridContainer" parent="PanelRTL"]
+margin_right = 40.0
+margin_bottom = 40.0
+columns = 3
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="ButtonNW" type="Button" parent="PanelRTL/GridContainer"]
+margin_right = 80.0
+margin_bottom = 27.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "الشمال الشرقي"
+script = null
+
+[node name="ButtonN" type="Button" parent="PanelRTL/GridContainer"]
+margin_left = 84.0
+margin_right = 128.0
+margin_bottom = 27.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "الشمال"
+script = null
+
+[node name="ButtonNE" type="Button" parent="PanelRTL/GridContainer"]
+margin_left = 132.0
+margin_right = 218.0
+margin_bottom = 27.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "الشمال الغربي"
+script = null
+
+[node name="ButtonW" type="Button" parent="PanelRTL/GridContainer"]
+margin_top = 31.0
+margin_right = 80.0
+margin_bottom = 58.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "الشرق"
+script = null
+
+[node name="ButtonCenter" type="Button" parent="PanelRTL/GridContainer"]
+margin_left = 84.0
+margin_top = 31.0
+margin_right = 128.0
+margin_bottom = 58.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "*"
+script = null
+
+[node name="ButtonE" type="Button" parent="PanelRTL/GridContainer"]
+margin_left = 132.0
+margin_top = 31.0
+margin_right = 218.0
+margin_bottom = 58.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "الغرب"
+script = null
+
+[node name="ButtonSW" type="Button" parent="PanelRTL/GridContainer"]
+margin_left = -0.59375
+margin_top = 62.0
+margin_right = 80.0
+margin_bottom = 89.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "الجنوب الشرقي"
+script = null
+
+[node name="ButtonS" type="Button" parent="PanelRTL/GridContainer"]
+margin_left = 83.0469
+margin_top = 62.0
+margin_right = 128.0
+margin_bottom = 89.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "الجنوب"
+script = null
+
+[node name="ButtonSE" type="Button" parent="PanelRTL/GridContainer"]
+margin_left = 131.734
+margin_top = 62.0
+margin_right = 218.0
+margin_bottom = 89.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = " 	الجنوب الغربي"
+script = null
+
+[node name="ButtonSwapLocale" type="Button" parent="."]
+margin_left = 670.0
+margin_top = 25.0
+margin_right = 820.0
+margin_bottom = 65.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Swap locale"
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="PanelSide" type="Panel" parent="."]
+anchor_left = 1.0
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_left = -20.0
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="HBoxContainer" type="HBoxContainer" parent="."]
+margin_left = 20.0
+margin_top = 20.0
+margin_right = 140.0
+margin_bottom = 60.0
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="ButtonBack" type="Button" parent="HBoxContainer"]
+margin_left = -0.921875
+margin_right = 40.0
+margin_bottom = 40.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Back"
+script = null
+
+[node name="ButtonFwd" type="Button" parent="HBoxContainer"]
+margin_left = 43.2188
+margin_right = 105.0
+margin_bottom = 40.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Forward"
+script = null
+
+[node name="Label" type="Label" parent="."]
+margin_left = 670.0
+margin_top = 70.0
+margin_right = 820.0
+margin_bottom = 100.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+align = 1
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="LabelInfo" type="Label" parent="."]
+margin_left = 100.0
+margin_top = 100.0
+margin_right = 550.0
+margin_bottom = 300.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Click \"Swap Locale\" button to swap locale between \"en  and \"ar\".
+
+Green tinted controls - LTR layout direction.
+Blue tinted controls - RTL layout direction.
+Red tinted controls - Layout direction from locale.
+Gray (default) controls - Inherited layout direction."
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="OptionButton" type="OptionButton" parent="."]
+margin_left = 129.0
+margin_top = 240.0
+margin_right = 264.0
+margin_bottom = 260.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+script = null
+
+[node name="CheckBox" type="CheckBox" parent="."]
+margin_left = 124.0
+margin_top = 265.0
+margin_right = 184.0
+margin_bottom = 290.0
+custom_fonts/font = ExtResource( 1 )
+custom_font_sizes/font_size = 12
+text = "Test"
+script = null
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[connection signal="pressed" from="ButtonSwapLocale" to="." method="_on_Button_pressed"]