PatchBay: complain when there are no MIDI devices

The empty window that would show when no MIDI devices are found would
confuse Haiku users. This was not a problem on the BeBox or older PCs
where a sound card with MPU401 port was standard, so there would always
be something to show.

Fixes #9977.
This commit is contained in:
Adrien Destugues
2014-11-06 16:22:09 +01:00
parent fbd8b14ae7
commit 5592b1d7e0
2 changed files with 30 additions and 4 deletions
+6 -1
View File
@@ -11,8 +11,13 @@ SimpleTest PatchBay
EndpointInfo.cpp EndpointInfo.cpp
MidiEventMeter.cpp MidiEventMeter.cpp
: :
midi midi2 be libicon.a [ TargetLibstdc++ ] midi midi2 be libicon.a localestub [ TargetLibstdc++ ]
: :
PatchBay.rdef PatchBay.rdef
; ;
DoCatalogs PatchBay :
x-vnd.Haiku.PatchBay
:
PatchView.cpp
;
+24 -3
View File
@@ -15,6 +15,7 @@
#include <Application.h> #include <Application.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Catalog.h>
#include <Debug.h> #include <Debug.h>
#include <IconUtils.h> #include <IconUtils.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
@@ -28,6 +29,9 @@
#include "UnknownDeviceIcons.h" #include "UnknownDeviceIcons.h"
#define B_TRANSLATION_CONTEXT "Patch Bay"
PatchView::PatchView(BRect rect) PatchView::PatchView(BRect rect)
: :
BView(rect, "PatchView", B_FOLLOW_ALL, B_WILL_DRAW), BView(rect, "PatchView", B_FOLLOW_ALL, B_WILL_DRAW),
@@ -149,14 +153,31 @@ PatchView::Draw(BRect /* updateRect */)
const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon; const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon;
DrawBitmapAsync(bitmap, RowIconFrameAt(index++).LeftTop()); DrawBitmapAsync(bitmap, RowIconFrameAt(index++).LeftTop());
} }
// draw consumer icons // draw consumer icons
index = 0; int32 index2 = 0;
for (list<EndpointInfo>::const_iterator i = fConsumers.begin(); for (list<EndpointInfo>::const_iterator i = fConsumers.begin();
i != fConsumers.end(); i++) { i != fConsumers.end(); i++) {
const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon; const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon;
DrawBitmapAsync(bitmap, ColumnIconFrameAt(index++).LeftTop()); DrawBitmapAsync(bitmap, ColumnIconFrameAt(index2++).LeftTop());
} }
if (index == 0 && index2 == 0) {
const char* message = B_TRANSLATE("No MIDI devices found!");
float width = StringWidth(message);
BRect rect = Bounds();
rect.top = rect.top + rect.bottom / 2;
rect.left = rect.left + rect.right / 2;
rect.left -= width / 2;
DrawString(message, rect.LeftTop());
// Since the message is centered, we need to redraw the whole view in
// this case.
SetFlags(Flags() | B_FULL_UPDATE_ON_RESIZE);
} else
SetFlags(Flags() & ~B_FULL_UPDATE_ON_RESIZE);
} }