Coder Social home page Coder Social logo

Comments (8)

brandon-reinhart avatar brandon-reinhart commented on September 27, 2024

I couldn't repro this, but am curious if you are still having the problem.

from bevy-console.

cebarks avatar cebarks commented on September 27, 2024

Just checked and I am. It seems to only be occurring when the window is on my 4k monitor with 125% scaling, but not the 4k at 200% scaling, so maybe something to do with dpi?

from bevy-console.

makspll avatar makspll commented on September 27, 2024

Hi @cebarks, could you please provide a small code example + steps for reproducing this issue?

from bevy-console.

cebarks avatar cebarks commented on September 27, 2024

Here's the code. The only thing required to reproduce this is to open this app on a 4k screen with scaling that ends in 25% (mine is set to 125%, but 175% also causes this to happen.) Switching scaling to a multiple of 50% stops it from happening.

use bevy::render::camera::ScalingMode;
use bevy::window::{PresentMode, WindowMode};
use bevy_console::{ConsoleConfiguration, ConsolePlugin};

pub const A_RATIO: f32 = 16.0 / 9.0;

fn main() {
    App::new()
        .insert_resource(get_window_desc())
        .insert_resource(ClearColor(Color::PURPLE))
        .add_plugins(DefaultPlugins)
        .add_plugin(ConsolePlugin)
        .insert_resource(ConsoleConfiguration {
            height: 200.0,
            ..Default::default()
        })
        .add_startup_system(spawn_camera)
        .run();
    println!("Exiting.");
}

fn get_window_desc() -> WindowDescriptor {
    return WindowDescriptor{
        title: "ConsoleTest".to_string(),
        width: 1600.0,
        height: 900.0,
        present_mode: PresentMode::Fifo,
        mode: WindowMode::Windowed,
        resizable: true,
        ..Default::default()
    }; 
}

fn spawn_camera(mut commands: Commands) {
    let mut camera = OrthographicCameraBundle::new_2d();

    camera.orthographic_projection.top = 1.0;
    camera.orthographic_projection.bottom = -1.0;

    camera.orthographic_projection.right = 1.0 * A_RATIO;
    camera.orthographic_projection.left = -1.0 * A_RATIO;

    camera.orthographic_projection.scaling_mode = ScalingMode::None;

    commands.spawn_bundle(camera);
    println!("Camera spawned.")
}

from bevy-console.

Flapperkewiet avatar Flapperkewiet commented on September 27, 2024

I had the same issue on a 2k (1440p) monitor with 125% scaling in windows settings.

I was able to fix it by editing :

let scroll_height = ui.available_height() - 30.0;

from

let scroll_height = ui.available_height() - 30.0;

to

let scroll_height = ui.available_height() - 32.0;

from bevy-console.

cebarks avatar cebarks commented on September 27, 2024

@makspll is the above enough to get this fixed? I can prepare a pull request too if with the change highlighted by @Flapperkewiet if that would help.

from bevy-console.

makspll avatar makspll commented on September 27, 2024

I am not sure what the cause of this issue is, but if this change fixes it it might be to do with the way floating point is handled. If you can reproduce the issue and this fix works then I am happy to accept PR's for it although I would love to know why exactly this happens ideally!

from bevy-console.

dimvoly avatar dimvoly commented on September 27, 2024

I'm getting this issue too. I believe the problem is that console.rs uses ui.vertical() which puts the widgets in from top to bottom. Since the one that grows in size is the scroll area, you can put the widgets in bottom to top instead:

{
                // ui.vertical(|ui| {
                    // let scroll_height = ui.available_height() - 30.0;
                ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
                    // Input
                    let text_edit = TextEdit::singleline(&mut state.buf)
                        .desired_width(f32::INFINITY)
                        .font(egui::TextStyle::Monospace);
                    let text_edit_response = ui.add(text_edit);

                    // Separator
                    ui.separator();

                    // Scroll area
                    ScrollArea::vertical()
                        .auto_shrink([false, false])
                        .stick_to_bottom(true)
                        // .max_height(scroll_height)
                        .show(ui, |ui| {

This way you don't need to pre-calculate the pixels for the available height. This also stops the large jump that happens to window size when you go to resize it using the grip on the bottom-right corner. Related talk here.

from bevy-console.

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.