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
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
use crate::types::Color;

#[derive(Debug, Clone)]
pub struct Style {
    pub margin: f32,
    pub title_height: f32,

    pub scroll_width: f32,
    pub scroll_multiplier: f32,

    pub window_border_focused: Color,
    pub window_border_inactive: Color,

    pub window_background_focused: Color,
    pub window_background_inactive: Color,

    pub editbox_background_focused: Color,
    pub editbox_background_inactive: Color,

    pub scrollbar_background_focused_clicked: Color,
    pub scrollbar_background_focused_hovered: Color,
    pub scrollbar_background_focused: Color,
    pub scrollbar_background_focused_inactive: Color,

    pub inactive_title: Color,
    pub focused_title: Color,

    pub focused_text: Color,
    pub inactive_text: Color,

    pub margin_button: f32,
    pub button_background_focused: Color,
    pub button_background_focused_hovered: Color,
    pub button_background_focused_clicked: Color,
    pub button_background_inactive: Color,

    pub group_border_focused_hovered: Color,
    pub group_border_focused: Color,
    pub group_border_focused_highlight: Color,
    pub group_border_inactive_hovered: Color,
    pub group_border_inactive: Color,

    pub editbox_cursor_focused: Color,
    pub editbox_cursor_focused_inactive: Color,
    pub editbox_cursor_inactive: Color,

    pub separator_focused: Color,
    pub separator_inactive: Color,

    pub slider_bar_focused: Color,
    pub slider_bar_hovered: Color,
    pub slider_bar_inactive: Color,

    pub selection_background_focused: Color,
    pub selection_background_inactive: Color,
}

impl Default for Style {
    fn default() -> Self {
        Style {
            margin: 2.0,
            title_height: 14.0,
            scroll_width: 10.0,
            scroll_multiplier: 3.,
            window_border_focused: Color::from_rgb(68, 68, 68),
            window_border_inactive: Color::from_rgba(102, 102, 102, 127),
            window_background_focused: Color::from_rgba(238, 238, 238, 255),
            window_background_inactive: Color::from_rgba(238, 238, 238, 128),
            editbox_background_focused: Color::from_rgba(200, 200, 200, 255),
            editbox_background_inactive: Color::from_rgba(200, 200, 200, 128),
            scrollbar_background_focused_clicked: Color::from_rgba(170, 170, 170, 235),
            scrollbar_background_focused_hovered: Color::from_rgba(180, 180, 180, 235),
            scrollbar_background_focused: Color::from_rgba(204, 204, 204, 235),
            scrollbar_background_focused_inactive: Color::from_rgba(204, 204, 204, 128),
            inactive_title: Color::from_rgba(102, 102, 102, 128),
            focused_title: Color::from_rgba(0, 0, 0, 255),
            focused_text: Color::from_rgba(0, 0, 0, 255),
            inactive_text: Color::from_rgba(102, 102, 102, 127),
            margin_button: 3.,
            button_background_focused: Color::from_rgba(204, 204, 204, 235),
            button_background_focused_hovered: Color::from_rgba(170, 170, 170, 235),
            button_background_focused_clicked: Color::from_rgba(187, 187, 187, 255),
            button_background_inactive: Color::from_rgba(204, 204, 204, 127),
            group_border_focused_hovered: Color::from_rgba(34, 153, 34, 68),
            group_border_focused: Color::from_rgba(34, 34, 34, 68),
            group_border_focused_highlight: Color::from_rgba(34, 34, 255, 255),
            group_border_inactive_hovered: Color::from_rgba(17, 136, 17, 34),
            group_border_inactive: Color::from_rgba(17, 17, 17, 34),

            editbox_cursor_focused: Color::from_rgba(0, 0, 0, 235),
            editbox_cursor_focused_inactive: Color::from_rgba(220, 220, 220, 235),
            editbox_cursor_inactive: Color::from_rgba(50, 50, 50, 34),

            separator_focused: Color::from_rgba(180, 180, 180, 235),
            separator_inactive: Color::from_rgba(180, 180, 180, 134),

            slider_bar_focused: Color::from_rgba(100, 100, 100, 255),
            slider_bar_hovered: Color::from_rgba(220, 220, 220, 255),
            slider_bar_inactive: Color::from_rgba(100, 100, 100, 34),

	    selection_background_focused: Color::from_rgba(100, 100, 100, 100),
	    selection_background_inactive: Color::from_rgba(100, 100, 100, 36),
        }
    }
}

impl Style {
    pub fn window_border(&self, focused: bool) -> Color {
        if focused {
            self.window_border_focused
        } else {
            self.window_border_inactive
        }
    }

    pub fn background(&self, focused: bool) -> Color {
        if focused {
            self.window_background_focused
        } else {
            self.window_background_inactive
        }
    }

    pub fn editbox_background(&self, focused: bool) -> Color {
        if focused {
            self.editbox_background_focused
        } else {
            self.editbox_background_inactive
        }
    }

    pub fn scroll_bar_handle(&self, focused: bool, hovered: bool, clicked: bool) -> Color {
        if focused {
            if clicked {
                self.scrollbar_background_focused_clicked
            } else if hovered {
                self.scrollbar_background_focused_hovered
            } else {
                self.scrollbar_background_focused
            }
        } else {
            self.scrollbar_background_focused_inactive
        }
    }

    pub fn title(&self, focused: bool) -> Color {
        if focused {
            self.focused_title
        } else {
            self.inactive_title
        }
    }

    pub fn text(&self, focused: bool) -> Color {
        if focused {
            self.focused_text
        } else {
            self.inactive_text
        }
    }

    pub fn button_background(&self, focused: bool, hovered: bool, clicked: bool) -> Color {
        if focused {
            if clicked {
                self.button_background_focused_clicked
            } else if hovered {
                self.button_background_focused_hovered
            } else {
                self.button_background_focused
            }
        } else {
            self.button_background_inactive
        }
    }

    pub fn drag_border(&self, focused: bool, hovered: bool, highlight: bool) -> Color {
        if focused {
            if hovered {
                self.group_border_focused_hovered
            } else {
                if highlight {
                    self.group_border_focused_highlight
                } else {
                    self.group_border_focused
                }
            }
        } else {
            if hovered {
                self.group_border_inactive_hovered
            } else {
                self.group_border_inactive
            }
        }
    }

    pub fn tabbar_background(
        &self,
        focused: bool,
        selected: bool,
        hovered: bool,
        clicked: bool,
    ) -> Color {
        if focused {
            if clicked {
                self.button_background_focused_clicked
            } else if hovered {
                self.button_background_focused
            } else {
                if selected {
                    self.button_background_focused_hovered
                } else {
                    self.button_background_inactive
                }
            }
        } else {
            self.button_background_inactive
        }
    }

    pub fn editbox_cursor(&self, focused: bool, input_focus: bool) -> Color {
        if focused && input_focus {
            self.editbox_cursor_focused
        } else if input_focus {
            self.editbox_cursor_focused_inactive
        } else {
            self.editbox_cursor_inactive
        }
    }

    pub fn separator(&self, focused: bool) -> Color {
        if focused {
            self.separator_focused
        } else {
            self.separator_inactive
        }
    }

    pub fn slider_bar(&self, focused: bool, hovered: bool) -> Color {
        if focused && hovered {
            self.slider_bar_hovered
        } else if focused {
            self.slider_bar_focused
        } else {
            self.slider_bar_inactive
        }
    }

    pub fn selection_background(&self, focused: bool) -> Color {
	if focused {
	    self.selection_background_focused
	} else {
	    self.selection_background_inactive
	}
    }
}