fltk-rs / fl2rust

A fluid (fltk ui designer) file to Rust transpiler
MIT License
52 stars 3 forks source link

[BUG] whitespace in label #17

Closed Aloxaf closed 1 year ago

Aloxaf commented 2 years ago

Example:

class UserInterface {open
} {
  Function {make_window()} {open
  } {
    Fl_Window {} {open
      xywh {425 888 140 90} type Double visible
    } {
      Fl_Box {} {
        label {many        spaces
newline} selected
        xywh {15 15 115 50}
      }
    }
  }
}

They are all replaced with a single whitespace, which breaks the layout.

impl UserInterface {
    pub fn make_window() -> Self {
        let mut fl2rust_widget_0 = Window::new(425, 888, 140, 90, None);
        fl2rust_widget_0.end();
        fl2rust_widget_0.show();
        let mut fl2rust_widget_1 = Frame::new(15, 15, 115, 50, "many spaces newline");
        fl2rust_widget_0.add(&fl2rust_widget_1);
        Self { ..Default::default() }
    }
}
MoAlyousef commented 2 years ago

This is difficult to support. AFAIK, the fluid gui itself doesn't allow creating new lines, you have to modify the fl file directly. Currently parsing fl files assumes significant whitespace, since this makes things much easier. Proper parsing along with reporting errors with line numbers etc is planned but I don't know when I can start implementing it.

The only workaround is to change the label on the Rust side, or to choose Wrap in the gui which should translate to Align::Wrap and properly wrap your text.

MoAlyousef commented 1 year ago

This should be fixed in 0.5