Browse Source

Various sample tweaks and fixes.

Michael Ragazzon 4 years ago
parent
commit
e435d9c915

+ 8 - 7
Samples/assets/invader.rcss

@@ -169,7 +169,7 @@ div#title_bar div#icon
 {
 	position: absolute;
 	left: 20dp;
-	top: 2dp;
+	top: -4dp;
 	
 	width: 51dp;
 	height: 39dp;
@@ -180,7 +180,7 @@ div#title_bar span
 {
 	padding-left: 85dp;
 	padding-right: 25dp;
-	padding-top: 17dp;
+	padding-top: 23dp;
 	padding-bottom: 51dp;
 
 	font-size: 20dp;
@@ -257,9 +257,9 @@ input.submit
 	display: inline-block;
 
 	width: 159dp;
-	height: 35dp;
+	height: 33dp;
 
-	padding-top: 10dp;
+	padding-top: 12dp;
 	vertical-align: -18dp;
 
 	font-size: 16dp;
@@ -298,7 +298,7 @@ input.text, input.password
 {
 	box-sizing: border-box;
 	height: 31dp;
-	padding: 10dp 10dp 0;
+	padding: 11dp 10dp 0;
 	decorator: tiled-horizontal( text-l, text-c, auto ); /* Right becomes mirrored left */
 	cursor: text;
 }
@@ -327,6 +327,7 @@ datagrid input.text, table input.text
 	height: 18dp;
 	margin: 0;
 	padding: 0 5dp;
+	line-height: 1.0;
 
 	border-width: 1dp;
 	border-color: black;
@@ -352,8 +353,8 @@ dataselect selectvalue
 	width: auto;
 	margin-right: 30dp;
 	
-	height: 26dp;
-	padding: 11dp 10dp 0dp 10dp;
+	height: 25dp;
+	padding: 12dp 10dp 0dp 10dp;
 
 	decorator: image( selectvalue  );
 }

+ 16 - 4
Samples/basic/sdl2/src/main.cpp

@@ -94,10 +94,22 @@ int main(int /*argc*/, char** /*argv*/)
 	if (!Rml::Initialise())
 		return 1;
 
-	Rml::LoadFontFace("assets/Delicious-Bold.otf");
-	Rml::LoadFontFace("assets/Delicious-BoldItalic.otf");
-	Rml::LoadFontFace("assets/Delicious-Italic.otf");
-	Rml::LoadFontFace("assets/Delicious-Roman.otf");
+	struct FontFace {
+		Rml::String filename;
+		bool fallback_face;
+	};
+	FontFace font_faces[] = {
+		{ "LatoLatin-Regular.ttf",    false },
+		{ "LatoLatin-Italic.ttf",     false },
+		{ "LatoLatin-Bold.ttf",       false },
+		{ "LatoLatin-BoldItalic.ttf", false },
+		{ "NotoEmoji-Regular.ttf",    true  },
+	};
+
+	for (const FontFace& face : font_faces)
+	{
+		Rml::LoadFontFace("assets/" + face.filename, face.fallback_face);
+	}
 
 	Rml::Context* Context = Rml::CreateContext("default",
 		Rml::Vector2i(window_width, window_height));

+ 16 - 4
Samples/basic/sfml2/src/main.cpp

@@ -104,11 +104,23 @@ int main(int /*argc*/, char** /*argv*/)
 	if (!Rml::Initialise())
 		return 1;
 
-	Rml::LoadFontFace("assets/Delicious-Bold.otf");
-	Rml::LoadFontFace("assets/Delicious-BoldItalic.otf");
-	Rml::LoadFontFace("assets/Delicious-Italic.otf");
-	Rml::LoadFontFace("assets/Delicious-Roman.otf");
+	struct FontFace {
+		Rml::String filename;
+		bool fallback_face;
+	};
+	FontFace font_faces[] = {
+		{ "LatoLatin-Regular.ttf",    false },
+		{ "LatoLatin-Italic.ttf",     false },
+		{ "LatoLatin-Bold.ttf",       false },
+		{ "LatoLatin-BoldItalic.ttf", false },
+		{ "NotoEmoji-Regular.ttf",    true  },
+	};
 
+	for (const FontFace& face : font_faces)
+	{
+		Rml::LoadFontFace("assets/" + face.filename, face.fallback_face);
+	}
+	
 	Rml::Context* Context = Rml::CreateContext("default",
 		Rml::Vector2i(MyWindow.getSize().x, MyWindow.getSize().y));
 

+ 6 - 4
Samples/invaders/src/DecoratorStarfield.cpp

@@ -29,6 +29,7 @@
 #include "DecoratorStarfield.h"
 #include <RmlUi/Core/Math.h>
 #include <RmlUi/Core/Element.h>
+#include <RmlUi/Core/ElementUtilities.h>
 #include <Shell.h>
 #include <ShellOpenGL.h>
 #include "GameDetails.h"
@@ -96,15 +97,16 @@ void DecoratorStarfield::ReleaseElementData(Rml::DecoratorDataHandle element_dat
 }
 
 // Called to render the decorator on an element.
-void DecoratorStarfield::RenderElement(Rml::Element* RMLUI_UNUSED_PARAMETER(element), Rml::DecoratorDataHandle element_data) const
+void DecoratorStarfield::RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const
 {
-	RMLUI_UNUSED(element);
-
 	StarField* star_field = reinterpret_cast<StarField*>(element_data);
 	star_field->Update();
 
+	const float dp_ratio = Rml::ElementUtilities::GetDensityIndependentPixelRatio(element);
+	const float point_size = Rml::Math::RoundUpFloat(2.f * dp_ratio);
+
 	glDisable(GL_TEXTURE_2D);
-	glPointSize(2);
+	glPointSize(point_size);
 	glBegin(GL_POINTS);
 
 	for (size_t i = 0; i < star_field->star_layers.size(); i++)

+ 6 - 4
Samples/luainvaders/src/DecoratorStarfield.cpp

@@ -29,6 +29,7 @@
 #include "DecoratorStarfield.h"
 #include <RmlUi/Core/Math.h>
 #include <RmlUi/Core/Element.h>
+#include <RmlUi/Core/ElementUtilities.h>
 #include <Shell.h>
 #include <ShellOpenGL.h>
 #include "GameDetails.h"
@@ -96,15 +97,16 @@ void DecoratorStarfield::ReleaseElementData(Rml::DecoratorDataHandle element_dat
 }
 
 // Called to render the decorator on an element.
-void DecoratorStarfield::RenderElement(Rml::Element* RMLUI_UNUSED_PARAMETER(element), Rml::DecoratorDataHandle element_data) const
+void DecoratorStarfield::RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const
 {
-	RMLUI_UNUSED(element);
-
 	StarField* star_field = (StarField*)element_data;
 	star_field->Update();
 
+	const float dp_ratio = Rml::ElementUtilities::GetDensityIndependentPixelRatio(element);
+	const float point_size = Rml::Math::RoundUpFloat(2.f * dp_ratio);
+
 	glDisable(GL_TEXTURE_2D);
-	glPointSize(2);
+	glPointSize(point_size);
 	glBegin(GL_POINTS);
 
 	for (size_t i = 0; i < star_field->star_layers.size(); i++)

+ 5 - 1
Samples/shell/src/win32/InputWin32.cpp

@@ -105,7 +105,11 @@ void InputWin32::ProcessWindowsEvent(HWND window, UINT message, WPARAM w_param,
 			}
 			else if (key_identifier == Rml::Input::KI_0 && key_modifier_state & Rml::Input::KM_CTRL)
 			{
-				context->SetDensityIndependentPixelRatio(key_modifier_state == Rml::Input::KM_SHIFT ? 1.f : Shell::GetDensityIndependentPixelRatio());
+				context->SetDensityIndependentPixelRatio(Shell::GetDensityIndependentPixelRatio());
+			}
+			else if (key_identifier == Rml::Input::KI_1 && key_modifier_state & Rml::Input::KM_CTRL)
+			{
+				context->SetDensityIndependentPixelRatio(1.f);
 			}
 			else if (key_identifier == Rml::Input::KI_OEM_MINUS && key_modifier_state & Rml::Input::KM_CTRL)
 			{