diff --git a/Applications/Spreadsheet/CellType/Type.h b/Applications/Spreadsheet/CellType/Type.h index cb07a8a262..2797c3e221 100644 --- a/Applications/Spreadsheet/CellType/Type.h +++ b/Applications/Spreadsheet/CellType/Type.h @@ -29,6 +29,7 @@ #include "../Forward.h" #include #include +#include #include #include @@ -38,6 +39,8 @@ struct CellTypeMetadata { int length { -1 }; String format; Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterRight }; + Optional static_foreground_color; + Optional static_background_color; }; class CellType { diff --git a/Applications/Spreadsheet/CellTypeDialog.h b/Applications/Spreadsheet/CellTypeDialog.h index 84ccbc8613..73ee09b608 100644 --- a/Applications/Spreadsheet/CellTypeDialog.h +++ b/Applications/Spreadsheet/CellTypeDialog.h @@ -60,6 +60,8 @@ private: String m_format; HorizontalAlignment m_horizontal_alignment { HorizontalAlignment::Right }; VerticalAlignment m_vertical_alignment { VerticalAlignment::Center }; + Optional m_static_foreground_color; + Optional m_static_background_color; }; } diff --git a/Applications/Spreadsheet/SpreadsheetModel.cpp b/Applications/Spreadsheet/SpreadsheetModel.cpp index 84eb2b7198..50976aa1fd 100644 --- a/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -85,6 +85,20 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) return Color(Color::Red); } + if (auto color = cell->type_metadata().static_foreground_color; color.has_value()) + return color.value(); + + return {}; + } + + if (role == GUI::ModelRole::BackgroundColor) { + const auto* cell = m_sheet->at({ m_sheet->column(index.column()), (size_t)index.row() }); + if (!cell) + return {}; + + if (auto color = cell->type_metadata().static_background_color; color.has_value()) + return color.value(); + return {}; }