Skip to content

Commit 863d857

Browse files
committed
remove gradient animation
1 parent b9b7ef5 commit 863d857

File tree

2 files changed

+24
-41
lines changed

2 files changed

+24
-41
lines changed

src/backends/fltk_button.rs

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cell::RefCell;
22
use std::rc::Rc;
33

4-
use fltk::{app, widget, widget_extends, draw::*};
4+
use fltk::{app, draw::*, widget, widget_extends};
55
use fltk::enums::{Color, Event, FrameType, Key};
66
use fltk::prelude::{WidgetBase, WidgetExt};
77
use mina::{Animate, prelude::*};
@@ -17,13 +17,9 @@ struct ButtonColorState {
1717
border_g: u8,
1818
border_b: u8,
1919

20-
fill1_r: u8,
21-
fill1_g: u8,
22-
fill1_b: u8,
23-
24-
fill2_r: u8,
25-
fill2_g: u8,
26-
fill2_b: u8,
20+
fill_r: u8,
21+
fill_g: u8,
22+
fill_b: u8,
2723

2824
text_r: u8,
2925
text_g: u8,
@@ -32,7 +28,6 @@ struct ButtonColorState {
3228

3329
pub struct CustomButton {
3430
inner: widget::Widget,
35-
// state: Rc<RefCell<ButtonColorState>>,
3631
}
3732

3833
#[derive(Clone, Default, PartialEq, State)]
@@ -129,12 +124,9 @@ impl CustomButton {
129124
border_r: dialog_theme.style_button_inactive.color_button_border.to_rgb().0,
130125
border_g: dialog_theme.style_button_inactive.color_button_border.to_rgb().1,
131126
border_b: dialog_theme.style_button_inactive.color_button_border.to_rgb().2,
132-
fill1_r: dialog_theme.style_button_inactive.color_button_background.0.to_rgb().0,
133-
fill1_g: dialog_theme.style_button_inactive.color_button_background.0.to_rgb().1,
134-
fill1_b: dialog_theme.style_button_inactive.color_button_background.0.to_rgb().2,
135-
fill2_r: dialog_theme.style_button_inactive.color_button_background.1.to_rgb().0,
136-
fill2_g: dialog_theme.style_button_inactive.color_button_background.1.to_rgb().1,
137-
fill2_b: dialog_theme.style_button_inactive.color_button_background.1.to_rgb().2,
127+
fill_r: dialog_theme.style_button_inactive.color_button_background.to_rgb().0,
128+
fill_g: dialog_theme.style_button_inactive.color_button_background.to_rgb().1,
129+
fill_b: dialog_theme.style_button_inactive.color_button_background.to_rgb().2,
138130
text_r: dialog_theme.style_button_inactive.color_button_text.to_rgb().0,
139131
text_g: dialog_theme.style_button_inactive.color_button_text.to_rgb().1,
140132
text_b: dialog_theme.style_button_inactive.color_button_text.to_rgb().2,
@@ -146,12 +138,9 @@ impl CustomButton {
146138
border_r: dialog_theme.style_button_hover.color_button_border.to_rgb().0,
147139
border_g: dialog_theme.style_button_hover.color_button_border.to_rgb().1,
148140
border_b: dialog_theme.style_button_hover.color_button_border.to_rgb().2,
149-
fill1_r: dialog_theme.style_button_hover.color_button_background.0.to_rgb().0,
150-
fill1_g: dialog_theme.style_button_hover.color_button_background.0.to_rgb().1,
151-
fill1_b: dialog_theme.style_button_hover.color_button_background.0.to_rgb().2,
152-
fill2_r: dialog_theme.style_button_hover.color_button_background.1.to_rgb().0,
153-
fill2_g: dialog_theme.style_button_hover.color_button_background.1.to_rgb().1,
154-
fill2_b: dialog_theme.style_button_hover.color_button_background.1.to_rgb().2,
141+
fill_r: dialog_theme.style_button_hover.color_button_background.to_rgb().0,
142+
fill_g: dialog_theme.style_button_hover.color_button_background.to_rgb().1,
143+
fill_b: dialog_theme.style_button_hover.color_button_background.to_rgb().2,
155144
text_r: dialog_theme.style_button_hover.color_button_text.to_rgb().0,
156145
text_g: dialog_theme.style_button_hover.color_button_text.to_rgb().1,
157146
text_b: dialog_theme.style_button_hover.color_button_text.to_rgb().2,
@@ -162,12 +151,9 @@ impl CustomButton {
162151
border_r: dialog_theme.style_button_pressed.color_button_border.to_rgb().0,
163152
border_g: dialog_theme.style_button_pressed.color_button_border.to_rgb().1,
164153
border_b: dialog_theme.style_button_pressed.color_button_border.to_rgb().2,
165-
fill1_r: dialog_theme.style_button_pressed.color_button_background.0.to_rgb().0,
166-
fill1_g: dialog_theme.style_button_pressed.color_button_background.0.to_rgb().1,
167-
fill1_b: dialog_theme.style_button_pressed.color_button_background.0.to_rgb().2,
168-
fill2_r: dialog_theme.style_button_pressed.color_button_background.1.to_rgb().0,
169-
fill2_g: dialog_theme.style_button_pressed.color_button_background.1.to_rgb().1,
170-
fill2_b: dialog_theme.style_button_pressed.color_button_background.1.to_rgb().2,
154+
fill_r: dialog_theme.style_button_pressed.color_button_background.to_rgb().0,
155+
fill_g: dialog_theme.style_button_pressed.color_button_background.to_rgb().1,
156+
fill_b: dialog_theme.style_button_pressed.color_button_background.to_rgb().2,
171157
text_r: dialog_theme.style_button_pressed.color_button_text.to_rgb().0,
172158
text_g: dialog_theme.style_button_pressed.color_button_text.to_rgb().1,
173159
text_b: dialog_theme.style_button_pressed.color_button_text.to_rgb().2,
@@ -178,12 +164,9 @@ impl CustomButton {
178164
border_r: dialog_theme.style_button_focused.color_button_border.to_rgb().0,
179165
border_g: dialog_theme.style_button_focused.color_button_border.to_rgb().1,
180166
border_b: dialog_theme.style_button_focused.color_button_border.to_rgb().2,
181-
fill1_r: dialog_theme.style_button_focused.color_button_background.0.to_rgb().0,
182-
fill1_g: dialog_theme.style_button_focused.color_button_background.0.to_rgb().1,
183-
fill1_b: dialog_theme.style_button_focused.color_button_background.0.to_rgb().2,
184-
fill2_r: dialog_theme.style_button_focused.color_button_background.1.to_rgb().0,
185-
fill2_g: dialog_theme.style_button_focused.color_button_background.1.to_rgb().1,
186-
fill2_b: dialog_theme.style_button_focused.color_button_background.1.to_rgb().2,
167+
fill_r: dialog_theme.style_button_focused.color_button_background.to_rgb().0,
168+
fill_g: dialog_theme.style_button_focused.color_button_background.to_rgb().1,
169+
fill_b: dialog_theme.style_button_focused.color_button_background.to_rgb().2,
187170
text_r: dialog_theme.style_button_focused.color_button_text.to_rgb().0,
188171
text_g: dialog_theme.style_button_focused.color_button_text.to_rgb().1,
189172
text_b: dialog_theme.style_button_focused.color_button_text.to_rgb().2,
@@ -274,7 +257,7 @@ impl CustomButton {
274257
let state = animator.current_values();
275258

276259
draw_box(FrameType::FlatBox, i.x(), i.y(), i.w(), i.h(), Color::Background2);
277-
draw_improved_rbox(i.x(), i.y(), i.w(), i.h(), state.border_radius, true, Color::from_rgb(state.fill1_r, state.fill1_g, state.fill1_b));
260+
draw_improved_rbox(i.x(), i.y(), i.w(), i.h(), state.border_radius, true, Color::from_rgb(state.fill_r, state.fill_g, state.fill_b));
278261
draw_improved_rbox(i.x(), i.y(), i.w(), i.h(), state.border_radius, false, Color::from_rgb(state.border_r, state.border_g, state.border_b));
279262

280263
set_font(i.label_font(), i.label_size());

src/backends/fltk_theme.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::fltk_fonts::*;
99
pub struct DialogButtonStyle {
1010
pub color_button_border: Color,
1111
pub color_button_text: Color,
12-
pub color_button_background: (Color, Color),
12+
pub color_button_background: Color,
1313
pub border_radius: i32,
1414
pub border_width: i32,
1515
}
@@ -85,31 +85,31 @@ pub fn apply_windows_theme(app_instance: &App) -> DialogTheme {
8585

8686
style_button_inactive: DialogButtonStyle {
8787
color_button_border: Color::from_hex(0xD0D0D0),
88-
color_button_background: (Color::from_hex(0xFDFDFD), Color::from_hex(0xFDFDFD)),
88+
color_button_background: Color::from_hex(0xFDFDFD),
8989
color_button_text: Color::from_hex(0x000000),
9090
border_radius: 3,
9191
border_width: 1,
9292
},
9393

9494
style_button_hover: DialogButtonStyle {
9595
color_button_border: Color::from_hex(0x0078D4),
96-
color_button_background: (Color::from_hex(0xE0EEF9), Color::from_hex(0xE0EEF9)),
96+
color_button_background: Color::from_hex(0xE0EEF9),
9797
color_button_text: Color::from_hex(0x000000),
9898
border_radius: 3,
9999
border_width: 1,
100100
},
101101

102102
style_button_pressed: DialogButtonStyle {
103103
color_button_border: Color::from_hex(0x005499),
104-
color_button_background: (Color::from_hex(0xCCE4F7), Color::from_hex(0xCCE4F7)),
104+
color_button_background: Color::from_hex(0xCCE4F7),
105105
color_button_text: Color::from_hex(0x000000),
106106
border_radius: 3,
107107
border_width: 1,
108108
},
109109

110110
style_button_focused: DialogButtonStyle {
111111
color_button_border: Color::from_hex(0x0078D4),
112-
color_button_background: (Color::from_hex(0xFDFDFD), Color::from_hex(0xFDFDFD)),
112+
color_button_background: Color::from_hex(0xFDFDFD),
113113
color_button_text: Color::from_hex(0x000000),
114114
border_radius: 3,
115115
border_width: 1,
@@ -120,14 +120,14 @@ pub fn apply_windows_theme(app_instance: &App) -> DialogTheme {
120120
pub fn apply_ubuntu_theme(app_instance: &App) -> DialogTheme {
121121
load_ubuntu_fonts(app_instance);
122122
app::set_frame_type_cb(FrameType::ThinUpBox, thin_up_box_noop_cb, 0, 0, 0, 0);
123-
123+
124124
todo!();
125125
}
126126

127127
pub fn apply_macos_theme(app_instance: &App, dark: bool) -> DialogTheme {
128128
load_macos_fonts(app_instance);
129129
app::set_frame_type_cb(FrameType::ThinUpBox, thin_up_box_noop_cb, 0, 0, 0, 0);
130-
130+
131131
todo!();
132132
}
133133

0 commit comments

Comments
 (0)