Shirakumo / alloy

A new user interface protocol and toolkit implementation
https://shirakumo.github.io/alloy
zlib License
181 stars 12 forks source link

Graphical cursor bug with textboxes #10

Closed Trashtalk217 closed 1 year ago

Trashtalk217 commented 4 years ago

Problem: https://imgur.com/a/aRBL3MX

The cursor is not behaving nicely for me, it doesn't stick to the text but charges ahead.

Code I used in the examples/window.lisp file:

(define-example wheel-test (screen)
  (let* ((window (windowing:make-window screen))
         (focus (make-instance 'alloy:focus-list :focus-parent window))
         (layout (make-instance 'alloy:vertical-linear-layout :layout-parent window))
         (value 10)
         (text "Hello there!")
         (wheel (alloy:represent value 'alloy:wheel))
         (input (alloy:represent text 'alloy:input-box)))
    (alloy:enter wheel layout)
    (alloy:enter wheel focus)
    (alloy:enter input layout)
    (alloy:enter input focus)))

I've looked throught the codebase myself and I've isolated the problem to the renderer. Nothing seemed to be wrong in the components themselve. Sadly, I've not yet gotten the courage to dig into renderer side of things so I thought I'd make this an issue instead of a pull request.

Shinmera commented 4 years ago

Yeah, the fond backend does not calculate cursor positions correctly. It is correct in the msdf backend, but for that the atlas generation is still broken in the 3b/sdf library.

Ideally the fond backend can be eliminated once atlas generation works correctly, since msdf is both pure-lisp, and creates far better text rendering than the fond backend.

Trashtalk217 commented 4 years ago

So you are referring to the make-atlas function in this repo? Just to make sure I understand the problem?

Shinmera commented 4 years ago

That is the repo, though not the right branch (msdf). We use it here: https://github.com/Shirakumo/alloy/blob/master/renderers/opengl/msdf.lisp#L112

The issue is complex and I'm waiting for @3b to get back into working on it, since I lack the understanding on the topic myself.

3b commented 4 years ago

is the problem in msdf atlas generator, bmfont code/api , or the way atlas generator uses the bmfont code? seems like cursor and character positioning should be using same character size, so seems odd they wouldn't match

Trashtalk217 commented 4 years ago

The amount of space the cursor moves is also proportional to the length of a given letter. When an 'i' is typed the cursor moves less, then when a 'w' is typed. So it is somewhat aware of the right proportions.

Shinmera commented 4 years ago

@3b The problem mentioned in this ticket is in the fond backend, which has nothing to do with the msdf atlas. It's just doing a bad computation on the glyph advance.

For the msdf backend the problem is still as before -- the atlas generation chokes on some glyphs that appear in fonts out there. Otherwise that backend (when using pre-computed atlases) works perfectly fine.

Shinmera commented 1 year ago

The fond backend has been deprecated.