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

Method positionYChanged

src/frontend/dockwidgets/CartesianPlotLegendDock.cpp:380–411  ·  view source on GitHub ↗

! called when legend's current vertical position relative to its parent (top, center, bottom, custom) is changed. */

Source from the content-addressed store, hash-verified

378 called when legend's current vertical position relative to its parent (top, center, bottom, custom) is changed.
379*/
380void CartesianPlotLegendDock::positionYChanged(int index) {
381 CONDITIONAL_LOCK_RETURN;
382
383 CartesianPlotLegend::PositionWrapper position = m_legend->position();
384 auto oldVerticalPosition = position.verticalPosition;
385 position.verticalPosition = CartesianPlotLegend::VerticalPosition(index);
386 double y = 0.;
387 if (position.verticalPosition == WorksheetElement::VerticalPosition::Relative) {
388 switch (oldVerticalPosition) {
389 case WorksheetElement::VerticalPosition::Top:
390 case WorksheetElement::VerticalPosition::Relative:
391 break;
392 case WorksheetElement::VerticalPosition::Center:
393 y = 0.5;
394 break;
395 case WorksheetElement::VerticalPosition::Bottom:
396 y = 1.0;
397 }
398 ui.sbPositionY->setSuffix(QStringLiteral(" %"));
399 } else {
400 if (m_units == Units::Metric)
401 ui.sbPositionY->setSuffix(QStringLiteral(" cm"));
402 else
403 ui.sbPositionY->setSuffix(QStringLiteral(" in"));
404 }
405
406 position.point.setY(y);
407 ui.sbPositionY->setValue(std::round(100. * y));
408
409 for (auto* legend : m_legendList)
410 legend->setPosition(position);
411}
412
413void CartesianPlotLegendDock::customPositionXChanged(double value) {
414 CONDITIONAL_RETURN_NO_LOCK;

Callers

nothing calls this directly

Calls 6

VerticalPositionEnum · 0.85
positionMethod · 0.80
setSuffixMethod · 0.80
setYMethod · 0.80
setValueMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected