mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:45:07 +00:00
LibGUI: Simplify setup code in GUI::MultiView
Use for_each_view_implementation() to avoid duplicating the setup code for each subview.
This commit is contained in:
parent
71663a9431
commit
3eba01a02d
1 changed files with 18 additions and 51 deletions
|
@ -43,57 +43,24 @@ MultiView::MultiView()
|
|||
m_table_view = add<TableView>();
|
||||
m_columns_view = add<ColumnsView>();
|
||||
|
||||
m_icon_view->on_activation = [&](auto& index) {
|
||||
if (on_activation)
|
||||
on_activation(index);
|
||||
};
|
||||
m_columns_view->on_activation = [&](auto& index) {
|
||||
if (on_activation)
|
||||
on_activation(index);
|
||||
};
|
||||
m_table_view->on_activation = [&](auto& index) {
|
||||
if (on_activation)
|
||||
on_activation(index);
|
||||
};
|
||||
|
||||
m_table_view->on_selection_change = [this] {
|
||||
if (on_selection_change)
|
||||
on_selection_change();
|
||||
};
|
||||
m_icon_view->on_selection_change = [this] {
|
||||
if (on_selection_change)
|
||||
on_selection_change();
|
||||
};
|
||||
m_columns_view->on_selection_change = [this] {
|
||||
if (on_selection_change)
|
||||
on_selection_change();
|
||||
};
|
||||
|
||||
m_table_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||
if (on_context_menu_request)
|
||||
on_context_menu_request(index, event);
|
||||
};
|
||||
m_icon_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||
if (on_context_menu_request)
|
||||
on_context_menu_request(index, event);
|
||||
};
|
||||
m_columns_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||
if (on_context_menu_request)
|
||||
on_context_menu_request(index, event);
|
||||
};
|
||||
|
||||
m_table_view->on_drop = [this](auto& index, auto& event) {
|
||||
if (on_drop)
|
||||
on_drop(index, event);
|
||||
};
|
||||
m_icon_view->on_drop = [this](auto& index, auto& event) {
|
||||
if (on_drop)
|
||||
on_drop(index, event);
|
||||
};
|
||||
m_columns_view->on_drop = [this](auto& index, auto& event) {
|
||||
if (on_drop)
|
||||
on_drop(index, event);
|
||||
};
|
||||
for_each_view_implementation([&](auto& view) {
|
||||
view.on_activation = [this](auto& index) {
|
||||
if (on_activation)
|
||||
on_activation(index);
|
||||
};
|
||||
view.on_selection_change = [this] {
|
||||
if (on_selection_change)
|
||||
on_selection_change();
|
||||
};
|
||||
view.on_context_menu_request = [this](auto& index, auto& event) {
|
||||
if (on_context_menu_request)
|
||||
on_context_menu_request(index, event);
|
||||
};
|
||||
view.on_drop = [this](auto& index, auto& event) {
|
||||
if (on_drop)
|
||||
on_drop(index, event);
|
||||
};
|
||||
});
|
||||
|
||||
build_actions();
|
||||
set_view_mode(ViewMode::Icon);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue