| 112 | }; |
| 113 | |
| 114 | DevtoolsLayoutTab::DevtoolsLayoutTab(AWindowBase* targetWindow) : mTargetWindow(targetWindow) { |
| 115 | using namespace declarative; |
| 116 | |
| 117 | setContents(Vertical { |
| 118 | Horizontal { |
| 119 | Button { "Force layout update" }.clicked(me::forceLayoutUpdate), |
| 120 | SpacerExpanding {}, |
| 121 | Label { "Use CTRL to hit test views" }, |
| 122 | }, |
| 123 | ASplitter::Horizontal() |
| 124 | .withItems({ |
| 125 | mViewHierarchyTree = _new<ATreeView>() with_style { MinSize { 300_dp }, Expanding {} }, |
| 126 | Centered { mViewPropertiesView = _new<ViewPropertiesView>(nullptr) }, |
| 127 | }) |
| 128 | .withExpanding(), |
| 129 | }); |
| 130 | |
| 131 | auto model = _new<ViewHierarchyTreeModel>(aui::ptr::fake(targetWindow)); |
| 132 | mViewHierarchyTree->setModel(model); |
| 133 | connect(mViewHierarchyTree->itemSelected, [this](const ATreeModelIndex& index) { |
| 134 | mViewPropertiesView->setTargetView(index.as<_<AView>>()); |
| 135 | }); |
| 136 | connect(mViewHierarchyTree->itemMouseHover, [this](const ATreeModelIndex& index) { |
| 137 | if (!AInput::isKeyDown(AInput::LCONTROL)) { |
| 138 | return; |
| 139 | } |
| 140 | mViewPropertiesView->setTargetView(index.as<_<AView>>()); |
| 141 | }); |
| 142 | connect(mouseLeave, [this] { |
| 143 | AUI_NULLSAFE(mTargetWindow->profiling())->highlightView = _weak<AView>(); |
| 144 | mTargetWindow->redraw(); |
| 145 | }); |
| 146 | connect(targetWindow->mouseMove, [this, targetWindow, model](glm::ivec2 position) { |
| 147 | if (!AInput::isKeyDown(AInput::LCONTROL)) { |
| 148 | return; |
| 149 | } |
| 150 | auto mouseOverView = targetWindow->getViewAtRecursive(position); |
| 151 | if (!mouseOverView) { |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | mViewPropertiesView->setTargetView(mouseOverView); |
| 156 | auto indexToSelect = model->find([&](const ATreeModelIndex& index) { |
| 157 | return index.as<_<AView>>() == mouseOverView; |
| 158 | }); |
| 159 | if (indexToSelect) { |
| 160 | mViewHierarchyTree->select(*indexToSelect); |
| 161 | } |
| 162 | }); |
| 163 | } |
| 164 | |
| 165 | void DevtoolsLayoutTab::forceLayoutUpdate() { mTargetWindow->forceUpdateLayoutRecursively(); } |
nothing calls this directly
no test coverage detected