1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use super::{WindowOptions, WindowPosition};
use crate::colors::TRANSPARENT;
use arcdps::imgui::{Condition, StyleColor, Ui, Window, WindowToken};

impl WindowOptions {
    /// Renders the window according to the options.
    pub fn render_window<'ui>(&mut self, ui: &'ui Ui, name: &str) -> Option<WindowToken<'ui>> {
        if self.visible {
            let size = [self.width, self.height];
            let pos = self.position.calc(ui, size);

            let _style = if !self.title_bar_background {
                Some((
                    ui.push_style_color(StyleColor::TitleBg, TRANSPARENT),
                    ui.push_style_color(StyleColor::TitleBgActive, TRANSPARENT),
                    ui.push_style_color(StyleColor::TitleBgCollapsed, TRANSPARENT),
                ))
            } else {
                None
            };

            Window::new(&name)
                .size(
                    size,
                    if self.auto_resize {
                        Condition::Never
                    } else {
                        Condition::Always
                    },
                )
                .position(
                    pos.unwrap_or_default(),
                    if let WindowPosition::Manual = self.position {
                        Condition::FirstUseEver
                    } else {
                        Condition::Always
                    },
                )
                .collapsible(false)
                .title_bar(self.title_bar)
                .draw_background(self.background)
                .always_auto_resize(self.auto_resize)
                .resizable(self.resize)
                .scrollable(self.scroll)
                .scroll_bar(self.scroll_bar)
                .focus_on_appearing(false)
                .opened(&mut self.visible)
                .begin(ui)
        } else {
            None
        }
    }
}