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:
parent
fbd8b14ae7
commit
5592b1d7e0
@ -11,8 +11,13 @@ SimpleTest PatchBay
|
||||
EndpointInfo.cpp
|
||||
MidiEventMeter.cpp
|
||||
:
|
||||
midi midi2 be libicon.a [ TargetLibstdc++ ]
|
||||
midi midi2 be libicon.a localestub [ TargetLibstdc++ ]
|
||||
:
|
||||
PatchBay.rdef
|
||||
;
|
||||
|
||||
DoCatalogs PatchBay :
|
||||
x-vnd.Haiku.PatchBay
|
||||
:
|
||||
PatchView.cpp
|
||||
;
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <Application.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Catalog.h>
|
||||
#include <Debug.h>
|
||||
#include <IconUtils.h>
|
||||
#include <InterfaceDefs.h>
|
||||
@ -28,6 +29,9 @@
|
||||
#include "UnknownDeviceIcons.h"
|
||||
|
||||
|
||||
#define B_TRANSLATION_CONTEXT "Patch Bay"
|
||||
|
||||
|
||||
PatchView::PatchView(BRect rect)
|
||||
:
|
||||
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;
|
||||
DrawBitmapAsync(bitmap, RowIconFrameAt(index++).LeftTop());
|
||||
}
|
||||
|
||||
|
||||
// draw consumer icons
|
||||
index = 0;
|
||||
int32 index2 = 0;
|
||||
for (list<EndpointInfo>::const_iterator i = fConsumers.begin();
|
||||
i != fConsumers.end(); i++) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user