1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 10:04:59 +00:00

Help: Make section books open and close when toggled

Much more satisfying!
This commit is contained in:
thankyouverycool 2020-07-07 07:19:30 -04:00 committed by Andreas Kling
parent cbf3c2caeb
commit d86dbfe9e8
6 changed files with 27 additions and 1 deletions

View file

@ -42,7 +42,7 @@ static ManualSectionNode s_sections[] = {
ManualModel::ManualModel()
{
// FIXME: need some help from the icon fairy ^)
m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png"));
m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png"));
m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"));
}
@ -142,12 +142,20 @@ GUI::Variant ManualModel::data(const GUI::ModelIndex& index, Role role) const
case Role::Icon:
if (node->is_page())
return m_page_icon;
if (node->is_open())
return m_section_open_icon;
return m_section_icon;
default:
return {};
}
}
void ManualModel::update_section_node_on_toggle(const GUI::ModelIndex& index, const bool open)
{
auto* node = static_cast<ManualSectionNode*>(index.internal_data());
node->set_open(open);
}
void ManualModel::update()
{
did_update();