mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
LibDraw: Add Selection and SelectionText system theme colors
This commit is contained in:
parent
033de7efe2
commit
b6eba388e3
16 changed files with 43 additions and 22 deletions
|
@ -35,6 +35,12 @@ Color::Color(SystemColor system_color)
|
|||
case SystemColor::HoverHighlight:
|
||||
m_value = theme.hover_highlight.value();
|
||||
break;
|
||||
case SystemColor::Selection:
|
||||
m_value = theme.selection.value();
|
||||
break;
|
||||
case SystemColor::SelectionText:
|
||||
m_value = theme.selection_text.value();
|
||||
break;
|
||||
case SystemColor::DesktopBackground:
|
||||
m_value = theme.desktop_background.value();
|
||||
break;
|
||||
|
|
|
@ -37,6 +37,8 @@ enum class SystemColor {
|
|||
ThreedShadow1,
|
||||
ThreedShadow2,
|
||||
HoverHighlight,
|
||||
Selection,
|
||||
SelectionText,
|
||||
|
||||
DisabledText = ThreedShadow1,
|
||||
};
|
||||
|
|
|
@ -46,6 +46,8 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
|
|||
data->threed_shadow1 = get("ThreedShadow1");
|
||||
data->threed_shadow2 = get("ThreedShadow2");
|
||||
data->hover_highlight = get("HoverHighlight");
|
||||
data->selection = get("Selection");
|
||||
data->selection_text = get("SelectionText");
|
||||
data->window = get("Window");
|
||||
data->window_text = get("WindowText");
|
||||
data->base = get("Base");
|
||||
|
|
|
@ -38,6 +38,9 @@ struct SystemTheme {
|
|||
Color threed_shadow2;
|
||||
|
||||
Color hover_highlight;
|
||||
|
||||
Color selection;
|
||||
Color selection_text;
|
||||
};
|
||||
|
||||
const SystemTheme& current_system_theme();
|
||||
|
|
|
@ -201,7 +201,7 @@ void GItemView::paint_event(GPaintEvent& event)
|
|||
bool is_selected_item = selection().contains(model()->index(item_index, m_model_column));
|
||||
Color background_color;
|
||||
if (is_selected_item) {
|
||||
background_color = is_focused() ? Color::from_rgb(0x84351a) : Color::from_rgb(0x606060);
|
||||
background_color = is_focused() ? Color(SystemColor::Selection) : Color::from_rgb(0x606060);
|
||||
} else {
|
||||
background_color = SystemColor::Base;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ void GItemView::paint_event(GPaintEvent& event)
|
|||
|
||||
Color text_color;
|
||||
if (is_selected_item)
|
||||
text_color = Color::White;
|
||||
text_color = SystemColor::SelectionText;
|
||||
else
|
||||
text_color = model()->data(model_index, GModel::Role::ForegroundColor).to_color(SystemColor::WindowText);
|
||||
painter.fill_rect(text_rect, background_color);
|
||||
|
|
|
@ -104,7 +104,7 @@ void GListView::paint_event(GPaintEvent& event)
|
|||
|
||||
Color background_color;
|
||||
if (is_selected_row) {
|
||||
background_color = is_focused() ? Color::from_rgb(0x84351a) : Color::from_rgb(0x606060);
|
||||
background_color = is_focused() ? Color(SystemColor::SelectionText) : Color::from_rgb(0x606060);
|
||||
} else {
|
||||
if (alternating_row_colors() && (painted_item_index % 2))
|
||||
background_color = Color(210, 210, 210);
|
||||
|
|
|
@ -53,8 +53,8 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
Color background_color;
|
||||
Color key_column_background_color;
|
||||
if (is_selected_row) {
|
||||
background_color = is_focused() ? Color::from_rgb(0x84351a) : Color::from_rgb(0x606060);
|
||||
key_column_background_color = is_focused() ? Color::from_rgb(0x84351a) : Color::from_rgb(0x606060);
|
||||
background_color = is_focused() ? Color(SystemColor::Selection) : Color::from_rgb(0x606060);
|
||||
key_column_background_color = is_focused() ? Color(SystemColor::Selection) : Color::from_rgb(0x606060);
|
||||
} else {
|
||||
if (alternating_row_colors() && (painted_item_index % 2)) {
|
||||
background_color = Color(SystemColor::Base).darkened(0.8f);
|
||||
|
@ -93,7 +93,7 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
} else {
|
||||
Color text_color;
|
||||
if (is_selected_row)
|
||||
text_color = Color::White;
|
||||
text_color = SystemColor::SelectionText;
|
||||
else
|
||||
text_color = model()->data(cell_index, GModel::Role::ForegroundColor).to_color(SystemColor::WindowText);
|
||||
painter.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, TextElision::Right);
|
||||
|
|
|
@ -424,7 +424,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
visual_line_rect.height()
|
||||
};
|
||||
|
||||
painter.fill_rect(selection_rect, Color::from_rgb(0x955233));
|
||||
painter.fill_rect(selection_rect, SystemColor::Selection);
|
||||
|
||||
size_t start_of_selection_within_visual_line = (size_t)max(0, (int)selection_start_column_within_line - (int)start_of_visual_line);
|
||||
size_t end_of_selection_within_visual_line = selection_end_column_within_line - start_of_visual_line;
|
||||
|
@ -434,7 +434,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
end_of_selection_within_visual_line - start_of_selection_within_visual_line
|
||||
};
|
||||
|
||||
painter.draw_text(selection_rect, visual_selected_text, TextAlignment::CenterLeft, Color::White);
|
||||
painter.draw_text(selection_rect, visual_selected_text, TextAlignment::CenterLeft, SystemColor::SelectionText);
|
||||
}
|
||||
}
|
||||
++visual_line_index;
|
||||
|
|
|
@ -185,8 +185,8 @@ void GTreeView::paint_event(GPaintEvent& event)
|
|||
Color background_color;
|
||||
Color key_column_background_color;
|
||||
if (is_selected_row) {
|
||||
background_color = is_focused() ? Color::from_rgb(0x84351a) : Color::from_rgb(0x606060);
|
||||
key_column_background_color = is_focused() ? Color::from_rgb(0x84351a) : Color::from_rgb(0x606060);
|
||||
background_color = is_focused() ? Color(SystemColor::Selection) : Color::from_rgb(0x606060);
|
||||
key_column_background_color = is_focused() ? Color(SystemColor::Selection) : Color::from_rgb(0x606060);
|
||||
} else {
|
||||
if (alternating_row_colors() && (painted_row_index % 2)) {
|
||||
background_color = Color(220, 220, 220);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue