summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Kojevnikov <alexander@kojevnikov.com>2012-08-30 10:39:27 -0700
committerAlexander Kojevnikov <alexander@kojevnikov.com>2012-08-30 10:39:27 -0700
commit21d2d447c511c3f5dc8c295a50f2fc8b867a64be (patch)
tree1127bae7b69d68a8c48a197046121a0b9513dc1e /src
parentc64475f36e161b83d7545c491321b3a9a44382c3 (diff)
downloadspek-21d2d447c511c3f5dc8c295a50f2fc8b867a64be.zip
spek-21d2d447c511c3f5dc8c295a50f2fc8b867a64be.tar.gz
spek-21d2d447c511c3f5dc8c295a50f2fc8b867a64be.tar.bz2
Fix crash on OS X when the window is too small
Diffstat (limited to 'src')
-rw-r--r--src/spek-spectrogram.cc44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/spek-spectrogram.cc b/src/spek-spectrogram.cc
index 23614fc..c28809c 100644
--- a/src/spek-spectrogram.cc
+++ b/src/spek-spectrogram.cc
@@ -209,7 +209,7 @@ void SpekSpectrogram::render(wxDC& dc)
TPAD - 2 * GAP - normal_height - small_height
);
- if (this->image.GetHeight() > 1) {
+ if (this->image.GetWidth() > 1 && this->image.GetHeight() > 1) {
// Draw the spectrogram.
wxBitmap bmp(this->image.Scale(w - LPAD - RPAD, h - TPAD - BPAD));
dc.DrawBitmap(bmp, LPAD, TPAD);
@@ -274,28 +274,30 @@ void SpekSpectrogram::render(wxDC& dc)
dc.DrawRectangle(LPAD, TPAD, w - LPAD - RPAD, h - TPAD - BPAD);
// The palette.
- wxBitmap bmp(this->palette.Scale(RULER, h - TPAD - BPAD + 1));
- dc.DrawBitmap(bmp, w - RPAD + GAP, TPAD);
+ if (h - TPAD - BPAD > 0) {
+ wxBitmap bmp(this->palette.Scale(RULER, h - TPAD - BPAD + 1));
+ dc.DrawBitmap(bmp, w - RPAD + GAP, TPAD);
- // Prepare to draw the ruler.
- dc.SetFont(small_font);
+ // Prepare to draw the ruler.
+ dc.SetFont(small_font);
- // Spectral density.
- int density_factors[] = {1, 2, 5, 10, 20, 50, 0};
- SpekRuler density_ruler(
- w - RPAD + GAP + RULER,
- TPAD,
- SpekRuler::RIGHT,
- // TRANSLATORS: keep "-00" unchanged, it's used to calc the text width
- _("-00 dB"),
- density_factors,
- -THRESHOLD,
- 3.0,
- (h - TPAD - BPAD) / (double)THRESHOLD,
- h - TPAD - BPAD,
- density_formatter
- );
- density_ruler.draw(dc);
+ // Spectral density.
+ int density_factors[] = {1, 2, 5, 10, 20, 50, 0};
+ SpekRuler density_ruler(
+ w - RPAD + GAP + RULER,
+ TPAD,
+ SpekRuler::RIGHT,
+ // TRANSLATORS: keep "-00" unchanged, it's used to calc the text width
+ _("-00 dB"),
+ density_factors,
+ -THRESHOLD,
+ 3.0,
+ (h - TPAD - BPAD) / (double)THRESHOLD,
+ h - TPAD - BPAD,
+ density_formatter
+ );
+ density_ruler.draw(dc);
+ }
}
static void pipeline_cb(int sample, float *values, void *cb_data)