MCPcopy Create free account
hub / github.com/KDE/labplot / positionXChanged

Method positionXChanged

src/frontend/dockwidgets/CartesianPlotLegendDock.cpp:344–375  ·  view source on GitHub ↗

! called when legend's current horizontal position relative to its parent (left, center, right, relative) is changed. */

Source from the content-addressed store, hash-verified

342 called when legend's current horizontal position relative to its parent (left, center, right, relative) is changed.
343*/
344void CartesianPlotLegendDock::positionXChanged(int index) {
345 CONDITIONAL_LOCK_RETURN;
346
347 auto position = m_legend->position();
348 auto oldHorizontalPosition = position.horizontalPosition;
349 position.horizontalPosition = CartesianPlotLegend::HorizontalPosition(index);
350 double x = 0.;
351 if (position.horizontalPosition == WorksheetElement::HorizontalPosition::Relative) {
352 switch (oldHorizontalPosition) {
353 case WorksheetElement::HorizontalPosition::Left:
354 case WorksheetElement::HorizontalPosition::Relative:
355 break;
356 case WorksheetElement::HorizontalPosition::Center:
357 x = 0.5;
358 break;
359 case WorksheetElement::HorizontalPosition::Right:
360 x = 1.0;
361 }
362 ui.sbPositionX->setSuffix(QStringLiteral(" %"));
363 } else {
364 if (m_units == Units::Metric)
365 ui.sbPositionX->setSuffix(QStringLiteral(" cm"));
366 else
367 ui.sbPositionX->setSuffix(QStringLiteral(" in"));
368 }
369
370 position.point.setX(x);
371 ui.sbPositionX->setValue(std::round(100. * x));
372
373 for (auto* legend : m_legendList)
374 legend->setPosition(position);
375}
376
377/*!
378 called when legend's current vertical position relative to its parent (top, center, bottom, custom) is changed.

Callers

nothing calls this directly

Calls 6

HorizontalPositionEnum · 0.85
positionMethod · 0.80
setSuffixMethod · 0.80
setXMethod · 0.80
setValueMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected