Skip to main content

Dock

Struct Dock 

Source
pub struct Dock {
    pub nodes: Vec<DockNode>,
    pub floating: Vec<(String, Panel)>,
    pub closed: Vec<String>,
    pub maximized: Option<String>,
    /* private fields */
}
Expand description

A dock’s layout, kept by the app.

Fields§

§nodes: Vec<DockNode>

Its places; the first is the whole dock.

§floating: Vec<(String, Panel)>

Panels floating over the window instead, each with its placement.

§closed: Vec<String>

Panels the user closed with their tab’s close button (where allowed: docked_closable), oldest first. Hidden until the app reopens them (set_open): an app whose panels are documents takes them from here.

§maximized: Option<String>

The panel maximized within the dock, with the rest of its place: usually none. The user toggles it with the button at the end of its tabs.

Implementations§

Source§

impl Dock

Source

pub fn of(names: &[&str]) -> Self

A dock of these panels as tabs.

Examples found in repository?
examples/book.rs (line 955)
954    fn first() -> Dock {
955        Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Notes"]).above(Dock::of(&["Log"]), 0.7), 0.25)
956    }
More examples
Hide additional examples
examples/gallery.rs (line 1311)
1248pub fn app() -> App {
1249    App {
1250        name: "Gallery".into(),
1251        presses: 0,
1252        page: 0,
1253        room: 0,
1254        filter: String::new(),
1255        notes: String::new(),
1256        renaming: None,
1257        light: false,
1258        contrast: false,
1259        system: false,
1260        spacing: 1,
1261        ticked: false,
1262        on: true,
1263        folded_open: true,
1264        second: false,
1265        level: 72.0,
1266        bold: false,
1267        starred: true,
1268        span: 1,
1269        busy: false,
1270        from: 20.0,
1271        to: 70.0,
1272        followed: 0,
1273        finding: false,
1274        colour: 6,
1275        wanted: String::new(),
1276        picture: None,
1277        photo: None,
1278        drawings: None,
1279        animation: None,
1280        playing: false,
1281        // `TAUT_FONT=some.ttf` writes the whole window with that font, in place of the system's.
1282        letters: std::env::var_os("TAUT_FONT").and_then(|file| std::fs::read(file).ok()).and_then(FontFile::read),
1283        place: String::new(),
1284        shape: None,
1285        selected_row: 1,
1286        tree_open: [true, true],
1287        amount: 4.0,
1288        off: true,
1289        count: 12,
1290        day: Date::today(),
1291        alarm: Time::new(7, 30, 0),
1292        meeting: (Date::today(), Time::new(14, 0, 0)),
1293        away: (Date::today(), Date::from_days(Date::today().days() + 6)),
1294        marked: 3.0,
1295        zoom: 100.0,
1296        within: 2.5,
1297        fruit: "pear",
1298        faint: true,
1299        hide: false,
1300        tint: Theme::dark().accent,
1301        drag_lists: [vec!["Apples", "Pears", "Plums"], vec!["Bread"]],
1302        table: Table { frozen: 1, ..Default::default() },
1303        selection: Selection::default(),
1304        files: (0..5000u32).map(|n| (format!("file {n:04}"), n * 7919 % 4096 + 1, ["text", "picture", "sound", "folder"][n as usize * 5 % 4])).collect(),
1305        tools: Panel { open: false, ..Panel::new(520.0, 150.0, 300.0, 220.0) },
1306        code: CodeEditor::new(include_str!("gallery.rs"), &Syntax::RUST),
1307        lamp: Lamp { name: "Desk".into(), power: 40.0, on: true, kind: LampKind::Spot, tint: Color::rgb(0xffcf7a), rooms: vec!["Study".into(), "Hall".into()] },
1308        inspector: Inspector::default(),
1309        beside: SecondWindow { open: false, ..SecondWindow::new(380.0, 240.0) },
1310        file_dialog: FileDialog::default(),
1311        dock: Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Preview"]).above(Dock::of(&["Log"]), 0.7), 0.25),
1312        step: 2,
1313        results: 0,
1314        query: String::new(),
1315        topics: vec!["mountains".into(), "walks".into()],
1316        topic: String::new(),
1317        stars: 3.5,
1318        face: None,
1319        liked: [true, false],
1320        loading: true,
1321        banner: true,
1322        styles: [true, false, false],
1323        section: Some(0),
1324        slices: ChartView::default(),
1325        view: ChartView::default(),
1326        dots: [0, 1, 2, 3].map(|row| (0..80u32).map(|n| chance(n + 80 * row)).collect()),
1327        live: false,
1328        load: (0..600).map(|nth| 0.5 + (nth as f32 / 40.0).sin() * 0.2).collect(),
1329        fed: taut::platform::unix_time(),
1330        folders: TreeView::default(),
1331        writing: Markdown::parse(WRITING),
1332    }
1333}
Source

pub fn beside(self, other: Dock, share: f32) -> Self

This dock on the left with share of the width, other on the right.

Examples found in repository?
examples/book.rs (line 955)
954    fn first() -> Dock {
955        Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Notes"]).above(Dock::of(&["Log"]), 0.7), 0.25)
956    }
More examples
Hide additional examples
examples/gallery.rs (line 1311)
1248pub fn app() -> App {
1249    App {
1250        name: "Gallery".into(),
1251        presses: 0,
1252        page: 0,
1253        room: 0,
1254        filter: String::new(),
1255        notes: String::new(),
1256        renaming: None,
1257        light: false,
1258        contrast: false,
1259        system: false,
1260        spacing: 1,
1261        ticked: false,
1262        on: true,
1263        folded_open: true,
1264        second: false,
1265        level: 72.0,
1266        bold: false,
1267        starred: true,
1268        span: 1,
1269        busy: false,
1270        from: 20.0,
1271        to: 70.0,
1272        followed: 0,
1273        finding: false,
1274        colour: 6,
1275        wanted: String::new(),
1276        picture: None,
1277        photo: None,
1278        drawings: None,
1279        animation: None,
1280        playing: false,
1281        // `TAUT_FONT=some.ttf` writes the whole window with that font, in place of the system's.
1282        letters: std::env::var_os("TAUT_FONT").and_then(|file| std::fs::read(file).ok()).and_then(FontFile::read),
1283        place: String::new(),
1284        shape: None,
1285        selected_row: 1,
1286        tree_open: [true, true],
1287        amount: 4.0,
1288        off: true,
1289        count: 12,
1290        day: Date::today(),
1291        alarm: Time::new(7, 30, 0),
1292        meeting: (Date::today(), Time::new(14, 0, 0)),
1293        away: (Date::today(), Date::from_days(Date::today().days() + 6)),
1294        marked: 3.0,
1295        zoom: 100.0,
1296        within: 2.5,
1297        fruit: "pear",
1298        faint: true,
1299        hide: false,
1300        tint: Theme::dark().accent,
1301        drag_lists: [vec!["Apples", "Pears", "Plums"], vec!["Bread"]],
1302        table: Table { frozen: 1, ..Default::default() },
1303        selection: Selection::default(),
1304        files: (0..5000u32).map(|n| (format!("file {n:04}"), n * 7919 % 4096 + 1, ["text", "picture", "sound", "folder"][n as usize * 5 % 4])).collect(),
1305        tools: Panel { open: false, ..Panel::new(520.0, 150.0, 300.0, 220.0) },
1306        code: CodeEditor::new(include_str!("gallery.rs"), &Syntax::RUST),
1307        lamp: Lamp { name: "Desk".into(), power: 40.0, on: true, kind: LampKind::Spot, tint: Color::rgb(0xffcf7a), rooms: vec!["Study".into(), "Hall".into()] },
1308        inspector: Inspector::default(),
1309        beside: SecondWindow { open: false, ..SecondWindow::new(380.0, 240.0) },
1310        file_dialog: FileDialog::default(),
1311        dock: Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Preview"]).above(Dock::of(&["Log"]), 0.7), 0.25),
1312        step: 2,
1313        results: 0,
1314        query: String::new(),
1315        topics: vec!["mountains".into(), "walks".into()],
1316        topic: String::new(),
1317        stars: 3.5,
1318        face: None,
1319        liked: [true, false],
1320        loading: true,
1321        banner: true,
1322        styles: [true, false, false],
1323        section: Some(0),
1324        slices: ChartView::default(),
1325        view: ChartView::default(),
1326        dots: [0, 1, 2, 3].map(|row| (0..80u32).map(|n| chance(n + 80 * row)).collect()),
1327        live: false,
1328        load: (0..600).map(|nth| 0.5 + (nth as f32 / 40.0).sin() * 0.2).collect(),
1329        fed: taut::platform::unix_time(),
1330        folders: TreeView::default(),
1331        writing: Markdown::parse(WRITING),
1332    }
1333}
Source

pub fn above(self, other: Dock, share: f32) -> Self

This dock on top with share of the height, other below.

Examples found in repository?
examples/book.rs (line 955)
954    fn first() -> Dock {
955        Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Notes"]).above(Dock::of(&["Log"]), 0.7), 0.25)
956    }
More examples
Hide additional examples
examples/gallery.rs (line 1311)
1248pub fn app() -> App {
1249    App {
1250        name: "Gallery".into(),
1251        presses: 0,
1252        page: 0,
1253        room: 0,
1254        filter: String::new(),
1255        notes: String::new(),
1256        renaming: None,
1257        light: false,
1258        contrast: false,
1259        system: false,
1260        spacing: 1,
1261        ticked: false,
1262        on: true,
1263        folded_open: true,
1264        second: false,
1265        level: 72.0,
1266        bold: false,
1267        starred: true,
1268        span: 1,
1269        busy: false,
1270        from: 20.0,
1271        to: 70.0,
1272        followed: 0,
1273        finding: false,
1274        colour: 6,
1275        wanted: String::new(),
1276        picture: None,
1277        photo: None,
1278        drawings: None,
1279        animation: None,
1280        playing: false,
1281        // `TAUT_FONT=some.ttf` writes the whole window with that font, in place of the system's.
1282        letters: std::env::var_os("TAUT_FONT").and_then(|file| std::fs::read(file).ok()).and_then(FontFile::read),
1283        place: String::new(),
1284        shape: None,
1285        selected_row: 1,
1286        tree_open: [true, true],
1287        amount: 4.0,
1288        off: true,
1289        count: 12,
1290        day: Date::today(),
1291        alarm: Time::new(7, 30, 0),
1292        meeting: (Date::today(), Time::new(14, 0, 0)),
1293        away: (Date::today(), Date::from_days(Date::today().days() + 6)),
1294        marked: 3.0,
1295        zoom: 100.0,
1296        within: 2.5,
1297        fruit: "pear",
1298        faint: true,
1299        hide: false,
1300        tint: Theme::dark().accent,
1301        drag_lists: [vec!["Apples", "Pears", "Plums"], vec!["Bread"]],
1302        table: Table { frozen: 1, ..Default::default() },
1303        selection: Selection::default(),
1304        files: (0..5000u32).map(|n| (format!("file {n:04}"), n * 7919 % 4096 + 1, ["text", "picture", "sound", "folder"][n as usize * 5 % 4])).collect(),
1305        tools: Panel { open: false, ..Panel::new(520.0, 150.0, 300.0, 220.0) },
1306        code: CodeEditor::new(include_str!("gallery.rs"), &Syntax::RUST),
1307        lamp: Lamp { name: "Desk".into(), power: 40.0, on: true, kind: LampKind::Spot, tint: Color::rgb(0xffcf7a), rooms: vec!["Study".into(), "Hall".into()] },
1308        inspector: Inspector::default(),
1309        beside: SecondWindow { open: false, ..SecondWindow::new(380.0, 240.0) },
1310        file_dialog: FileDialog::default(),
1311        dock: Dock::of(&["Files"]).beside(Dock::of(&["Editor", "Preview"]).above(Dock::of(&["Log"]), 0.7), 0.25),
1312        step: 2,
1313        results: 0,
1314        query: String::new(),
1315        topics: vec!["mountains".into(), "walks".into()],
1316        topic: String::new(),
1317        stars: 3.5,
1318        face: None,
1319        liked: [true, false],
1320        loading: true,
1321        banner: true,
1322        styles: [true, false, false],
1323        section: Some(0),
1324        slices: ChartView::default(),
1325        view: ChartView::default(),
1326        dots: [0, 1, 2, 3].map(|row| (0..80u32).map(|n| chance(n + 80 * row)).collect()),
1327        live: false,
1328        load: (0..600).map(|nth| 0.5 + (nth as f32 / 40.0).sin() * 0.2).collect(),
1329        fed: taut::platform::unix_time(),
1330        folders: TreeView::default(),
1331        writing: Markdown::parse(WRITING),
1332    }
1333}
Source

pub fn panels(&self) -> impl Iterator<Item = &str>

The names of all shown panels: docked, then floating.

Source

pub fn is_open(&self, name: &str) -> bool

Whether a panel is open: not among the closed ones.

Examples found in repository?
examples/gallery.rs (line 296)
256fn menu_bar(app: &mut App, ui: &mut Ui) {
257    ui.menu_bar();
258    if ui.menu_button("&File") {
259        if ui.menu_item("&Rename this window…\tF2").clicked {
260            app.renaming = Some(app.name.clone());
261        }
262        if ui.submenu("&Go to page") {
263            for (number, name) in PAGES.iter().enumerate() {
264                if ui.menu_item(name).clicked {
265                    app.page = number;
266                }
267            }
268            ui.close();
269        }
270        if ui.menu_item("&Open a file…").clicked {
271            app.file_dialog.pick(std::env::home_dir().unwrap_or_else(|| ".".into()));
272        }
273        ui.separator();
274        if ui.menu_item("&Close the window").clicked {
275            ui.quit();
276        }
277        ui.close();
278    }
279    if ui.menu_button("&View") {
280        ui.menu_checkbox(&mut app.light, "&Light colours");
281        ui.menu_checkbox(&mut app.tools.open, "The &Tools panel");
282        ui.menu_checkbox(&mut app.beside.open, "A &second window");
283        app.finding |= ui.menu_item("&Find a command\u{2026}\tCtrl+K").clicked;
284        // (The window over all of its screen, and back: ticked while it is.)
285        let mut whole = ui.full_screen();
286        if ui.menu_checkbox(&mut whole, "&Over all of the screen\tF11").changed {
287            ui.set_full_screen(whole);
288        }
289        // One of several, with a dot by the one that is selected; and the dock's panels that
290        // may be closed, ticked while they are open.
291        ui.separator();
292        ui.menu_radio(&mut app.room, 0, "Roo&my rows");
293        ui.menu_radio(&mut app.room, 1, "Tig&ht rows");
294        ui.separator();
295        for (name, _) in PANELS.iter().filter(|(_, closes)| *closes) {
296            let mut open = app.dock.is_open(name);
297            if ui.menu_checkbox(&mut open, name).changed {
298                app.dock.set_open(name, open);
299            }
300        }
301        ui.separator();
302        ui.menu_checkbox(&mut app.contrast, "High contrast");
303        ui.menu_checkbox(&mut app.system, "As the system has it");
304        if ui.submenu("Spacing") {
305            for (number, name) in SPACINGS.iter().enumerate() {
306                app.spacing = if ui.menu_checkbox(&mut (app.spacing == number), name).clicked { number } else { app.spacing };
307            }
308            ui.close();
309        }
310        ui.close();
311    }
312    ui.close();
313}
Source

pub fn set_open(&mut self, name: &str, open: bool)

Reopens a closed panel where it was, or closes one as its close button does. (For a menu that checks the open panels.)

Examples found in repository?
examples/gallery.rs (line 298)
256fn menu_bar(app: &mut App, ui: &mut Ui) {
257    ui.menu_bar();
258    if ui.menu_button("&File") {
259        if ui.menu_item("&Rename this window…\tF2").clicked {
260            app.renaming = Some(app.name.clone());
261        }
262        if ui.submenu("&Go to page") {
263            for (number, name) in PAGES.iter().enumerate() {
264                if ui.menu_item(name).clicked {
265                    app.page = number;
266                }
267            }
268            ui.close();
269        }
270        if ui.menu_item("&Open a file…").clicked {
271            app.file_dialog.pick(std::env::home_dir().unwrap_or_else(|| ".".into()));
272        }
273        ui.separator();
274        if ui.menu_item("&Close the window").clicked {
275            ui.quit();
276        }
277        ui.close();
278    }
279    if ui.menu_button("&View") {
280        ui.menu_checkbox(&mut app.light, "&Light colours");
281        ui.menu_checkbox(&mut app.tools.open, "The &Tools panel");
282        ui.menu_checkbox(&mut app.beside.open, "A &second window");
283        app.finding |= ui.menu_item("&Find a command\u{2026}\tCtrl+K").clicked;
284        // (The window over all of its screen, and back: ticked while it is.)
285        let mut whole = ui.full_screen();
286        if ui.menu_checkbox(&mut whole, "&Over all of the screen\tF11").changed {
287            ui.set_full_screen(whole);
288        }
289        // One of several, with a dot by the one that is selected; and the dock's panels that
290        // may be closed, ticked while they are open.
291        ui.separator();
292        ui.menu_radio(&mut app.room, 0, "Roo&my rows");
293        ui.menu_radio(&mut app.room, 1, "Tig&ht rows");
294        ui.separator();
295        for (name, _) in PANELS.iter().filter(|(_, closes)| *closes) {
296            let mut open = app.dock.is_open(name);
297            if ui.menu_checkbox(&mut open, name).changed {
298                app.dock.set_open(name, open);
299            }
300        }
301        ui.separator();
302        ui.menu_checkbox(&mut app.contrast, "High contrast");
303        ui.menu_checkbox(&mut app.system, "As the system has it");
304        if ui.submenu("Spacing") {
305            for (number, name) in SPACINGS.iter().enumerate() {
306                app.spacing = if ui.menu_checkbox(&mut (app.spacing == number), name).clicked { number } else { app.spacing };
307            }
308            ui.close();
309        }
310        ui.close();
311    }
312    ui.close();
313}
Source

pub fn only(self, names: &[&str]) -> Self

This dock without the panels not in names; their room goes to the others. For a layout saved earlier (see written) by an app that no longer has every panel; panels added since join the first tabs by themselves.

Trait Implementations§

Source§

impl Clone for Dock

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Dock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Dock

How a dock’s panels lie. Its places, separated by semicolons: t, the front tab, and the panels’ names; or s, whether the split is side by side, the first part’s share, and the numbers of the two parts; or g for a place that is gone. Then a bar and the floating panels, each as its name and a panel’s text. Then, if any, three more lists after bars: closed panels; the panel filling the dock; and where each floating or closed panel returns to: its name, the panel beside it, the side (0 to 3: left, top, right, bottom; 4: behind its tabs) and its share.

Source§

fn fmt(&self, to: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Dock

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

fn from_str(text: &str) -> Result<Self, ()>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Dock

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Dock

Auto Trait Implementations§

§

impl Forget for Dock

§

impl Freeze for Dock

§

impl Move for Dock

§

impl RefUnwindSafe for Dock

§

impl Send for Dock

§

impl Sync for Dock

§

impl Unpin for Dock

§

impl UnsafeUnpin for Dock

§

impl UnwindSafe for Dock

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.