mirror of https://github.com/buggins/dlangui.git
d3d example fixes; DML - double literals fix, DML widgets: alpha property fix
This commit is contained in:
parent
b10cc6f5d8
commit
05442de450
|
|
@ -40,6 +40,7 @@ class UiWidget : VerticalLayout, CellVisitor {
|
||||||
layoutWidth = FILL_PARENT;
|
layoutWidth = FILL_PARENT;
|
||||||
layoutHeight = FILL_PARENT;
|
layoutHeight = FILL_PARENT;
|
||||||
alignment = Align.Center;
|
alignment = Align.Center;
|
||||||
|
try {
|
||||||
parseML(q{
|
parseML(q{
|
||||||
{
|
{
|
||||||
margins: 10
|
margins: 10
|
||||||
|
|
@ -56,28 +57,21 @@ class UiWidget : VerticalLayout, CellVisitor {
|
||||||
layoutHeight: fill
|
layoutHeight: fill
|
||||||
TextWidget { text: "There should be OpenGL animation on background"; textColor: "red"; fontSize: 150%; fontWeight: 800; fontFace: "Arial" }
|
TextWidget { text: "There should be OpenGL animation on background"; textColor: "red"; fontSize: 150%; fontWeight: 800; fontFace: "Arial" }
|
||||||
TextWidget { text: "Do you see it? If no, there is some bug in Mesh rendering code..."; fontSize: 120% }
|
TextWidget { text: "Do you see it? If no, there is some bug in Mesh rendering code..."; fontSize: 120% }
|
||||||
HorizontalLayout {
|
|
||||||
layoutWidth: fill
|
|
||||||
TextWidget { text: "Text 20%"; backgroundColor:"#80FF0000"; layoutWidth: 20% }
|
|
||||||
VerticalLayout {
|
|
||||||
layoutWidth: 30%
|
|
||||||
TextWidget { text: "Text 30%"; backgroundColor:"#80FF00FF" }
|
|
||||||
TextWidget { text: "Text 30%"; backgroundColor:"#8000FFFF" }
|
|
||||||
TextWidget { text: "Text 30%"; backgroundColor:"#8000FFFF" }
|
|
||||||
}
|
|
||||||
TextWidget { text: "Text 50%"; backgroundColor:"#80FFFF00"; layoutWidth: 50% }
|
|
||||||
}
|
|
||||||
// arrange controls as form - table with two columns
|
// arrange controls as form - table with two columns
|
||||||
TableLayout {
|
TableLayout {
|
||||||
colCount: 2
|
colCount: 4
|
||||||
TextWidget { text: "Translation X" }
|
TextWidget { text: "Translation X" }
|
||||||
ScrollBar { id: sbTranslationX; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 300 }
|
ScrollBar { id: sbTranslationX; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 200; alpha: 0.6 }
|
||||||
|
TextWidget { text: "Rotation X" }
|
||||||
|
ScrollBar { id: sbRotationX; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 200; alpha: 0.6 }
|
||||||
TextWidget { text: "Translation Y" }
|
TextWidget { text: "Translation Y" }
|
||||||
ScrollBar { id: sbTranslationY; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 300 }
|
ScrollBar { id: sbTranslationY; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 200; alpha: 0.6 }
|
||||||
|
TextWidget { text: "Rotation Y" }
|
||||||
|
ScrollBar { id: sbRotationY; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 150; alpha: 0.6 }
|
||||||
TextWidget { text: "Translation Z" }
|
TextWidget { text: "Translation Z" }
|
||||||
ScrollBar { id: sbTranslationZ; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 300 }
|
ScrollBar { id: sbTranslationZ; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 150; alpha: 0.6 }
|
||||||
TextWidget { text: "param 1" }
|
TextWidget { text: "Rotation Z" }
|
||||||
EditLine { id: edit1; text: "some text" }
|
ScrollBar { id: sbRotationZ; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 150; alpha: 0.6 }
|
||||||
}
|
}
|
||||||
VSpacer { layoutWeight: 30 }
|
VSpacer { layoutWeight: 30 }
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
|
|
@ -88,6 +82,9 @@ class UiWidget : VerticalLayout, CellVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "", this);
|
}, "", this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Failed to parse dml", e);
|
||||||
|
}
|
||||||
// assign OpenGL drawable to child widget background
|
// assign OpenGL drawable to child widget background
|
||||||
childById("glView").backgroundDrawable = DrawableRef(new OpenGLDrawable(&doDraw));
|
childById("glView").backgroundDrawable = DrawableRef(new OpenGLDrawable(&doDraw));
|
||||||
|
|
||||||
|
|
@ -110,7 +107,7 @@ class UiWidget : VerticalLayout, CellVisitor {
|
||||||
|
|
||||||
int x0 = 0;
|
int x0 = 0;
|
||||||
int y0 = 0;
|
int y0 = 0;
|
||||||
int z0 = 2;
|
int z0 = 0;
|
||||||
|
|
||||||
_mesh = Mesh.createCubeMesh(vec3(x0+ 0, y0 + 0, z0 + 0), 0.3f);
|
_mesh = Mesh.createCubeMesh(vec3(x0+ 0, y0 + 0, z0 + 0), 0.3f);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
@ -201,19 +198,31 @@ class UiWidget : VerticalLayout, CellVisitor {
|
||||||
}
|
}
|
||||||
_cam.setPerspective(rc.width, rc.height, 45.0f, 0.1f, 100.0f);
|
_cam.setPerspective(rc.width, rc.height, 45.0f, 0.1f, 100.0f);
|
||||||
_cam.setIdentity();
|
_cam.setIdentity();
|
||||||
_cam.translate(vec3(-1, -1.5, -1)); // - angle/1000
|
//_cam.translate(vec3(
|
||||||
|
// childById!ScrollBar("sbTranslationX").position / 10.0f,
|
||||||
|
// childById!ScrollBar("sbTranslationY").position / 10.0f,
|
||||||
|
// childById!ScrollBar("sbTranslationZ").position / 10.0f));
|
||||||
|
_cam.translateX(childById!ScrollBar("sbTranslationX").position / 10.0f);
|
||||||
|
_cam.translateY(childById!ScrollBar("sbTranslationY").position / 10.0f);
|
||||||
|
_cam.translateZ(childById!ScrollBar("sbTranslationZ").position / 10.0f);
|
||||||
|
_cam.rotateX(childById!ScrollBar("sbRotationX").position * 2.5f);
|
||||||
|
_cam.rotateY(childById!ScrollBar("sbRotationY").position * 2.5f);
|
||||||
|
_cam.rotateZ(childById!ScrollBar("sbRotationZ").position * 2.5f);
|
||||||
|
//_cam.translate(vec3(-1, -1.5, -1)); // - angle/1000
|
||||||
//_cam.translate(vec3(0, 0, -1.1)); // - angle/1000
|
//_cam.translate(vec3(0, 0, -1.1)); // - angle/1000
|
||||||
//_cam.translate(vec3(0, 3, - angle/1000)); //
|
//_cam.translate(vec3(0, 3, - angle/1000)); //
|
||||||
//_cam.rotateZ(30.0f + angle * 0.3456778);
|
//_cam.rotateZ(30.0f + angle * 0.3456778);
|
||||||
mat4 projectionViewMatrix = _cam.projectionViewMatrix;
|
mat4 projectionViewMatrix = _cam.projectionViewMatrix;
|
||||||
|
|
||||||
|
Log.d("projectionViewMatrix: ", projectionViewMatrix);
|
||||||
|
|
||||||
// ======== Model Matrix ==================
|
// ======== Model Matrix ==================
|
||||||
mat4 modelMatrix;
|
mat4 modelMatrix;
|
||||||
//modelMatrix.scale(0.1f);
|
//modelMatrix.scale(0.1f);
|
||||||
//modelMatrix.rotatez(30.0f + angle * 0.3456778);
|
//modelMatrix.rotatez(30.0f + angle * 0.3456778);
|
||||||
//modelMatrix.rotatey(25);
|
//modelMatrix.rotatey(25);
|
||||||
//modelMatrix.rotatex(15);
|
//modelMatrix.rotatex(15);
|
||||||
modelMatrix.rotatey(angle);
|
//modelMatrix.rotatey(angle);
|
||||||
//modelMatrix.rotatex(angle * 1.98765f);
|
//modelMatrix.rotatex(angle * 1.98765f);
|
||||||
|
|
||||||
mat4 projectionViewModelMatrix = projectionViewMatrix * modelMatrix;
|
mat4 projectionViewModelMatrix = projectionViewMatrix * modelMatrix;
|
||||||
|
|
|
||||||
|
|
@ -316,14 +316,14 @@ class Tokenizer {
|
||||||
_token.type = TokenType.floating;
|
_token.type = TokenType.floating;
|
||||||
dchar ch = peekChar();
|
dchar ch = peekChar();
|
||||||
// floating point
|
// floating point
|
||||||
int div = 0;
|
int div = 1;
|
||||||
int n2 = 0;
|
int n2 = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ch = skipChar();
|
ch = skipChar();
|
||||||
if (!isNum(ch))
|
if (!isNum(ch))
|
||||||
break;
|
break;
|
||||||
n2 = n2 * 10 + (ch - '0');
|
n2 = n2 * 10 + (ch - '0');
|
||||||
div++;
|
div *= 10;
|
||||||
}
|
}
|
||||||
_token.floatvalue = cast(double)n + (div > 0 ? cast(double)n2 / div : 0.0);
|
_token.floatvalue = cast(double)n + (div > 0 ? cast(double)n2 / div : 0.0);
|
||||||
string suffix;
|
string suffix;
|
||||||
|
|
|
||||||
|
|
@ -1580,7 +1580,7 @@ public:
|
||||||
bool setDoubleProperty(string name, double value) {
|
bool setDoubleProperty(string name, double value) {
|
||||||
if (name.equal("alpha")) {
|
if (name.equal("alpha")) {
|
||||||
int n = cast(int)(value * 255);
|
int n = cast(int)(value * 255);
|
||||||
setIntProperty(name, n);
|
return setIntProperty(name, n);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue