diff --git a/src/dlangui/dialogs/filedlg.d b/src/dlangui/dialogs/filedlg.d index bb0c6f3f..7e1219eb 100644 --- a/src/dlangui/dialogs/filedlg.d +++ b/src/dlangui/dialogs/filedlg.d @@ -216,8 +216,13 @@ class FileDialog : Dialog, CustomGridCellAdapter { else resname = "text-plain"; _fileList.setCellText(0, i, toUTF32(resname)); - sz = to!string(_entries[i].size); - date = "2014-01-01 00:00:00"; + double size = _entries[i].size; + import std.format : format; + sz = size < 1024 ? to!string(size) ~ " B" : + (size < 1024*1024 ? "%.1f".format(size/1024) ~ " KB" : + (size < 1024*1024*1024 ? "%.1f".format(size/(1024*1024)) ~ " MB" : + "%.1f".format(size/(1024*1024*1024)) ~ " GB")); + date = _entries[i].timeLastModified.toSimpleString(); } _fileList.setCellText(2, i, toUTF32(sz)); _fileList.setCellText(3, i, toUTF32(date)); diff --git a/src/dlangui/graphics/glsupport.d b/src/dlangui/graphics/glsupport.d index 7c9d3b45..fc3694e3 100644 --- a/src/dlangui/graphics/glsupport.d +++ b/src/dlangui/graphics/glsupport.d @@ -45,20 +45,6 @@ derelict.util.exception.ShouldThrow gl3MissingSymFunc( string symName ) { return derelict.util.exception.ShouldThrow.No; } -// utility function to fill 4-float array of vertex colors with converted CR 32bit color -private void LVGLFillColor(uint color, float * buf, int count) { - float r = ((color >> 16) & 255) / 255.0f; - float g = ((color >> 8) & 255) / 255.0f; - float b = ((color >> 0) & 255) / 255.0f; - float a = (((color >> 24) & 255) ^ 255) / 255.0f; - for (int i=0; i= 0 && vertexLocation >= 0 && colAttrLocation >= 0; + return matrixLocation >= 0 && vertexLocation >= 0 && colAttrLocation >= 0; } bool execute(float[] vertices, float[] colors) { @@ -329,9 +295,6 @@ class SolidFillProgram : GLProgram { checkgl!glDrawArrays(GL_TRIANGLES, 0, cast(int)vertices.length/3); - glDisableVertexAttribArray(vertexLocation); - glDisableVertexAttribArray(colAttrLocation); - afterExecute(); destroy(vbo); @@ -359,9 +322,6 @@ class LineProgram : SolidFillProgram { checkgl!glDrawArrays(GL_LINES, 0, cast(int)vertices.length/3); - glDisableVertexAttribArray(vertexLocation); - glDisableVertexAttribArray(colAttrLocation); - afterExecute(); destroy(vbo); @@ -408,7 +368,7 @@ class TextureProgram : SolidFillProgram { return res && texCoordLocation >= 0; } - bool execute(float[] vertices, float[] texcoords, float[] colors, Tex2D texture, bool linear) { + bool execute(float[] vertices, float[] colors, float[] texcoords, Tex2D texture, bool linear) { if(!check()) return false; beforeExecute(); @@ -484,15 +444,8 @@ class FontProgram : SolidFillProgram { } override void beforeExecute() { - glEnable(GL_BLEND); - checkgl!glDisable(GL_CULL_FACE); - checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //glBlendFunc(GL_ONE, GL_SRC_COLOR); - //glBlendFunc(GL_ONE, GL_SRC_COLOR); + super.beforeExecute(); //glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR); - //glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_SRC_COLOR); - bind(); - checkgl!glUniformMatrix4fv(matrixLocation, 1, false, glSupport.qtmatrix.ptr); } override void afterExecute() { @@ -500,7 +453,7 @@ class FontProgram : SolidFillProgram { super.afterExecute(); } - bool execute(float[] vertices, float[] texcoords, float[] colors, Tex2D texture, bool linear) { + bool execute(float[] vertices, float[] colors, float[] texcoords, Tex2D texture, bool linear) { if(!check()) return false; beforeExecute(); @@ -523,10 +476,6 @@ class FontProgram : SolidFillProgram { checkgl!glDrawArrays(GL_TRIANGLES, 0, cast(int)vertices.length/3); - glDisableVertexAttribArray(vertexLocation); - glDisableVertexAttribArray(colAttrLocation); - glDisableVertexAttribArray(texCoordLocation); - afterExecute(); destroy(vbo); @@ -537,6 +486,26 @@ class FontProgram : SolidFillProgram { } } + +struct Color +{ + float r, g, b, a; +} + +// utility function to fill 4-float array of vertex colors with converted CR 32bit color +private void FillColor(uint color, Color[] buf_slice) { + float r = ((color >> 16) & 255) / 255.0; + float g = ((color >> 8) & 255) / 255.0; + float b = ((color >> 0) & 255) / 255.0; + float a = (((color >> 24) & 255) ^ 255) / 255.0; + foreach(ref col; buf_slice) { + col.r = r; + col.g = g; + col.b = b; + col.a = a; + } +} + __gshared GLSupport _glSupport; @property GLSupport glSupport() { if (!_glSupport) { @@ -638,9 +607,9 @@ class GLSupport { } void drawLine(Point p1, Point p2, uint color1, uint color2) { - float[2 * 4] colors; - LVGLFillColor(color1, colors.ptr + 4*0, 1); - LVGLFillColor(color2, colors.ptr + 4*1, 1); + Color[2] colors; + FillColor(color1, colors[0..1]); + FillColor(color2, colors[1..2]); float x0 = cast(float)(p1.x); float y0 = cast(float)(bufferDy-p1.y); float x1 = cast(float)(p2.x); @@ -657,21 +626,20 @@ class GLSupport { x1,y1,Z_2D ]; if (_lineProgram !is null) { - //Log.d("solid fill: vertices ", vertices, " colors ", colors); - _lineProgram.execute(vertices, colors); + _lineProgram.execute(vertices, cast(float[])colors); } else Log.e("No program"); } static immutable float Z_2D = -2.0f; void drawSolidFillRect(Rect rc, uint color1, uint color2, uint color3, uint color4) { - float[6 * 4] colors; - LVGLFillColor(color1, colors.ptr + 4*0, 1); - LVGLFillColor(color4, colors.ptr + 4*1, 1); - LVGLFillColor(color3, colors.ptr + 4*2, 1); - LVGLFillColor(color1, colors.ptr + 4*3, 1); - LVGLFillColor(color3, colors.ptr + 4*4, 1); - LVGLFillColor(color2, colors.ptr + 4*5, 1); + Color[6] colors; + FillColor(color1, colors[0..1]); + FillColor(color4, colors[1..2]); + FillColor(color3, colors[2..3]); + FillColor(color1, colors[3..4]); + FillColor(color3, colors[4..5]); + FillColor(color2, colors[5..6]); float x0 = cast(float)(rc.left); float y0 = cast(float)(bufferDy-rc.top); float x1 = cast(float)(rc.right); @@ -710,21 +678,19 @@ class GLSupport { glDisable(GL_BLEND); } else { if (_solidFillProgram !is null) { - //Log.d("solid fill: vertices ", vertices, " colors ", colors); - _solidFillProgram.execute(vertices, colors); + _solidFillProgram.execute(vertices, cast(float[])colors); } else Log.e("No program"); } } void drawColorAndTextureGlyphRect(Tex2D texture, int tdx, int tdy, Rect srcrc, Rect dstrc, uint color) { - //Log.v("drawColorAndGlyphRect tx=", texture.ID, " src=", srcrc, " dst=", dstrc); drawColorAndTextureGlyphRect(texture, tdx, tdy, srcrc.left, srcrc.top, srcrc.width(), srcrc.height(), dstrc.left, dstrc.top, dstrc.width(), dstrc.height(), color); } void drawColorAndTextureGlyphRect(Tex2D texture, int tdx, int tdy, int srcx, int srcy, int srcdx, int srcdy, int xx, int yy, int dx, int dy, uint color) { - float[6*4] colors; - LVGLFillColor(color, colors.ptr, 6); + Color[6] colors; + FillColor(color, colors); float dstx0 = cast(float)xx; float dsty0 = cast(float)(bufferDy - (yy)); float dstx1 = cast(float)(xx + dx); @@ -740,8 +706,8 @@ class GLSupport { float srcy0 = srcy / cast(float)tdy; float srcx1 = (srcx + srcdx) / cast(float)tdx; float srcy1 = (srcy + srcdy) / cast(float)tdy; - float[3 * 6] vertices = - [dstx0, dsty0, Z_2D, + float[3 * 6] vertices = [ + dstx0, dsty0, Z_2D, dstx0, dsty1, Z_2D, dstx1, dsty1, Z_2D, dstx0, dsty0, Z_2D, @@ -778,19 +744,18 @@ class GLSupport { glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); } else { - _fontProgram.execute(vertices, texcoords, colors, texture, false); + _fontProgram.execute(vertices, cast(float[])colors, texcoords, texture, false); } //drawColorAndTextureRect(vertices, texcoords, colors, texture, linear); } void drawColorAndTextureRect(Tex2D texture, int tdx, int tdy, Rect srcrc, Rect dstrc, uint color, bool linear) { - //Log.v("drawColorAndTextureRect tx=", texture.ID, " src=", srcrc, " dst=", dstrc); drawColorAndTextureRect(texture, tdx, tdy, srcrc.left, srcrc.top, srcrc.width(), srcrc.height(), dstrc.left, dstrc.top, dstrc.width(), dstrc.height(), color, linear); } void drawColorAndTextureRect(Tex2D texture, int tdx, int tdy, int srcx, int srcy, int srcdx, int srcdy, int xx, int yy, int dx, int dy, uint color, bool linear) { - float[6*4] colors; - LVGLFillColor(color, colors.ptr, 6); + Color[6] colors; + FillColor(color, colors); float dstx0 = cast(float)xx; float dsty0 = cast(float)(bufferDy - (yy)); float dstx1 = cast(float)(xx + dx); @@ -806,12 +771,13 @@ class GLSupport { float srcy0 = srcy / cast(float)tdy; float srcx1 = (srcx + srcdx) / cast(float)tdx; float srcy1 = (srcy + srcdy) / cast(float)tdy; - float[3 * 6] vertices = [dstx0,dsty0,Z_2D, - dstx0,dsty1,Z_2D, - dstx1,dsty1,Z_2D, - dstx0,dsty0,Z_2D, - dstx1,dsty1,Z_2D, - dstx1,dsty0,Z_2D]; + float[3 * 6] vertices = [ + dstx0,dsty0,Z_2D, + dstx0,dsty1,Z_2D, + dstx1,dsty1,Z_2D, + dstx0,dsty0,Z_2D, + dstx1,dsty1,Z_2D, + dstx1,dsty0,Z_2D]; float[2 * 6] texcoords = [srcx0,srcy0, srcx0,srcy1, srcx1,srcy1, srcx0,srcy0, srcx1,srcy1, srcx1,srcy0]; if (_legacyMode) { @@ -842,7 +808,7 @@ class GLSupport { glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); } else { - _textureProgram.execute(vertices, texcoords, colors, texture, linear); + _textureProgram.execute(vertices, cast(float[])colors, texcoords, texture, linear); } //drawColorAndTextureRect(vertices, texcoords, colors, texture, linear); } diff --git a/src/dlangui/platforms/common/platform.d b/src/dlangui/platforms/common/platform.d index ad5d57d5..bfc23374 100644 --- a/src/dlangui/platforms/common/platform.d +++ b/src/dlangui/platforms/common/platform.d @@ -180,7 +180,7 @@ class Window { _mainWidget.window = this; } - // Abstract methods : override in platform implementatino + // Abstract methods : override in platform implementation /// show window abstract void show(); diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 329c8817..ebbdf1f6 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -182,7 +182,6 @@ class SDLWindow : Window { static if (ENABLE_OPENGL) { if (_enableOpengl) { - Log.i("Trying to create OpenGL 3.2 context"); createContext(3, 2); //_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current if (!_context) { diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index d28ed052..a54f3523 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -1696,7 +1696,7 @@ class WidgetGroupDefaultDrawing : WidgetGroup { } } -immutable long ONE_SECOND = 10000000L; +immutable long ONE_SECOND = 10_000_000L; /// Helper to handle animation progress struct AnimationHelper {