mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
Spreadsheet: Allow cells to optionally have static fg/bg colors
This commit is contained in:
parent
1674903dcc
commit
8fa385f774
Notes:
sideshowbarker
2024-07-19 02:43:30 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/8fa385f774c Pull-request: https://github.com/SerenityOS/serenity/pull/3463
3 changed files with 19 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "../Forward.h"
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/TextAlignment.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
|
@ -38,6 +39,8 @@ struct CellTypeMetadata {
|
|||
int length { -1 };
|
||||
String format;
|
||||
Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterRight };
|
||||
Optional<Gfx::Color> static_foreground_color;
|
||||
Optional<Gfx::Color> static_background_color;
|
||||
};
|
||||
|
||||
class CellType {
|
||||
|
|
|
@ -60,6 +60,8 @@ private:
|
|||
String m_format;
|
||||
HorizontalAlignment m_horizontal_alignment { HorizontalAlignment::Right };
|
||||
VerticalAlignment m_vertical_alignment { VerticalAlignment::Center };
|
||||
Optional<Color> m_static_foreground_color;
|
||||
Optional<Color> m_static_background_color;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue