! called when legend's current horizontal position relative to its parent (left, center, right, relative) is changed. */
| 342 | called when legend's current horizontal position relative to its parent (left, center, right, relative) is changed. |
| 343 | */ |
| 344 | void 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. |
nothing calls this directly
no test coverage detected