fltk-rs / fl2rust

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

How to set margin to a flex? #24

Closed felixmaker closed 1 year ago

felixmaker commented 1 year ago

When adding margin to a flex in fluid, it cases widgets in flex do not generate.

It seems margin (int *left, int *top, int *right, int *bottom) const do not exist in fltk-rs. https://www.fltk.org/doc-1.4/classFl__Flex.html#ac40bc6a709b1e07402e73d1401129486

MoAlyousef commented 1 year ago

Hi

Can you post an fl example? Currently Flex has set_margin(val) and margin(). So it assumes that all margins on all sides are the same. I don’t think fluid supports different margins either. But I might not have kept up with the changes to fluid. If you have an example I could add the necessary code generation to fl2rust and fltk-rs.

MoAlyousef commented 1 year ago

So I tried with latest fluid, and it does enable setting different margins. I'll add support for that in the next few days.

felixmaker commented 1 year ago

Sorry to be late! Here is my fl example:

# data file for the Fltk User Interface Designer (fluid)
version 1.0400
header_name {.h}
code_name {.cxx}
class UserInterface {open
} {
  Function {make_window()} {open
  } {
    Fl_Window {} {open
      xywh {350 200 200 200} type Double visible
    } {
      Fl_Flex {} {open selected
        xywh {0 0 200 200} margins {10 20 10 10} gap 20 set_size_tuples {2  0 25  1 25 }
      } {
        Fl_Input {} {
          label {input:}
          xywh {10 20 180 25} align 5
        }
        Fl_Input {} {
          label {input:}
          xywh {10 65 180 25} align 5
        }
      }
    }
  }
}
MoAlyousef commented 1 year ago

I've updated the fl2rust to support margins and published a new release. I've also added it to fltk-rs, but the release will be next week.

felixmaker commented 1 year ago

Thank you!

MoAlyousef commented 1 year ago

This should work now with the latest release of fltk-rs (1.4.7)

felixmaker commented 1 year ago

It works! Thank you!