250{
252
253
254
256 const float dBRange =
settings.dBRange;
257
260 cache.GetDisplayBounds(
min, max);
261 const float lastdBRange = cache.GetLastDBRange();
262 if (dBRange != lastdBRange)
264
265 auto scaleType =
settings.scaleType;
266
268
269
272 cache.GetLastScaleType() != -1)
273 {
274
277 float sign = (
min >= 0 ? 1 : -1);
283 }
284 sign = (max >= 0 ? 1 : -1);
285
286 if (max != 0.) {
288 if (max < 0.0)
289 max = 0.0;
290 max *= sign;
291 }
292 cache.SetDisplayBounds(
min, max);
293 }
294
295 vruler->SetDbMirrorValue(0.0);
296 vruler->SetBounds(
297 rect.x, rect.y, rect.x + rect.width, rect.y + rect.height - 1);
298 vruler->SetOrientation(wxVERTICAL);
299 vruler->SetRange(max,
min);
302 vruler->SetLabelEdges(false);
303 vruler->SetUnits({});
305 }
306 else {
308 vruler->SetLabelEdges(true);
309 vruler->SetUnits(
XO(
"dB"));
312 std::vector<LinearDBValues>
values =
314 for (int ii = 0; ii < 3; ii++) {
318 for (
int i = 0; i <
size; i++) {
322
323 if (value == -dBRange)
325 else {
326 float sign = (value > -dBRange ? 1 : -1);
327 if (value < -dBRange)
328 value = -2 * dBRange - value;
330 }
331
332 wxString s = (value == -dBRange) ?
333 wxString(L"-\u221e") : wxString::FromDouble(value);
334
335
336
338
339 labs.push_back(lab);
340 }
341 if (ii == 0)
342 major = labs;
343 else if (ii == 1)
344 minor = labs;
345 else
346 minorMinor = labs;
347 }
349 }
350 }
351 else {
352 vruler->SetUnits(
XO(
"dB"));
353
355
357
358 cache.GetLastScaleType() != -1)
359 {
360
363 float sign = (
min >= 0 ? 1 : -1);
369 }
370 sign = (max >= 0 ? 1 : -1);
371
372 if (max != 0.) {
374 if (max < 0.0)
375 max = 0.0;
376 max *= sign;
377 }
378 cache.SetDisplayBounds(
min, max);
379 }
380 else if (dBRange != lastdBRange) {
382
383 float newMax = max;
384
385
386
387#ifdef ONLY_LABEL_POSITIVE
388 const float sign = (max >= 0 ? 1 : -1);
389 if (max != 0.) {
390
391
392#define ZOOMLIMIT 0.001f
393
395
397 extreme, (float(fabs(max)) * lastdBRange - lastdBRange));
398
399
400 newMax = sign * std::max(ZOOMLIMIT, (dBRange + dB) / dBRange);
401
402
404 min = std::max(-extreme, newMax *
min / max);
405 }
406#endif
407 cache.SetDisplayBounds(
min, newMax);
408 }
409
410
411
412
413
414#ifdef ONLY_LABEL_POSITIVE
415 if (max > 0) {
416#endif
417 int top = 0;
418 float topval = 0;
419 int bot = rect.height;
420 float botval = -dBRange;
421
422#ifdef ONLY_LABEL_POSITIVE
424 bot = top + (int)((max / (max -
min))*(bot - top));
426 }
427
428 if (max > 1) {
429 top += (int)((max - 1) / (max -
min) * (bot - top));
430 max = 1;
431 }
432
433 if (max < 1 && max > 0)
434 topval = -((1 - max) * dBRange);
435
437 botval = -((1 -
min) * dBRange);
438 }
439#else
440 topval = -((1 - max) * dBRange);
441 botval = -((1 -
min) * dBRange);
442 vruler->SetDbMirrorValue( dBRange );
443#endif
444 vruler->SetBounds(rect.x, rect.y + top, rect.x + rect.width, rect.y + bot - 1);
445 vruler->SetOrientation(wxVERTICAL);
446 vruler->SetRange(topval, botval);
447#ifdef ONLY_LABEL_POSITIVE
448 }
449 else
450 vruler->SetBounds(0.0, 0.0, 0.0, 0.0);
451#endif
453 vruler->SetLabelEdges(true);
455 }
457 vruler->GetMaxSize(&
size.first, &
size.second);
458}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
static ChannelView & Get(Channel &channel)
std::pair< int, int > vrulerSize
void SetData(RulerUpdater::Labels majorLabels, RulerUpdater::Labels minorLabels, RulerUpdater::Labels minorMinorLabels)
static const LinearUpdater & Instance()
std::vector< Label > Labels
AUDACITY_DLL_API Ruler & ScratchRuler()
An array of these created by the Updater is used to determine what and where text annotations to the ...
std::optional< TranslatableString > text