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

feat: Basic Scrolling in Tab Menu #3

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
wip: prev w/ clippy
  • Loading branch information
bennjii committed Jun 2, 2023
commit 1eba30170fbcc7c6adade11ae0362ab3fde16440
3 changes: 0 additions & 3 deletions examples/advanced.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

use std::sync::mpsc::Sender;

use eframe::egui;
use egui::Button;

fn main() -> Result<(), eframe::Error> {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
Expand Down
2 changes: 0 additions & 2 deletions src/behavior.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::mpsc::Sender;

use egui::{
vec2, Color32, Id, Rect, Response, Rgba, Sense, Stroke, TextStyle, Ui, Visuals, WidgetText,
};
Expand Down
29 changes: 12 additions & 17 deletions src/container/tabs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use egui::{scroll_area::ScrollBarVisibility, vec2, Rect, Vec2, Pos2};
use egui::{scroll_area::ScrollBarVisibility, vec2, Rect, Vec2};

use crate::{
is_being_dragged, Behavior, ContainerInsertion, DropContext, InsertionPoint, SimplifyAction,
Expand Down Expand Up @@ -211,24 +211,19 @@ impl Tabs {
});

if scroll_state.offset.x > 0.0 {

let mut scroll_area_size = Vec2::ZERO;
scroll_area_size.x = 25.0;
scroll_area_size.y = ui.available_height();

ui.allocate_ui_with_layout(scroll_area_size, egui::Layout::right_to_left(egui::Align::Center), | ui | {
behavior.top_bar_left_ui(
&tree.tiles, ui, tile_id,
self, scroll_state.offset.x,
&mut scroll_state.offset_delta.x
);
});
}

let total_width = ui.available_width();
let mut scroll_area_size = Vec2::ZERO;
scroll_area_size.x = 25.0;
scroll_area_size.y = ui.available_height();

println!("W: {:?}", scroll_area_size);

ui.allocate_ui_with_layout(scroll_area_size, egui::Layout::right_to_left(egui::Align::Center), | ui | {
behavior.top_bar_left_ui(
&tree.tiles, ui, tile_id,
self, scroll_state.offset.x,
&mut scroll_state.offset_delta.x
);
});

scroll_state.offset = output.state.offset;
scroll_state.consumed = output.content_size;
scroll_state.available = output.inner_rect.size();
Expand Down