Skip to content

Commit

Permalink
Fluent: minor cleanups
Browse files Browse the repository at this point in the history
- use a singular value in colors
- remove a few todo.
  • Loading branch information
diegoiast committed Mar 29, 2024
1 parent a3df98a commit f77dd64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/themes/fluent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "themes/fluent.h"

auto ThemeFluent::get_light_colors(int32_t accent) -> ColorStyle {
// https://learn.microsoft.com/en-us/windows/apps/design/signature-experiences/color
auto background = MakeColor(243, 243, 243);
auto normal = MakeColor(229, 229, 229);
auto disabled = Darker(normal);
Expand All @@ -17,32 +16,32 @@ auto ThemeFluent::get_light_colors(int32_t accent) -> ColorStyle {
colors.window_background = background;

colors.frame_normal_color1 = normal;
colors.frame_normal_color2 = colors.frame_normal_color1;
colors.frame_normal_color3 = colors.frame_normal_color1;
colors.frame_normal_color4 = colors.frame_normal_color1;
colors.frame_normal_color2 = normal;
colors.frame_normal_color3 = normal;
colors.frame_normal_color4 = normal;

colors.frame_hover_color1 = colors.frame_normal_color1;
colors.frame_hover_color2 = colors.frame_hover_color1;
colors.frame_hover_color3 = colors.frame_hover_color1;
colors.frame_hover_color4 = colors.frame_hover_color1;
colors.frame_hover_color1 = normal;
colors.frame_hover_color2 = normal;
colors.frame_hover_color3 = normal;
colors.frame_hover_color4 = normal;

colors.frame_selected_color1 = (accent);
colors.frame_selected_color2 = colors.frame_selected_color1;
colors.frame_selected_color3 = colors.frame_selected_color1;
colors.frame_selected_color4 = colors.frame_selected_color1;
colors.frame_selected_color1 = accent;
colors.frame_selected_color2 = normal;
colors.frame_selected_color3 = normal;
colors.frame_selected_color4 = normal;

colors.frame_disabled_color1 = disabled;
colors.frame_disabled_color2 = colors.frame_disabled_color1;
colors.frame_disabled_color3 = colors.frame_disabled_color1;
colors.frame_disabled_color4 = colors.frame_disabled_color1;
colors.frame_disabled_color2 = disabled;
colors.frame_disabled_color3 = disabled;
colors.frame_disabled_color4 = disabled;

colors.input_background_normal = MakeColor(255, 255, 255);
colors.input_background_hover = MakeColor(252, 252, 252);
colors.input_background_disabled = colors.input_background_normal;
colors.input_background_selected = accent;

colors.button_background_1 = MakeColor(251, 251, 251);
colors.button_background_2 = MakeColor(253, 253, 253);
colors.button_background_2 = colors.button_background_1;
colors.button_selected_background = accent;
colors.button_selected_text = MakeColor(255, 255, 255);

Expand Down Expand Up @@ -242,15 +241,14 @@ auto ThemeFluent::draw_checkbox(Bitmap &content, bool has_focus, bool is_enabled
}

auto ThemeFluent::draw_input_background(Bitmap &content, const bool has_focus) -> void {
// TODO - padding should be the frame size
auto background = has_focus ? colors.input_background_hover : colors.input_background_normal;

auto margin_bottom = 1;
content.fill(background);
auto frame_size = content.size;
frame_size.height -= margin_bottom;

content.line(0, content.size.height - 2, content.size.width, content.size.height - 2,
content.fill(background);
frame_size.height -= margin_bottom;
content.line(0, content.size.height - margin_bottom * 2, content.size.width,
content.size.height - margin_bottom * 2,
has_focus ? colors.text_selection_background : Darker(background, 0.1));
}

Expand All @@ -274,10 +272,9 @@ void ThemeFluent::draw_listview_item(Bitmap &content, const std::string_view tex
background_color = colors.text_selection_background_hover;
content.fill(background_color);

// TODO properly center
auto text_padding = 5;
auto text_size = font.text_size(text);
auto centered = Position{text_padding, text_padding};
auto centered = content.size.centeredY(text_size, text_padding);
font.write(content, centered, text, text_color);
}

Expand Down
1 change: 1 addition & 0 deletions src/themes/fluent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// Theme reference is found here (we try to match as possible look and feel):
// https://developer.microsoft.com/en-us/fluentui?fabricVer=6#/controls/web/button
// https://learn.microsoft.com/en-us/windows/apps/design/signature-experiences/color

#include <theme.h>

Expand Down

0 comments on commit f77dd64

Please sign in to comment.