SidebarWidget.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "SidebarWidget.h"
  7. #include "OutlineModel.h"
  8. #include <LibGUI/BoxLayout.h>
  9. #include <LibGUI/TabWidget.h>
  10. SidebarWidget::SidebarWidget()
  11. {
  12. set_fill_with_background_color(true);
  13. set_layout<GUI::VerticalBoxLayout>();
  14. set_enabled(false);
  15. auto& tab_bar = add<GUI::TabWidget>();
  16. auto& outline_container = tab_bar.add_tab<GUI::Widget>("Outline");
  17. outline_container.set_layout<GUI::VerticalBoxLayout>(4);
  18. m_outline_tree_view = outline_container.add<GUI::TreeView>();
  19. m_outline_tree_view->set_activates_on_selection(true);
  20. m_outline_tree_view->set_should_fill_selected_rows(true);
  21. m_outline_tree_view->set_selection_behavior(GUI::AbstractView::SelectionBehavior::SelectRows);
  22. m_outline_tree_view->on_selection_change = [this]() {
  23. auto& selection = m_outline_tree_view->selection();
  24. if (selection.is_empty())
  25. return;
  26. auto destination = OutlineModel::get_destination(selection.first());
  27. on_destination_selected(destination);
  28. };
  29. auto& thumbnails_container = tab_bar.add_tab<GUI::Widget>("Thumbnails");
  30. thumbnails_container.set_layout<GUI::VerticalBoxLayout>(4);
  31. // FIXME: Add thumbnail previews
  32. }