fltk-rs / fl2rust

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

Cannot create correct "Browser". #8

Closed AllenDang closed 3 years ago

AllenDang commented 3 years ago

Reproduce steps:

  1. Create browser in fluid, change it's type to SelectBrowser.
  2. Use fl2rust to generate rust source.

Expect:

  1. Browser type should be SelectBrowser.

Actual:

  1. All kinds of Browsers like HoldBrowser and SelectBrowser will be created as Browser.
MoAlyousef commented 3 years ago

Yes, but their type is set later using the set_type method.

class UserInterface {open
} {
  Function {make_window()} {open
  } {
    Fl_Window win {open
      xywh {190 213 510 360} type Double resizable visible
    } {
      Fl_Browser br {selected
        xywh {25 25 415 215} type Select
      }
    }
  }
}

Would generate:


#[derive(Debug, Clone, Default)]
pub struct UserInterface {
    pub win: Window,
    pub br: Browser,
}

impl UserInterface {
    pub fn make_window() -> Self {
        let mut win = Window::new(190, 213, 510, 360, None);
        win.end();
        win.make_resizable(true);
        win.show();
        let mut br = Browser::new(25, 25, 415, 215, None);
        br.set_type(BrowserType::Select);
        win.add(&br);
        Self { win, br, ..Default::default() }
    }
}
AllenDang commented 3 years ago

@MoAlyousef Got it. Thanks!