Skip to content

Consider Generating Bindings #109

Description

@bbb651

Related: #65, #101.

See: https://github.com/ocornut/imgui/wiki/Bindings.

This would significantly help with reducing maintenance burden, outdated imgui versions, missing features and incorrect/inconsistent types and style.

The options seem to be:

Details
pub const WindowFlags = packed struct(c_int) {
    /// Disable title-bar
    NoTitleBar: bool = false,
    /// Disable user resizing with the lower-right grip
    NoResize: bool = false,
    /// Disable user moving the window
    NoMove: bool = false,
    /// Disable scrollbars (window can still scroll with mouse or programmatically)
    NoScrollbar: bool = false,
    /// Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
    NoScrollWithMouse: bool = false,
    /// Disable user collapsing window by double-clicking on it. Also referred to as Window Menu Button (e.g. within a docking node).
    NoCollapse: bool = false,
    /// Resize every window to its content every frame
    AlwaysAutoResize: bool = false,
    /// Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f).
    NoBackground: bool = false,
    /// Never load/save settings in .ini file
    NoSavedSettings: bool = false,
    /// Disable catching mouse, hovering test with pass through.
    NoMouseInputs: bool = false,
    /// Has a menu-bar
    MenuBar: bool = false,
    /// Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
    HorizontalScrollbar: bool = false,
    /// Disable taking focus when transitioning from hidden to visible state
    NoFocusOnAppearing: bool = false,
    /// Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus)
    NoBringToFrontOnFocus: bool = false,
    /// Always show vertical scrollbar (even if ContentSize.y < Size.y)
    AlwaysVerticalScrollbar: bool = false,
    /// Always show horizontal scrollbar (even if ContentSize.x < Size.x)
    AlwaysHorizontalScrollbar: bool = false,
    /// No keyboard/gamepad navigation within the window
    NoNavInputs: bool = false,
    /// No focusing toward this window with keyboard/gamepad navigation (e.g. skipped by Ctrl+Tab)
    NoNavFocus: bool = false,
    /// Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
    UnsavedDocument: bool = false,
    /// Disable docking of this window
    NoDocking: bool = false,
    unused20: bool = false,
    unused21: bool = false,
    unused22: bool = false,
    unused23: bool = false,
    unused24: bool = false,
    unused25: bool = false,
    unused26: bool = false,
    unused27: bool = false,
    unused28: bool = false,
    unused29: bool = false,
    unused30: bool = false,
    unused31: bool = false,
    const NoNav: @This() = .{ .NoNavInputs = true, .NoNavFocus = true };
    const NoDecoration: @This() = .{ .NoTitleBar = true, .NoResize = true, .NoScrollbar = true, .NoCollapse = true };
    const NoInputs: @This() = .{ .NoMouseInputs = true, .NoNavInputs = true, .NoNavFocus = true };
};
// ...
pub const Key = enum(c_int) {
    None = 0,
    /// == ImGuiKey_NamedKey_BEGIN
    Tab = 512,
    LeftArrow = 513,
    RightArrow = 514,
    UpArrow = 515,
    DownArrow = 516,
    PageUp = 517,
    PageDown = 518,
    Home = 519,
    End = 520,
    Insert = 521,
    Delete = 522,
    Backspace = 523,
    Space = 524,
    Enter = 525,
    Escape = 526,
    LeftCtrl = 527,
    LeftShift = 528,
    LeftAlt = 529,
    /// Also see ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiMod_Alt, ImGuiMod_Super below!
    LeftSuper = 530,
    RightCtrl = 531,
    RightShift = 532,
    RightAlt = 533,
    RightSuper = 534,
    Menu = 535,
    @"0" = 536,
    @"1" = 537,
    @"2" = 538,
    @"3" = 539,
    @"4" = 540,
    @"5" = 541,
    @"6" = 542,
    @"7" = 543,
    @"8" = 544,
    @"9" = 545,
    A = 546,
    B = 547,
    C = 548,
    D = 549,
    E = 550,
    F = 551,
    G = 552,
    H = 553,
    I = 554,
    J = 555,
    K = 556,
    L = 557,
    M = 558,
    N = 559,
    O = 560,
    P = 561,
    Q = 562,
    R = 563,
    S = 564,
    T = 565,
    U = 566,
    V = 567,
    W = 568,
    X = 569,
    Y = 570,
    Z = 571,
    F1 = 572,
    F2 = 573,
    F3 = 574,
    F4 = 575,
    F5 = 576,
    F6 = 577,
    F7 = 578,
    F8 = 579,
    F9 = 580,
    F10 = 581,
    F11 = 582,
    F12 = 583,
    F13 = 584,
    F14 = 585,
    F15 = 586,
    F16 = 587,
    F17 = 588,
    F18 = 589,
    F19 = 590,
    F20 = 591,
    F21 = 592,
    F22 = 593,
    F23 = 594,
    F24 = 595,
    /// '
    Apostrophe = 596,
    /// ,
    Comma = 597,
    /// -
    Minus = 598,
    /// .
    Period = 599,
    /// /
    Slash = 600,
    /// ;
    Semicolon = 601,
    /// =
    Equal = 602,
    /// [
    LeftBracket = 603,
    /// \ (this text inhibit multiline comment caused by backslash)
    Backslash = 604,
    /// ]
    RightBracket = 605,
    /// `
    GraveAccent = 606,
    CapsLock = 607,
    ScrollLock = 608,
    NumLock = 609,
    PrintScreen = 610,
    Pause = 611,
    Keypad0 = 612,
    Keypad1 = 613,
    Keypad2 = 614,
    Keypad3 = 615,
    Keypad4 = 616,
    Keypad5 = 617,
    Keypad6 = 618,
    Keypad7 = 619,
    Keypad8 = 620,
    Keypad9 = 621,
    KeypadDecimal = 622,
    KeypadDivide = 623,
    KeypadMultiply = 624,
    KeypadSubtract = 625,
    KeypadAdd = 626,
    KeypadEnter = 627,
    KeypadEqual = 628,
    /// Available on some keyboard/mouses. Often referred as "Browser Back"
    AppBack = 629,
    AppForward = 630,
    /// Non-US backslash.
    Oem102 = 631,
    /// Menu        | +       | Options  |
    GamepadStart = 632,
    /// View        | -       | Share    |
    GamepadBack = 633,
    /// X           | Y       | Square   | Toggle Menu. Hold for Windowing mode (Focus/Move/Resize windows)
    GamepadFaceLeft = 634,
    /// B           | A       | Circle   | Cancel / Close / Exit
    GamepadFaceRight = 635,
    /// Y           | X       | Triangle | Open Context Menu
    GamepadFaceUp = 636,
    /// A           | B       | Cross    | Activate / Open / Toggle. Hold for 0.60f to Activate in Text Input mode (e.g. wired to an on-screen keyboard).
    GamepadFaceDown = 637,
    /// D-pad Left  | "       | "        | Move / Tweak / Resize Window (in Windowing mode)
    GamepadDpadLeft = 638,
    /// D-pad Right | "       | "        | Move / Tweak / Resize Window (in Windowing mode)
    GamepadDpadRight = 639,
    /// D-pad Up    | "       | "        | Move / Tweak / Resize Window (in Windowing mode)
    GamepadDpadUp = 640,
    /// D-pad Down  | "       | "        | Move / Tweak / Resize Window (in Windowing mode)
    GamepadDpadDown = 641,
    /// L Bumper    | L       | L1       | Tweak Slower / Focus Previous (in Windowing mode)
    GamepadL1 = 642,
    /// R Bumper    | R       | R1       | Tweak Faster / Focus Next (in Windowing mode)
    GamepadR1 = 643,
    /// L Trigger   | ZL      | L2       | [Analog]
    GamepadL2 = 644,
    /// R Trigger   | ZR      | R2       | [Analog]
    GamepadR2 = 645,
    /// L Stick     | L3      | L3       |
    GamepadL3 = 646,
    /// R Stick     | R3      | R3       |
    GamepadR3 = 647,
    /// |         |          | [Analog] Move Window (in Windowing mode)
    GamepadLStickLeft = 648,
    /// |         |          | [Analog] Move Window (in Windowing mode)
    GamepadLStickRight = 649,
    /// |         |          | [Analog] Move Window (in Windowing mode)
    GamepadLStickUp = 650,
    /// |         |          | [Analog] Move Window (in Windowing mode)
    GamepadLStickDown = 651,
    /// |         |          | [Analog]
    GamepadRStickLeft = 652,
    /// |         |          | [Analog]
    GamepadRStickRight = 653,
    /// |         |          | [Analog]
    GamepadRStickUp = 654,
    /// |         |          | [Analog]
    GamepadRStickDown = 655,
    MouseLeft = 656,
    MouseRight = 657,
    MouseMiddle = 658,
    MouseX1 = 659,
    MouseX2 = 660,
    MouseWheelX = 661,
    MouseWheelY = 662,
    ReservedForModCtrl = 663,
    ReservedForModShift = 664,
    ReservedForModAlt = 665,
    ReservedForModSuper = 666,
    Mod_None = 0,
    /// Ctrl (non-macOS), Cmd (macOS)
    Mod_Ctrl = 4096,
    /// Shift
    Mod_Shift = 8192,
    /// Option/Menu
    Mod_Alt = 16384,
    /// Windows/Super (non-macOS), Ctrl (macOS)
    Mod_Super = 32768,
    /// 4-bits
    Mod_Mask_ = 61440,
    /// Removed in 1.90.7, you can now simply use ImGuiMod_Ctrl
    Mod_Shortcut = 4096,
};
  • Generate them from scratch from imgui.h. This gives the most flexibility but is significantly more complex. This doesn't necessarily require creating c bindings, it's possible to use cimgui/dcimgui while manually reading the header, but that has it's own issues and it's still a ton of work.

Either way it doesn't need to be perfect, it's pretty simple to have a system to manually override generated code, which is the work currently being done for all bindings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions