Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I set the window's position upon appearance? #19

Open
ocelot2024 opened this issue Dec 7, 2024 · 1 comment
Open

How can I set the window's position upon appearance? #19

ocelot2024 opened this issue Dec 7, 2024 · 1 comment
Labels
question Further information is requested

Comments

@ocelot2024
Copy link

How can I set the window's position upon appearance?

#![cfg_attr(not(test), windows_subsystem = "windows")]
#![cfg_attr(test, windows_subsystem = "console")]

extern crate libui;
use libui::controls::*;
use libui::prelude::*;

fn main() {
    let ui = UI::init()
        .expect("Couldn't initialize UI library");
    
    let mut win = Window::new(&ui, "Example", 300, 200, 
        WindowType::NoMenubar);
    let layout = VerticalBox::new();

    // add controls to your layout here

    win.set_child(layout);
    win.show();
    ui.main();
}

When I run this sample, the window appears at the bottom-left corner of the screen. I wanted to adjust the position of the window, so I looked for relevant methods in the documentation but couldn't find anything. How can I adjust the window's position?

@nptr
Copy link
Member

nptr commented Jan 21, 2025

There is Window::set_position() which was added in the development branch in July '24.
If you prefer tagged versions, last week I released version 0.4.0 on from crates.io, which includes this change.

Not sure if you can change the position before the window is shown or only afterwards. Thats something you'd have to try.

@nptr nptr added the question Further information is requested label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants