mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:25:10 +00:00
GTableView: Add a way to turn off alternating row colors.
This commit is contained in:
parent
491aa112ab
commit
b54ab06595
5 changed files with 15 additions and 7 deletions
|
@ -49,6 +49,7 @@ void IRCAppWindow::setup_widgets()
|
|||
|
||||
auto* window_list = new GTableView(widget);
|
||||
window_list->set_headers_visible(false);
|
||||
window_list->set_alternating_row_colors(false);
|
||||
window_list->set_model(OwnPtr<IRCClientWindowListModel>(m_client.client_window_list_model()));
|
||||
window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
window_list->set_preferred_size({ 120, 0 });
|
||||
|
|
|
@ -16,19 +16,21 @@ IRCClientWindow::IRCClientWindow(IRCClient& client, Type type, const String& nam
|
|||
{
|
||||
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
||||
// Make a container for the log buffer view + optional member list.
|
||||
// Make a container for the log buffer view + (optional) member list.
|
||||
GWidget* container = new GWidget(this);
|
||||
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
|
||||
m_table_view = new GTableView(container);
|
||||
m_table_view->set_headers_visible(false);
|
||||
m_table_view->set_font(Font::default_fixed_width_font());
|
||||
m_table_view->set_alternating_row_colors(false);
|
||||
|
||||
if (m_type == Channel) {
|
||||
auto* member_view = new GTableView(container);
|
||||
member_view->set_headers_visible(false);
|
||||
member_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
member_view->set_preferred_size({ 100, 0 });
|
||||
member_view->set_alternating_row_colors(false);
|
||||
member_view->set_model(OwnPtr<IRCChannelMemberListModel>(m_client.ensure_channel(m_name).member_model()));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@ public:
|
|||
|
||||
int count() const { return m_messages.size(); }
|
||||
const Message& at(int index) const { return m_messages.at(index); }
|
||||
|
||||
void add_message(char prefix, const String& name, const String& text);
|
||||
|
||||
void dump() const;
|
||||
|
||||
const IRCLogBufferModel* model() const { return m_model; }
|
||||
|
@ -31,8 +29,6 @@ public:
|
|||
|
||||
private:
|
||||
IRCLogBuffer();
|
||||
|
||||
IRCLogBufferModel* m_model { nullptr };
|
||||
|
||||
CircularQueue<Message, 1000> m_messages;
|
||||
};
|
||||
|
|
|
@ -157,8 +157,13 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
key_column_background_color = is_focused() ? Color::from_rgb(0x84351a) : Color::from_rgb(0x606060);
|
||||
text_color = Color::White;
|
||||
} else {
|
||||
background_color = painted_item_index % 2 ? Color(210, 210, 210) : Color::White;
|
||||
key_column_background_color = painted_item_index % 2 ? Color(190, 190, 190) : Color(235, 235, 235);
|
||||
if (alternating_row_colors() && (painted_item_index % 2)) {
|
||||
background_color = Color(210, 210, 210);
|
||||
key_column_background_color = Color(190, 190, 190);
|
||||
} else {
|
||||
background_color = Color::White;
|
||||
key_column_background_color = Color(235, 235, 235);
|
||||
}
|
||||
text_color = Color::Black;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ public:
|
|||
bool headers_visible() const { return m_headers_visible; }
|
||||
void set_headers_visible(bool headers_visible) { m_headers_visible = headers_visible; }
|
||||
|
||||
bool alternating_row_colors() const { return m_alternating_row_colors; }
|
||||
void set_alternating_row_colors(bool b) { m_alternating_row_colors = b; }
|
||||
|
||||
void did_update_model();
|
||||
|
||||
int content_width() const;
|
||||
|
@ -54,4 +57,5 @@ private:
|
|||
OwnPtr<GTableModel> m_model;
|
||||
int m_horizontal_padding { 5 };
|
||||
bool m_headers_visible { true };
|
||||
bool m_alternating_row_colors { true };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue