khchen / wNim

Nim's Windows GUI Framework
MIT License
319 stars 17 forks source link

Bug with "_" (underline) in variable names when used in autolayout #91

Closed rockcavera closed 3 years ago

rockcavera commented 3 years ago

I had made a window using wnim a year and a half ago. Since then I had not recompiled the program. So I went to recompile today and the autolayout wasn't working. It took me a long time to figure out what was wrong. Well, the error was in the use of "_" (underline) in the name of the controls' variables. As Nim ignores but makes it easier to visualize, I adopted this scheme. In the past, the autolayout recognized it, but I see that now it doesn't.

See the code below. statictextA, statictext_B and statictext_C, declared like this. As we know, for Nim it's all without the "_". Now see the autolayout. I used statictextA, statictextB and statictext_C. If you test each one separately, you will see that the only problem is the use of statictext_C in the autolayout, that is, the "_" is not ignored.

Example:

import wNim

let app = App(wSystemDpiAware)
let frame = Frame(title="Underline bug", style=wDefaultFrameStyle or wModalFrame)

frame.dpiAutoScale:
  frame.size = (640, 530)
  frame.minSize = (500, 450)

let panel = Panel(frame)

let staticbox1 = StaticBox(panel, label="")

let
  statictextA = StaticText(panel, label="A")
  statictext_B = StaticText(panel, label="B")
  statictext_C = StaticText(panel, label="C")

proc layout() =
  panel.autolayout """
    spacing: 10
    V:|-[staticbox1]-|
    H:|-[staticbox1]-|

    outer: staticbox1
    V:|[statictextA]-[statictextB]-[statictextC]|
    H:|-[statictextA, statictextB,statictext_C]
  """

layout()
frame.center()
frame.show()
app.mainLoop()
rockcavera commented 3 years ago

The problem started with this commit.

khchen commented 3 years ago

Thanks for your report. Should be fixed in v0.13.1, please try again.

rockcavera commented 3 years ago

Issue solved in v0.13.1.