GithubHelp home page GithubHelp logo

Comments (2)

zeozeozeo avatar zeozeozeo commented on August 25, 2024

Here's how the attached example looks:

gridbug2.mp4

from egui_commonmark.

lampsitter avatar lampsitter commented on August 25, 2024

Repo without CommonMarkViewer

use eframe::egui;

fn main() {
    let native_options = eframe::NativeOptions::default();
    eframe::run_native(
        "Commonmark bug",
        native_options,
        Box::new(|_cc| Box::new(App::default())),
    )
    .expect("failed to run app");
}

#[derive(Default)]
struct App {
    content: String,
}

impl eframe::App for App {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            egui::Grid::new("my_grid")
                .num_columns(2)
                .striped(true)
                .show(ui, |ui| {
                    ui.label("row 1, col 1");
                    ui.label("row 1, col 2");
                    ui.end_row();
                    ui.label("row 2, col 1");

                    let layout =
                        egui::Layout::left_to_right(egui::Align::BOTTOM).with_main_wrap(true);
                    ui.allocate_ui_with_layout(egui::vec2(200.0, 0.0), layout, |ui| {
                        ui.label(&self.content);
                    });
                });
        });
        self.content += "a";
        ctx.request_repaint();
    }

with_main_wrap is guilty. My naive guess is that the layout grows downwards, but the grid tries to center it, so it allocates space on both sides which is what causes the growth. I have tried different Align options but it does not appear to change anything.

I don't know whether this is a case of using egui wrong or if it's a bug in Grid.

from egui_commonmark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.