JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.9k stars 1.16k forks source link

SelectionContainer and TextField: Unable to select words with blank chars (space, \n, ...) #2327

Open TsihenHo opened 1 year ago

TsihenHo commented 1 year ago

https://user-images.githubusercontent.com/52124236/190847396-c6c73dc7-fcd8-4778-9662-c9fa58118183.mp4

this problem also remains in TextField

Os windows 7 Version 1.2.0-beta01

the error msg:

Shader compilation error
------------------------
   1    #version 420 compatibility
   2    
   3    const float PRECISION = 4.0;
   4    const float MAX_FIXED_RESOLVE_LEVEL = 5.0;
   5    const float MAX_FIXED_SEGMENTS = 32.0;
   6    uniform vec4 sk_RTAdjust;
   7    uniform vec4 uaffineMatrix_S0;
   8    uniform vec2 utranslate_S0;
   9    in vec2 resolveLevel_and_idx;
  10    in vec4 p01;
  11    in vec4 p23;
  12    in vec2 fanPointAttrib;
  13    float wangs_formula_max_fdiff_p2_ff2f2f2f2f22(vec2 p0, vec2 p1, vec2 p2, vec2 p3, mat2 matrix) {
  14        vec2 d0 = matrix * (fma(vec2(-2.0), p1, p2) + p0);
  15        vec2 d1 = matrix * (fma(vec2(-2.0), p2, p3) + p1);
  16        return max(dot(d0, d0), dot(d1, d1));
  17    }
  18    float wangs_formula_conic_p2_fff2f2f2f(float _precision_, vec2 p0, vec2 p1, vec2 p2, float w) {
  19        vec2 C = (min(min(p0, p1), p2) + max(max(p0, p1), p2)) * 0.5;
  20        p0 -= C;
  21        p1 -= C;
  22        p2 -= C;
  23        float m = sqrt(max(max(dot(p0, p0), dot(p1, p1)), dot(p2, p2)));
  24        vec2 dp = fma(vec2(-2.0 * w), p1, p0) + p2;
  25        float dw = abs(fma(-2.0, w, 2.0));
  26        float rp_minus_1 = max(0.0, fma(m, _precision_, -1.0));
  27        float numer = length(dp) * _precision_ + rp_minus_1 * dw;
  28        float denom = 4.0 * min(w, 1.0);
  29        return numer / denom;
  30    }
  31    void main() {
  32        mat2 AFFINE_MATRIX = mat2(uaffineMatrix_S0);
  33        vec2 TRANSLATE = utranslate_S0;
  34        float resolveLevel = resolveLevel_and_idx.x;
  35        float idxInResolveLevel = resolveLevel_and_idx.y;
  36        vec2 localcoord;
  37        if (resolveLevel < 0.0) {
  38            localcoord = fanPointAttrib;
  39        } else if (isinf(p23.z)) {
  40            localcoord = resolveLevel != 0.0 ? p01.zw : (idxInResolveLevel != 0.0 ? p23.xy : p01.xy);
  41        } else {
  42            vec2 p0 = p01.xy;
  43            vec2 p1 = p01.zw;
  44            vec2 p2 = p23.xy;
  45            vec2 p3 = p23.zw;
  46            float w = -1.0;
  47            float maxResolveLevel;
  48            if (isinf(p23.w)) {
  49                w = p3.x;
  50                float _0_n2 = wangs_formula_conic_p2_fff2f2f2f(PRECISION, AFFINE_MATRIX * p0, AFFINE_MATRIX * p1, AFFINE_MATRIX * p2, w);
  51                maxResolveLevel = ceil(log2(max(_0_n2, 1.0)) * 0.5);
  52                p1 *= w;
  53                p3 = p2;
  54            } else {
  55                float _1_m = wangs_formula_max_fdiff_p2_ff2f2f2f2f22(p0, p1, p2, p3, AFFINE_MATRIX);
  56                maxResolveLevel = ceil(log2(max(9.0 * _1_m, 1.0)) * 0.25);
  57            }
  58            if (resolveLevel > maxResolveLevel) {
  59                idxInResolveLevel = floor(ldexp(idxInResolveLevel, int(maxResolveLevel - resolveLevel)));
  60                resolveLevel = maxResolveLevel;
  61            }
  62            float fixedVertexID = floor(0.5 + ldexp(idxInResolveLevel, int(MAX_FIXED_RESOLVE_LEVEL - resolveLevel)));
  63            if (0.0 < fixedVertexID && fixedVertexID < MAX_FIXED_SEGMENTS) {
  64                float T = fixedVertexID * 0.03125;
  65                vec2 ab = mix(p0, p1, T);
  66                vec2 bc = mix(p1, p2, T);
  67                vec2 cd = mix(p2, p3, T);
  68                vec2 abc = mix(ab, bc, T);
  69                vec2 bcd = mix(bc, cd, T);
  70                vec2 abcd = mix(abc, bcd, T);
  71                float u = mix(1.0, w, T);
  72                float v = (w + 1.0) - u;
  73                float uv = mix(u, v, T);
  74                localcoord = w < 0.0 ? abcd : abc / uv;
  75            } else {
  76                localcoord = fixedVertexID == 0.0 ? p0 : p3;
  77            }
  78        }
  79        vec2 vertexpos = AFFINE_MATRIX * localcoord + TRANSLATE;
  80        gl_Position = vec4(vertexpos, 0.0, 1.0);
  81        gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w);
  82    }
  83    
Errors:
Vertex shader failed to compile with the following errors:
ERROR: 0:32: error(#53) Built-in function parameter type check fail: an operation which requires matrix parameters is used on a non matrix type!
ERROR: 0:32: error(#53) Built-in function parameter type check fail: an operation which requires matrix parameters is used on a non matrix type!
ERROR: error(#273) 2 compilation errors.  No code generated
TsihenHo commented 1 year ago

1576 #2135 are similar and maybe related

okushnikov commented 2 weeks ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.