Giter Club home page Giter Club logo

Comments (3)

emilk avatar emilk commented on September 27, 2024

One solution is to simply add the full range as a second parameter to the closure:

let mut batch = vec![];

table_builder
    .header(re_ui::DesignTokens::table_line_height(), header_ui)
    .body(|body| {
        body.rows(line_height, row_count, |row, row_range: Range<usize>| {
            if row.index() == row_range.start {
                batch = load_batch(row_range);
            }
            show(row, batch);
        });
    });

However, that's maybe not the most ergonomic.

An alternative is

table_builder
    .header(re_ui::DesignTokens::table_line_height(), header_ui)
    .body(|body| {
        body.rows_ext(line_height, row_count,
            |row_range: Range<usize>| load_batch(row_range),
            |batch, row| show(row, batch)
        );
    });

from egui.

abey79 avatar abey79 commented on September 27, 2024

Either would be fine for me. The former needs to guarantee that the closure is called in the correct order. The latter is slightly weird wrt to ownership (I assume body take ownership of the first closure's returned value, and only provides a mutable(?) ref to the second closure)?

Wonder if a trait based API could be more ergonomics, as it could encompass everything (header row(s), on_row_batch(), on_row(), cell-based callback to accommodate for #5001).

from egui.

emilk avatar emilk commented on September 27, 2024

Done in https://github.com/rerun-io/egui_table

from egui.

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.