From b0867c1602cf0a397d335f84e0ba23e88c6c0d73 Mon Sep 17 00:00:00 2001 From: TryTwo Date: Tue, 21 Nov 2023 18:29:07 -0700 Subject: [PATCH] CodeWidget: Layout tweak. Give left-side widgets more vertical space by moving the address bar out of the way. Align things better. --- Source/Core/DolphinQt/Debugger/CodeWidget.cpp | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp index af8315f179..eedf70a192 100644 --- a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp @@ -100,16 +100,22 @@ void CodeWidget::showEvent(QShowEvent* event) void CodeWidget::CreateWidgets() { - auto* layout = new QGridLayout; + auto* layout = new QHBoxLayout; layout->setContentsMargins(2, 2, 2, 2); layout->setSpacing(0); + auto* top_layout = new QHBoxLayout; m_search_address = new QLineEdit; - m_branch_watch = new QPushButton(tr("Branch Watch")); - m_code_view = new CodeViewWidget; - m_search_address->setPlaceholderText(tr("Search Address")); + m_branch_watch = new QPushButton(tr("Branch Watch")); + top_layout->addWidget(m_search_address); + top_layout->addWidget(m_branch_watch); + + auto* right_layout = new QVBoxLayout; + m_code_view = new CodeViewWidget; + right_layout->addLayout(top_layout); + right_layout->addWidget(m_code_view); m_box_splitter = new QSplitter(Qt::Vertical); m_box_splitter->setStyleSheet(BOX_SPLITTER_STYLESHEET); @@ -146,12 +152,23 @@ void CodeWidget::CreateWidgets() m_code_splitter = new QSplitter(Qt::Horizontal); - m_code_splitter->addWidget(m_box_splitter); - m_code_splitter->addWidget(m_code_view); + // right_layout is the searchbar area and the codeview. + QWidget* right_widget = new QWidget; + right_widget->setLayout(right_layout); - layout->addWidget(m_search_address, 0, 0); - layout->addWidget(m_branch_watch, 0, 2); - layout->addWidget(m_code_splitter, 1, 0, -1, -1); + m_code_splitter->addWidget(m_box_splitter); + m_code_splitter->addWidget(right_widget); + + layout->addWidget(m_code_splitter); + + // Corrects button height mis-aligning the layout. Note: Margin only populates values after this + // point. + const int height_fix = + m_branch_watch->sizeHint().height() - m_search_address->sizeHint().height(); + auto margins = right_layout->contentsMargins(); + margins.setTop(margins.top() - height_fix / 2); + right_layout->setContentsMargins(margins); + right_layout->setSpacing(right_layout->spacing() - height_fix / 2); QWidget* widget = new QWidget(this); widget->setLayout(layout);