Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ include(DISSCOVersions.txt)

project(DISSCO VERSION ${DISSCO_VERSION})

include(CTest)

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
find_program(LLD_LINKER ld.lld)
if(LLD_LINKER)
Expand Down
11 changes: 11 additions & 0 deletions LASSIE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,15 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(LASSIE PRIVATE QT_NO_DEBUG_OUTPUT)
endif()

if(BUILD_TESTING)
target_compile_definitions(LASSIE PRIVATE DISSCO_ENABLE_UI_LAYOUT_TESTS)
add_test(NAME LASSIE.EnvelopeLegendLayout
COMMAND LASSIE
)
set_tests_properties(LASSIE.EnvelopeLegendLayout PROPERTIES
ENVIRONMENT "QT_QPA_PLATFORM=offscreen;DISSCO_TEST_ENVELOPE_LAYOUT=1"
TIMEOUT 10
)
endif()

message(STATUS "DONE!")
42 changes: 42 additions & 0 deletions LASSIE/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

#include <QApplication>
#include <QFile>
#ifdef DISSCO_ENABLE_UI_LAYOUT_TESTS
#include <QDebug>
#include <QLabel>
#include <QLayout>
#include "windows/EnvelopeLibraryWindow.hpp"
#endif
#include "widgets/TextOverflowDisplayPolicy.hpp"
#include "windows/MainWindow.hpp"

Expand All @@ -18,6 +24,42 @@ int main(int argc, char *argv[])

QApplication a(argc, argv);
TextOverflowDisplayPolicy textOverflowDisplayPolicy(a);

#ifdef DISSCO_ENABLE_UI_LAYOUT_TESTS
if (qEnvironmentVariableIsSet("DISSCO_TEST_ENVELOPE_LAYOUT")) {
EnvelopeLibraryWindow window;
window.ensurePolished();
window.show();
for (int i = 0; i < 3; ++i) {
window.centralWidget()->layout()->activate();
QApplication::processEvents();
}

QLabel* legend = window.findChild<QLabel*>("envelopeLegend");
if (!legend) {
qCritical() << "Envelope legend was not found";
return 1;
}

const QRect legendInCentral(
legend->mapTo(window.centralWidget(), QPoint()), legend->size());
const int requiredHeight = legend->heightForWidth(legend->width());
const bool fullyVisible =
window.centralWidget()->rect().contains(legendInCentral)
&& legend->visibleRegion().contains(legend->rect())
&& legend->height() >= requiredHeight;

if (!fullyVisible) {
qCritical() << "Envelope legend is clipped:"
<< "actual" << legend->size()
<< "required height" << requiredHeight
<< "visible region" << legend->visibleRegion();
}

return fullyVisible ? 0 : 1;
}
#endif

registerAllFunctions();
Inst *m = Inst::instance();
MainWindow *w = new MainWindow(m);
Expand Down
8 changes: 4 additions & 4 deletions LASSIE/src/windows/EnvelopeLibraryWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <QPushButton>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QSizePolicy>
#include <QDebug>

#include "../utilities.hpp"
Expand All @@ -31,7 +30,7 @@ EnvelopeLibraryWindow::EnvelopeLibraryWindow(QWidget* parent)
{
// Window setup
setWindowTitle("Envelope Library");
resize(600, 220); // Compact initial size
resize(600, 500);

// Central widget and layout
QWidget* central = new QWidget(this);
Expand Down Expand Up @@ -84,8 +83,9 @@ EnvelopeLibraryWindow::EnvelopeLibraryWindow(QWidget* parent)
xyWidget->setLayout(xyForm);
xyLegendLayout->addWidget(xyWidget, 0, Qt::AlignLeft);
QLabel* legend = new QLabel("Right click the graph to see available actions or click-and-drag a node to adjust the envelope.\nThick segment = Flexible; Thin segment = Fixed.\nBlue = Linear; Green = Spline; Red = Exponential (curved).\nYou can also type X and Y values directly to position nodes.", this);
legend->setObjectName("envelopeLegend");
legend->setWordWrap(true);
legend->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
// Keep QLabel's height-for-width policy so wrapped text gets enough room.
xyLegendLayout->addWidget(legend, 1);
layout->addLayout(xyLegendLayout);

Expand Down Expand Up @@ -356,4 +356,4 @@ void EnvelopeLibraryWindow::setEntries(const QString& x, const QString& y)
// Reconnect signals
connect(xEntry, &QLineEdit::textChanged, this, &EnvelopeLibraryWindow::valueEntriesChanged);
connect(yEntry, &QLineEdit::textChanged, this, &EnvelopeLibraryWindow::valueEntriesChanged);
}
}
Loading