Ticket #9604: 0001-PatchBay-revisions-for-Haiku.patch
File 0001-PatchBay-revisions-for-Haiku.patch, 103.0 KB (added by , 11 years ago) |
---|
-
src/apps/Jamfile
From 5c0dedeb457ca6925d84f4775de929f71a0c2ca8 Mon Sep 17 00:00:00 2001 From: Pete Goodeve <pete.goodeve@computer.org> Date: Tue, 2 Apr 2013 17:07:36 -0700 Subject: [PATCH] PatchBay revisions for Haiku --- src/apps/Jamfile | 1 + src/apps/patchbay/CountEventConsumer.h | 46 ++ src/apps/patchbay/EndpointInfo.cpp | 144 ++++++ src/apps/patchbay/EndpointInfo.h | 52 +++ src/apps/patchbay/Jamfile | 18 + src/apps/patchbay/MidiEventMeter.cpp | 144 ++++++ src/apps/patchbay/MidiEventMeter.h | 42 ++ src/apps/patchbay/PatchApp.cpp | 46 ++ src/apps/patchbay/PatchApp.h | 27 ++ src/apps/patchbay/PatchBay.rdef | 75 ++++ src/apps/patchbay/PatchRow.cpp | 226 ++++++++++ src/apps/patchbay/PatchRow.h | 50 +++ src/apps/patchbay/PatchView.cpp | 484 +++++++++++++++++++++ src/apps/patchbay/PatchView.h | 73 ++++ src/apps/patchbay/PatchWin.cpp | 36 ++ src/apps/patchbay/PatchWin.h | 30 ++ src/apps/patchbay/UnknownDeviceIcons.h | 105 +++++ src/tests/kits/midi/Jamfile | 2 +- src/tests/kits/midi/patchbay/CountEventConsumer.h | 30 -- src/tests/kits/midi/patchbay/EndpointInfo.cpp | 124 ------ src/tests/kits/midi/patchbay/EndpointInfo.h | 40 -- src/tests/kits/midi/patchbay/Jamfile | 17 - src/tests/kits/midi/patchbay/MidiEventMeter.cpp | 122 ------ src/tests/kits/midi/patchbay/MidiEventMeter.h | 36 -- src/tests/kits/midi/patchbay/PatchApp.cpp | 44 -- src/tests/kits/midi/patchbay/PatchApp.h | 26 -- src/tests/kits/midi/patchbay/PatchBay.rsrc | Bin 2861 -> 0 bytes src/tests/kits/midi/patchbay/PatchRow.cpp | 194 --------- src/tests/kits/midi/patchbay/PatchRow.h | 38 -- src/tests/kits/midi/patchbay/PatchView.cpp | 462 -------------------- src/tests/kits/midi/patchbay/PatchView.h | 75 ---- src/tests/kits/midi/patchbay/PatchWin.cpp | 26 -- src/tests/kits/midi/patchbay/PatchWin.h | 24 - src/tests/kits/midi/patchbay/TToolTip.cpp | 357 --------------- src/tests/kits/midi/patchbay/TToolTip.h | 86 ---- src/tests/kits/midi/patchbay/UnknownDeviceIcons.h | 106 ----- 36 files changed, 1600 insertions(+), 1808 deletions(-) create mode 100644 src/apps/patchbay/CountEventConsumer.h create mode 100644 src/apps/patchbay/EndpointInfo.cpp create mode 100644 src/apps/patchbay/EndpointInfo.h create mode 100644 src/apps/patchbay/Jamfile create mode 100644 src/apps/patchbay/MidiEventMeter.cpp create mode 100644 src/apps/patchbay/MidiEventMeter.h create mode 100644 src/apps/patchbay/PatchApp.cpp create mode 100644 src/apps/patchbay/PatchApp.h create mode 100644 src/apps/patchbay/PatchBay.rdef create mode 100644 src/apps/patchbay/PatchRow.cpp create mode 100644 src/apps/patchbay/PatchRow.h create mode 100644 src/apps/patchbay/PatchView.cpp create mode 100644 src/apps/patchbay/PatchView.h create mode 100644 src/apps/patchbay/PatchWin.cpp create mode 100644 src/apps/patchbay/PatchWin.h create mode 100644 src/apps/patchbay/UnknownDeviceIcons.h delete mode 100644 src/tests/kits/midi/patchbay/CountEventConsumer.h delete mode 100644 src/tests/kits/midi/patchbay/EndpointInfo.cpp delete mode 100644 src/tests/kits/midi/patchbay/EndpointInfo.h delete mode 100644 src/tests/kits/midi/patchbay/Jamfile delete mode 100644 src/tests/kits/midi/patchbay/MidiEventMeter.cpp delete mode 100644 src/tests/kits/midi/patchbay/MidiEventMeter.h delete mode 100644 src/tests/kits/midi/patchbay/PatchApp.cpp delete mode 100644 src/tests/kits/midi/patchbay/PatchApp.h delete mode 100644 src/tests/kits/midi/patchbay/PatchBay.rsrc delete mode 100644 src/tests/kits/midi/patchbay/PatchRow.cpp delete mode 100644 src/tests/kits/midi/patchbay/PatchRow.h delete mode 100644 src/tests/kits/midi/patchbay/PatchView.cpp delete mode 100644 src/tests/kits/midi/patchbay/PatchView.h delete mode 100644 src/tests/kits/midi/patchbay/PatchWin.cpp delete mode 100644 src/tests/kits/midi/patchbay/PatchWin.h delete mode 100644 src/tests/kits/midi/patchbay/TToolTip.cpp delete mode 100644 src/tests/kits/midi/patchbay/TToolTip.h delete mode 100644 src/tests/kits/midi/patchbay/UnknownDeviceIcons.h diff --git a/src/apps/Jamfile b/src/apps/Jamfile index 0f90365..6538a4f 100644
a b HaikuSubInclude overlayimage ; 41 41 HaikuSubInclude packageinstaller ; 42 42 HaikuSubInclude packagemanager ; 43 43 HaikuSubInclude pairs ; 44 HaikuSubInclude patchbay ; 44 45 HaikuSubInclude people ; 45 46 HaikuSubInclude poorman ; 46 47 HaikuSubInclude powerstatus ; -
new file src/apps/patchbay/CountEventConsumer.h
diff --git a/src/apps/patchbay/CountEventConsumer.h b/src/apps/patchbay/CountEventConsumer.h new file mode 100644 index 0000000..d6fe12f
- + 1 /* CountEventConsumer.h 2 * -------------------- 3 * A simple MIDI consumer that counts incoming MIDI events. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #ifndef _CountEventConsumer_h 15 #define _CountEventConsumer_h 16 17 #include <MidiConsumer.h> 18 #include <SupportDefs.h> 19 20 class CountEventConsumer : public BMidiLocalConsumer 21 { 22 public: 23 CountEventConsumer(const char* name) 24 : 25 BMidiLocalConsumer(name), 26 fEventCount(0) 27 {} 28 void Reset() 29 { 30 fEventCount = 0; 31 } 32 int32 CountEvents() 33 { 34 return fEventCount; 35 } 36 37 void Data(uchar*, size_t, bool, bigtime_t) 38 { 39 atomic_add(&fEventCount, 1); 40 } 41 42 private: 43 int32 fEventCount; 44 }; 45 46 #endif /* _CountEventConsumer_h */ -
new file src/apps/patchbay/EndpointInfo.cpp
diff --git a/src/apps/patchbay/EndpointInfo.cpp b/src/apps/patchbay/EndpointInfo.cpp new file mode 100644 index 0000000..4ee9911
- + 1 /* EndpointInfo.cpp 2 * ---------------- 3 * Implements the EndpointInfo object. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 #include "EndpointInfo.h" 14 15 #include <Bitmap.h> 16 #include <Debug.h> 17 #include <IconUtils.h> 18 #include <Message.h> 19 #include <MidiRoster.h> 20 #include <MidiEndpoint.h> 21 22 const char* LARGE_ICON_NAME = "be:large_icon"; 23 const char* MINI_ICON_NAME = "be:mini_icon"; 24 const char* VECTOR_ICON_NAME = "icon"; 25 const uint32 LARGE_ICON_TYPE = 'ICON'; 26 const uint32 MINI_ICON_TYPE = 'MICN'; 27 const uint32 VECTOR_ICON_TYPE = 'VICN'; 28 extern const uint8 LARGE_ICON_SIZE = 32; 29 extern const uint8 MINI_ICON_SIZE = 16; 30 extern const icon_size DISPLAY_ICON_SIZE = B_LARGE_ICON; 31 extern const color_space ICON_COLOR_SPACE = B_CMAP8; 32 33 static BBitmap* CreateIcon(const BMessage* msg, icon_size which); 34 35 36 EndpointInfo::EndpointInfo() 37 : 38 fId(-1), 39 fIcon(NULL) 40 {} 41 42 43 EndpointInfo::EndpointInfo(int32 id) 44 : 45 fId(id), 46 fIcon(NULL) 47 { 48 BMidiRoster* roster = BMidiRoster::MidiRoster(); 49 if (roster) { 50 BMidiEndpoint* endpoint = roster->FindEndpoint(id); 51 if (endpoint) { 52 printf("endpoint %ld = %p\n", id, endpoint); 53 BMessage msg; 54 if (endpoint->GetProperties(&msg) == B_OK) { 55 fIcon = CreateIcon(&msg, DISPLAY_ICON_SIZE); 56 } 57 endpoint->Release(); 58 } 59 } 60 } 61 62 63 EndpointInfo::EndpointInfo(const EndpointInfo& info) 64 : 65 fId(info.fId) 66 { 67 fIcon = (info.fIcon) ? new BBitmap(info.fIcon) : NULL; 68 } 69 70 71 EndpointInfo& 72 EndpointInfo::operator=(const EndpointInfo& info) 73 { 74 if (&info != this) { 75 fId = info.fId; 76 delete fIcon; 77 fIcon = (info.fIcon) ? new BBitmap(info.fIcon) : NULL; 78 } 79 return *this; 80 } 81 82 83 EndpointInfo::~EndpointInfo() 84 { 85 delete fIcon; 86 } 87 88 89 void 90 EndpointInfo::UpdateProperties(const BMessage* props) 91 { 92 delete fIcon; 93 fIcon = CreateIcon(props, DISPLAY_ICON_SIZE); 94 } 95 96 97 static BBitmap* 98 CreateIcon(const BMessage* msg, icon_size which) 99 { 100 101 const void* data; 102 ssize_t size; 103 BBitmap* bitmap = NULL; 104 105 // See if a Haiku Vector Icon available 106 if (msg->FindData(VECTOR_ICON_NAME, VECTOR_ICON_TYPE, &data, 107 &size) == B_OK) { 108 BRect r(0, 0, LARGE_ICON_SIZE - 1, LARGE_ICON_SIZE - 1); 109 bitmap = new BBitmap(r, B_RGBA32); 110 if (BIconUtils::GetVectorIcon((const uint8*)data, size, 111 bitmap) == B_OK) { 112 printf("Created vector icon bitmap\n"); 113 return bitmap; 114 } else 115 delete bitmap; 116 } 117 118 // If not, look for BeOS style icon 119 float bmapSize; 120 uint32 iconType; 121 const char* iconName; 122 123 if (which == B_LARGE_ICON) { 124 bmapSize = LARGE_ICON_SIZE - 1; 125 iconType = LARGE_ICON_TYPE; 126 iconName = LARGE_ICON_NAME; 127 } else if (which == B_MINI_ICON) { 128 bmapSize = MINI_ICON_SIZE - 1; 129 iconType = MINI_ICON_TYPE; 130 iconName = MINI_ICON_NAME; 131 } else { 132 return NULL; 133 } 134 135 if (msg->FindData(iconName, iconType, &data, &size) == B_OK) 136 { 137 ; 138 bitmap = new BBitmap(BRect(0, 0, bmapSize, bmapSize), 139 ICON_COLOR_SPACE); 140 ASSERT((bitmap->BitsLength() == size)); 141 memcpy(bitmap->Bits(), data, size); 142 } 143 return bitmap; 144 } -
new file src/apps/patchbay/EndpointInfo.h
diff --git a/src/apps/patchbay/EndpointInfo.h b/src/apps/patchbay/EndpointInfo.h new file mode 100644 index 0000000..92a65dc
- + 1 /* EndpointInfo.h 2 * -------------- 3 * A simple structure that describes a MIDI object. 4 * Currently, it only contains icon data associated with the object. 5 * 6 * Copyright 2013, Haiku, Inc. All rights reserved. 7 * Distributed under the terms of the MIT License. 8 * 9 * Revisions by Pete Goodeve 10 * 11 * Copyright 1999, Be Incorporated. All Rights Reserved. 12 * This file may be used under the terms of the Be Sample Code License. 13 */ 14 15 #ifndef _EndpointInfo_h 16 #define _EndpointInfo_h 17 18 #include <Mime.h> /* for icon_size */ 19 #include <GraphicsDefs.h> /* for color_space */ 20 21 class BMidiEndpoint; 22 23 extern const uint8 LARGE_ICON_SIZE; 24 extern const uint8 MINI_ICON_SIZE; 25 extern const icon_size DISPLAY_ICON_SIZE; 26 extern const color_space ICON_COLOR_SPACE; 27 28 class EndpointInfo 29 { 30 public: 31 EndpointInfo(); 32 EndpointInfo(int32 id); 33 EndpointInfo(const EndpointInfo& info); 34 EndpointInfo& operator=(const EndpointInfo& info); 35 ~EndpointInfo(); 36 37 int32 ID() const 38 { 39 return fId; 40 } 41 const BBitmap* Icon() const 42 { 43 return fIcon; 44 } 45 void UpdateProperties(const BMessage* props); 46 47 private: 48 int32 fId; 49 BBitmap* fIcon; 50 }; 51 52 #endif /* _EndpointInfo_h */ -
new file src/apps/patchbay/Jamfile
diff --git a/src/apps/patchbay/Jamfile b/src/apps/patchbay/Jamfile new file mode 100644 index 0000000..193ad85
- + 1 SubDir HAIKU_TOP src apps patchbay ; 2 3 SetSubDirSupportedPlatformsBeOSCompatible ; 4 5 SimpleTest PatchBay 6 : 7 PatchApp.cpp 8 PatchWin.cpp 9 PatchView.cpp 10 PatchRow.cpp 11 EndpointInfo.cpp 12 MidiEventMeter.cpp 13 : 14 midi midi2 be libicon.a $(TARGET_LIBSTDC++) 15 : 16 PatchBay.rdef 17 ; 18 -
new file src/apps/patchbay/MidiEventMeter.cpp
diff --git a/src/apps/patchbay/MidiEventMeter.cpp b/src/apps/patchbay/MidiEventMeter.cpp new file mode 100644 index 0000000..719cf61
- + 1 /* MidiEventMeter.cpp 2 * ------------------ 3 * Implements the MidiEventMeter class. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #include <stdio.h> 15 #include <MidiRoster.h> 16 #include <MidiProducer.h> 17 #include <MidiConsumer.h> 18 #include <View.h> 19 #include "CountEventConsumer.h" 20 #include "MidiEventMeter.h" 21 22 static const BRect METER_BOUNDS(0, 0, 7, 31); 23 24 // If we get this number of events per pulse or greater, we will 25 // max out the event meter. 26 // Value was determined empirically based on my banging on a MIDI 27 // keyboard controller with a pulse of 200ms. 28 static const int32 METER_SCALE = 10; 29 30 31 MidiEventMeter::MidiEventMeter(int32 producerID) 32 : 33 fCounter(NULL), 34 fMeterLevel(0) 35 { 36 BMidiRoster* roster = BMidiRoster::MidiRoster(); 37 if (roster) { 38 BMidiProducer* producer = roster->FindProducer(producerID); 39 if (producer) { 40 BString name; 41 name << producer->Name() << " Event Meter"; 42 fCounter = new CountEventConsumer(name.String()); 43 producer->Connect(fCounter); 44 producer->Release(); 45 } 46 } 47 } 48 49 50 MidiEventMeter::~MidiEventMeter() 51 { 52 if (fCounter) 53 fCounter->Release(); 54 } 55 56 57 void 58 MidiEventMeter::Pulse(BView* view) 59 { 60 int32 newLevel = fMeterLevel; 61 if (fCounter) { 62 newLevel = CalcMeterLevel(fCounter->CountEvents()); 63 fCounter->Reset(); 64 } 65 if (newLevel != fMeterLevel) { 66 fMeterLevel = newLevel; 67 view->Invalidate(BRect(METER_BOUNDS).InsetBySelf(1, 1)); 68 } 69 } 70 71 72 BRect 73 MidiEventMeter::Bounds() const 74 { 75 return METER_BOUNDS; 76 } 77 78 79 void 80 MidiEventMeter::Draw(BView* view) 81 { 82 const rgb_color METER_BLACK = { 0, 0, 0, 255 }; 83 const rgb_color METER_GREY = { 180, 180, 180, 255 }; 84 const rgb_color METER_GREEN = { 0, 255, 0, 255 }; 85 86 view->PushState(); 87 88 // draw the frame 89 BPoint lt = METER_BOUNDS.LeftTop(); 90 BPoint rb = METER_BOUNDS.RightBottom(); 91 view->BeginLineArray(4); 92 view->AddLine(BPoint(lt.x, lt.y), BPoint(rb.x - 1, lt.y), METER_BLACK); 93 view->AddLine(BPoint(rb.x, lt.y), BPoint(rb.x, rb.y - 1), METER_BLACK); 94 view->AddLine(BPoint(rb.x, rb.y), BPoint(lt.x + 1, rb.y), METER_BLACK); 95 view->AddLine(BPoint(lt.x, rb.y), BPoint(lt.x, lt.y + 1), METER_BLACK); 96 view->EndLineArray(); 97 98 // draw the cells 99 BRect cell = METER_BOUNDS; 100 cell.InsetBy(1, 1); 101 cell.bottom = cell.top + (cell.Height() + 1) / 5; 102 cell.bottom--; 103 104 const float kTintArray[] = 105 {B_DARKEN_4_TINT, 106 B_DARKEN_3_TINT, 107 B_DARKEN_2_TINT, 108 B_DARKEN_1_TINT, 109 B_NO_TINT}; 110 111 for (int32 i = 4; i >= 0; i--) 112 { 113 rgb_color color; 114 if (fMeterLevel > i) { 115 color = tint_color(METER_GREEN, kTintArray[i]); 116 } else { 117 color = METER_GREY; 118 } 119 view->SetHighColor(color); 120 view->FillRect(cell); 121 cell.OffsetBy(0, cell.Height() + 1); 122 } 123 124 view->PopState(); 125 } 126 127 128 int32 129 MidiEventMeter::CalcMeterLevel(int32 eventCount) const 130 { 131 // we use an approximately logarithmic scale for determing the actual 132 // drawn meter level, so that low-density event streams show up well. 133 if (eventCount == 0) 134 return 0; 135 else if (eventCount < (int32)(0.5 * METER_SCALE)) 136 return 1; 137 else if (eventCount < (int32)(0.75 * METER_SCALE)) 138 return 2; 139 else if (eventCount < (int32)(0.9 * METER_SCALE)) 140 return 3; 141 else if (eventCount < METER_SCALE) 142 return 4; 143 return 5; 144 } -
new file src/apps/patchbay/MidiEventMeter.h
diff --git a/src/apps/patchbay/MidiEventMeter.h b/src/apps/patchbay/MidiEventMeter.h new file mode 100644 index 0000000..5866e6e
- + 1 /* MidiEventMeter.h 2 * ---------------- 3 * A UI widget that measures the amount of MIDI data generated by a 4 * consumer. 5 * 6 * Copyright 2013, Haiku, Inc. All rights reserved. 7 * Distributed under the terms of the MIT License. 8 * 9 * Revisions by Pete Goodeve 10 * 11 * Copyright 1999, Be Incorporated. All Rights Reserved. 12 * This file may be used under the terms of the Be Sample Code License. 13 */ 14 15 #ifndef _MidiEventMeter_h 16 #define _MidiEventMeter_h 17 18 #include <Point.h> 19 #include <Rect.h> 20 21 class BMidiProducer; 22 class CountEventConsumer; 23 class BView; 24 25 class MidiEventMeter 26 { 27 public: 28 MidiEventMeter(int32 producerID); 29 ~MidiEventMeter(); 30 31 void Pulse(BView* view); 32 BRect Bounds() const; 33 void Draw(BView* view); 34 35 private: 36 int32 CalcMeterLevel(int32 eventCount) const; 37 38 CountEventConsumer* fCounter; 39 int32 fMeterLevel; 40 }; 41 42 #endif /* _MidiMeterWidget_h */ -
new file src/apps/patchbay/PatchApp.cpp
diff --git a/src/apps/patchbay/PatchApp.cpp b/src/apps/patchbay/PatchApp.cpp new file mode 100644 index 0000000..acf3512
- + 1 /* PatchApp.cpp 2 * ------------ 3 * Implements the PatchBay application class and main(). 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #include "PatchApp.h" 15 16 #include <Roster.h> 17 #include "PatchWin.h" 18 19 PatchApp::PatchApp() 20 : 21 BApplication("application/x-vnd.Haiku.PatchBay") 22 {} 23 24 25 void 26 PatchApp::ReadyToRun() 27 { 28 new PatchWin; 29 } 30 31 32 void 33 PatchApp::MessageReceived(BMessage* msg) 34 { 35 BApplication::MessageReceived(msg); 36 } 37 38 39 int 40 main(void) 41 { 42 PatchApp app; 43 app.Run(); 44 return 0; 45 } 46 -
new file src/apps/patchbay/PatchApp.h
diff --git a/src/apps/patchbay/PatchApp.h b/src/apps/patchbay/PatchApp.h new file mode 100644 index 0000000..e45f32a
- + 1 /* PatchApp.h 2 * ---------- 3 * The PatchBay application class. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #ifndef _PatchApp_h 15 #define _PatchApp_h 16 17 #include <Application.h> 18 19 class PatchApp : public BApplication 20 { 21 public: 22 PatchApp(); 23 void ReadyToRun(); 24 void MessageReceived(BMessage* msg); 25 }; 26 27 #endif /* _PatchApp_h */ -
new file src/apps/patchbay/PatchBay.rdef
diff --git a/src/apps/patchbay/PatchBay.rdef b/src/apps/patchbay/PatchBay.rdef new file mode 100644 index 0000000..47f170f
- + 1 2 resource app_signature "application/x-vnd.Haiku.PatchBay"; 3 4 resource app_name_catalog_entry "application/x-vnd.Haiku.PatchBay:System name:PatchBay"; 5 6 resource app_version { 7 major = 1, 8 middle = 0, 9 minor = 0, 10 11 variety = 2, 12 internal = 0, 13 14 short_info = "PatchBay", 15 16 long_info = "PatchBay MIDI Port interconnection ©2013 Haiku, Inc." 17 }; 18 19 resource app_flags B_SINGLE_LAUNCH; 20 21 22 resource vector_icon { 23 $"6E636966140401740500020006023C5783372F7CB8EFFB3E28D3482623479BB1" 24 $"00E1FCF3FF8DDAC0020006023B3049396B0ABA90833C646E4A101543299500E1" 25 $"FCF3FFB4EEDB02000603395E1E32DB49B6921A3D07D74A57904908D600646464" 26 $"0678948AFF78948A050102031604BEBE2BBEE9573EE957BEBE2B48B7784A2FD3" 27 $"0001C670D073FFFF020116033EB0000000000000003EB000470000486000BE4B" 28 $"0084FF32020316023C4E213D44DABD44DA3C4E214926894A428EA143FFFF0203" 29 $"1602BC6B27BD2F9C3D2F9CBC6B2748B0FD4A3D7CAB08FFFF0300FF0005010200" 30 $"1605BF2F31BF38ED3ED85CBECFC4499A0C4B50220001377000716D73FFFF0201" 31 $"16033EB0000000000000003EB000482000482000BE4B0084FF3202000604BE37" 32 $"C8B7C456379553BE1C1A4B24CF4C81BE0E0000008F040202FF685B5BFFFFFFFF" 33 $"02030603BCD4ABBC8A9D3DAD85BE0C574A5F474B05CB8A080808FFC9C4C4FFB2" 34 $"A7A702000603BA8802BC993B3DD226BBB8D249CA264BD1370008010100FFAA00" 35 $"FF08010102000603BA51E2B9CF15B97D653A20214B39494A12BA0008010100FF" 36 $"AA00FF08010102000603390B9BBB2FCAB9D8B1B7AD044A23004B7F9900080101" 37 $"00FFAA00FF08010102000603B847EDB76620BB18843C13D84A521C4A634F00F9" 38 $"EED70037290DFFF9EED7090A04455F4F5E5F4E4F460A04272B2750465E46350A" 39 $"044636465E564E562B0A04272B4636562B38230A06262B2650465F574E572B38" 40 $"2202043735BEB4BC7430322A3F2ABC962AC21D3551B8D3C56F3C54434743C54D" 41 $"433E020440304932BC50B89C303D30BB0830C2133F4FBC02C49C48524F444FC4" 42 $"DD4FBDD20A043A4A3A554459444D060AFEF107BF0048BF00C3A2BF00C3A2BF00" 43 $"C3A23DC4553DC3A23DC507BF00C507BF00C523BF00C4EB4FBF4DBF4DC507BF4D" 44 $"C50DBF4DC50140C45540C50740C3A2BF4DC39DBF4DC397BF4DC3A248290A0001" 45 $"002021210A0101041001178200040A020101000A030103000A040102000A0B01" 46 $"051001178400040A0F0105123FAFC50000000000003FB0194301D643017D0117" 47 $"8500040A0E0105123FA0000000000000003FA04841FFFB42FB8801178200040A" 48 $"0C0105023F77770000000000003F77774244444422220A130107123DB13B0000" 49 $"000000003E023E455D893B535E01178100040A100107023D60B1B053F32F5F01" 50 $"3E551D45E7E1C3AE060A11010830172101158000040A120108123F3E45BE5759" 51 $"3E57593F3E45C90928495A4C01158000040A110108123C90423FCA00BFCA003C" 52 $"90424AE74EC4752501158000040A120108123C7791BFCE173FCE173C7791C8BD" 53 $"2F4B800301158000040A110108123EE5493EC273BEC2733EE549490C6EC67EAD" 54 $"01158000040A0B000237D7012A6354AAA73E38221B486CD349FAFB0A0B010512" 55 $"BE04150000000000003FAF574BA0103ED0A801178400040A0F010512BDB74D00" 56 $"00000000003F65BC4B87D043790B01178500040A0E010512BDA7670000000000" 57 $"003F572A4B8FEF43738E01178200040A0C010502BD7E8C0000000000003F3190" 58 $"4B8DC94451320A13010712BBB8C50000000000003DB3794B69C93F94BC011781" 59 $"00040A10010702BB6797B02503AD65E43E26154B6112C2AFA90A11010812BE04" 60 $"150000000000003FAF574BE8A341400001158000040A12010812BD44E6BE2824" 61 $"BC5C223EFCE04C31F3492D3701158000040A11010812BA957F3F7D993DD1BE3C" 62 $"5C914A2972C3D30401158000040A12010812BA7C9BBF815DBDD5DD3C45D24C28" 63 $"614B44B201158000040A11010812BCEB333E8ACE3CC8163EAAE54ADB66C61F54" 64 $"01158000040A0B0002B5DED92A332D28ACAA37EE2F4B039E49C13E0A0B010512" 65 $"BFEE20BBF39CB90B913D07574B9193440B9D01178400040A0F010512BF9F4CBB" 66 $"A45AB8CEBC3CCAD74B5DB9443E3501178500040A0E010512BF8FCEBB94C6B8C2" 67 $"B23CBEDE4B5DA144656901178200040A0C010502BF67FABB6CBAB8A39F3C9FF6" 68 $"4B577B449B340A13010712BDA0BBB9A5CBB70EFB3B0ABC4B177B4292CB011781" 69 $"00040A10010702BD16C6BAF1F5B934283B45744B2953443BF50A11010812BFE3" 70 $"13BC4AC7B9885D3CFED34C04CD45CD7C01158000040A12010812BEE4A7BD9C97" 71 $"BEA2143A2C9E4C64D548B4E801158000040A11010812BD53E43C1A5C3F8A613D" 72 $"218E46D73DC69FE701158000040A12010812BB1D51BD8E67BFD570BA83684C38" 73 $"9B49FCC101158000040A11010812BF1E563742033E5CA93DBFED4A15DFC50930" 74 $"01158000040A0B0002B78654B54AE7B2B098350C6A4A20C547001D" 75 }; -
new file src/apps/patchbay/PatchRow.cpp
diff --git a/src/apps/patchbay/PatchRow.cpp b/src/apps/patchbay/PatchRow.cpp new file mode 100644 index 0000000..6dfe353
- + 1 /* PatchRow.cpp 2 * ------------ 3 * 4 * Copyright 2013, Haiku, Inc. All rights reserved. 5 * Distributed under the terms of the MIT License. 6 * 7 * Revisions by Pete Goodeve 8 * 9 * Copyright 1999, Be Incorporated. All Rights Reserved. 10 * This file may be used under the terms of the Be Sample Code License. 11 */ 12 13 #include "PatchRow.h" 14 15 #include <stdio.h> 16 #include <CheckBox.h> 17 #include <Debug.h> 18 #include <MidiRoster.h> 19 #include <MidiConsumer.h> 20 #include <MidiProducer.h> 21 #include <Window.h> 22 #include "MidiEventMeter.h" 23 24 extern const float ROW_LEFT = 50.0f; 25 extern const float ROW_TOP = 50.0f; 26 extern const float ROW_HEIGHT = 40.0f; 27 extern const float COLUMN_WIDTH = 40.0f; 28 extern const float METER_PADDING = 15.0f; 29 extern const uint32 MSG_CONNECT_REQUEST = 'mCRQ'; 30 31 static const BPoint kBoxOffset(8, 7); 32 33 // PatchCheckBox is the check box that describes a connection 34 // between a producer and a consumer. 35 class PatchCheckBox : public BCheckBox 36 { 37 public: 38 PatchCheckBox(BRect r, int32 producerID, int32 consumerID) 39 : 40 BCheckBox(r, "", "", new BMessage(MSG_CONNECT_REQUEST)), 41 fProducerID(producerID), 42 fConsumerID(consumerID) 43 {} 44 45 int32 ProducerID() const 46 { 47 return fProducerID; 48 } 49 int32 ConsumerID() const 50 { 51 return fConsumerID; 52 } 53 54 void DoConnect(); 55 56 private: 57 int32 fProducerID; 58 int32 fConsumerID; 59 }; 60 61 62 PatchRow::PatchRow(int32 producerID) 63 : 64 BView(BRect(0, 0, 0, 0), "PatchRow", B_FOLLOW_NONE, 65 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED), 66 fProducerID(producerID), 67 fEventMeter(NULL) 68 { 69 fEventMeter = new MidiEventMeter(fProducerID); 70 } 71 72 73 PatchRow::~PatchRow() 74 { 75 delete fEventMeter; 76 } 77 78 79 int32 80 PatchRow::ID() const 81 { 82 return fProducerID; 83 } 84 85 86 void 87 PatchRow::Pulse() 88 { 89 if (fEventMeter) 90 fEventMeter->Pulse(this); 91 } 92 93 94 void 95 PatchRow::Draw(BRect) 96 { 97 if (fEventMeter) 98 fEventMeter->Draw(this); 99 } 100 101 102 void 103 PatchRow::AddColumn(int32 consumerID) 104 { 105 BRect rect; 106 int32 numColumns = CountChildren(); 107 rect.left = numColumns * COLUMN_WIDTH + METER_PADDING + kBoxOffset.x; 108 rect.top = kBoxOffset.y; 109 rect.right = rect.left + 20; 110 rect.bottom = rect.top + 20; 111 112 PatchCheckBox* box = new PatchCheckBox(rect, fProducerID, consumerID); 113 AddChild(box); 114 box->SetTarget(this); 115 } 116 117 118 void 119 PatchRow::RemoveColumn(int32 consumerID) 120 { 121 int32 numChildren = CountChildren(); 122 for (int32 i = 0; i < numChildren; i++) { 123 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i)); 124 if (box && box->ConsumerID() == consumerID) { 125 RemoveChild(box); 126 delete box; 127 while (i < numChildren) { 128 box = dynamic_cast<PatchCheckBox*>(ChildAt(i++)); 129 if (box) 130 box->MoveBy(-COLUMN_WIDTH, 0); 131 } 132 break; 133 } 134 } 135 } 136 137 138 void 139 PatchRow::Connect(int32 consumerID) 140 { 141 int32 numChildren = CountChildren(); 142 for (int32 i = 0; i < numChildren; i++) { 143 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i)); 144 if (box && box->ConsumerID() == consumerID) 145 box->SetValue(1); 146 } 147 } 148 149 150 void 151 PatchRow::Disconnect(int32 consumerID) 152 { 153 int32 numChildren = CountChildren(); 154 for (int32 i = 0; i < numChildren; i++) { 155 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i)); 156 if (box && box->ConsumerID() == consumerID) 157 box->SetValue(0); 158 } 159 } 160 161 162 void 163 PatchRow::AttachedToWindow() 164 { 165 Window()->SetPulseRate(200000); 166 SetViewColor(Parent()->ViewColor()); 167 int32 numChildren = CountChildren(); 168 for (int32 i = 0; i < numChildren; i++) { 169 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i)); 170 if (box) 171 box->SetTarget(this); 172 } 173 } 174 175 176 void 177 PatchRow::MessageReceived(BMessage* msg) 178 { 179 switch (msg->what) { 180 case MSG_CONNECT_REQUEST: 181 { 182 BControl* ctrl; 183 if (msg->FindPointer("source", (void**) &ctrl) == B_OK) { 184 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ctrl); 185 if (box) 186 box->DoConnect(); 187 } 188 } 189 break; 190 default: 191 BView::MessageReceived(msg); 192 break; 193 } 194 } 195 196 197 void 198 PatchCheckBox::DoConnect() 199 { 200 int32 value = Value(); 201 int32 inverseValue = (value + 1) % 2; 202 203 BMidiRoster* roster = BMidiRoster::MidiRoster(); 204 if (roster == NULL) { 205 SetValue(inverseValue); 206 return; 207 } 208 209 BMidiProducer* producer = roster->FindProducer(fProducerID); 210 BMidiConsumer* consumer = roster->FindConsumer(fConsumerID); 211 if (producer && consumer) { 212 status_t err; 213 if (value) 214 err = producer->Connect(consumer); 215 else 216 err = producer->Disconnect(consumer); 217 218 if (err != B_OK) { 219 SetValue(inverseValue); 220 } 221 } else 222 SetValue(inverseValue); 223 224 if (producer) producer->Release(); 225 if (consumer) consumer->Release(); 226 } -
new file src/apps/patchbay/PatchRow.h
diff --git a/src/apps/patchbay/PatchRow.h b/src/apps/patchbay/PatchRow.h new file mode 100644 index 0000000..21977b6
- + 1 /* PatchRow.h 2 * ---------- 3 * 4 * Copyright 2013, Haiku, Inc. All rights reserved. 5 * Distributed under the terms of the MIT License. 6 * 7 * Revisions by Pete Goodeve 8 * 9 * Copyright 1999, Be Incorporated. All Rights Reserved. 10 * This file may be used under the terms of the Be Sample Code License. 11 */ 12 13 #ifndef _PatchRow_h 14 #define _PatchRow_h 15 16 #include <View.h> 17 18 extern const float ROW_LEFT; 19 extern const float ROW_TOP; 20 extern const float ROW_HEIGHT; 21 extern const float COLUMN_WIDTH; 22 extern const float METER_PADDING; 23 extern const uint32 MSG_CONNECT_REQUEST; 24 25 class MidiEventMeter; 26 27 class PatchRow : public BView 28 { 29 public: 30 PatchRow(int32 producerID); 31 ~PatchRow(); 32 33 int32 ID() const; 34 35 void AttachedToWindow(); 36 void MessageReceived(BMessage* msg); 37 void Pulse(); 38 void Draw(BRect updateRect); 39 40 void AddColumn(int32 consumerID); 41 void RemoveColumn(int32 consumerID); 42 void Connect(int32 consumerID); 43 void Disconnect(int32 consumerID); 44 45 private: 46 int32 fProducerID; 47 MidiEventMeter* fEventMeter; 48 }; 49 50 #endif /* _PatchRow_h */ -
new file src/apps/patchbay/PatchView.cpp
diff --git a/src/apps/patchbay/PatchView.cpp b/src/apps/patchbay/PatchView.cpp new file mode 100644 index 0000000..dc0054e
- + 1 /* PatchView.cpp 2 * ------------- 3 * Implements the main PatchBay view class. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #include "PatchView.h" 15 16 #include <Application.h> 17 #include <Bitmap.h> 18 #include <Debug.h> 19 #include <IconUtils.h> 20 #include <InterfaceDefs.h> 21 #include <Message.h> 22 #include <Messenger.h> 23 #include <MidiRoster.h> 24 #include <Window.h> 25 #include "EndpointInfo.h" 26 #include "PatchRow.h" 27 #include "UnknownDeviceIcons.h" 28 29 30 PatchView::PatchView(BRect rect) 31 : 32 BView(rect, "PatchView", B_FOLLOW_ALL, B_WILL_DRAW), 33 fUnknownDeviceIcon(NULL) 34 { 35 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 36 37 BRect iconRect(0, 0, LARGE_ICON_SIZE - 1, LARGE_ICON_SIZE - 1); 38 fUnknownDeviceIcon = new BBitmap(iconRect, B_RGBA32); 39 if (BIconUtils::GetVectorIcon( 40 UnknownDevice::kVectorIcon, 41 sizeof(UnknownDevice::kVectorIcon), 42 fUnknownDeviceIcon) == B_OK) 43 return; 44 delete fUnknownDeviceIcon; 45 } 46 47 48 PatchView::~PatchView() 49 { 50 delete fUnknownDeviceIcon; 51 } 52 53 54 void 55 PatchView::AttachedToWindow() 56 { 57 BMidiRoster* roster = BMidiRoster::MidiRoster(); 58 if (roster == NULL) { 59 PRINT(("Couldn't get MIDI roster\n")); 60 be_app->PostMessage(B_QUIT_REQUESTED); 61 return; 62 } 63 64 BMessenger msgr(this); 65 roster->StartWatching(&msgr); 66 } 67 68 69 void 70 PatchView::MessageReceived(BMessage* msg) 71 { 72 switch (msg->what) { 73 case B_MIDI_EVENT: 74 HandleMidiEvent(msg); 75 break; 76 default: 77 BView::MessageReceived(msg); 78 break; 79 } 80 } 81 82 83 bool 84 PatchView::GetToolTipAt(BPoint point, BToolTip** tip) 85 { 86 bool found = false; 87 int32 index = 0; 88 endpoint_itor begin, end; 89 int32 size = fConsumers.size(); 90 for (int32 i = 0; !found && i < size; i++) { 91 BRect r = ColumnIconFrameAt(i); 92 if (r.Contains(point)) { 93 begin = fConsumers.begin(); 94 end = fConsumers.end(); 95 found = true; 96 index = i; 97 } 98 } 99 size = fProducers.size(); 100 for (int32 i = 0; !found && i < size; i++) { 101 BRect r = RowIconFrameAt(i); 102 if (r.Contains(point)) { 103 begin = fProducers.begin(); 104 end = fProducers.end(); 105 found = true; 106 index = i; 107 } 108 } 109 110 if (!found) 111 return false; 112 113 endpoint_itor itor; 114 for (itor = begin; itor != end; itor++, index--) 115 if (index <= 0) break; 116 117 if (itor == end) 118 return false; 119 120 BMidiRoster* roster = BMidiRoster::MidiRoster(); 121 if (roster == NULL) 122 return false; 123 BMidiEndpoint* obj = roster->FindEndpoint(itor->ID()); 124 if (obj == NULL) 125 return false; 126 127 BString str; 128 str << "<" << obj->ID() << ">: " << obj->Name(); 129 obj->Release(); 130 131 SetToolTip(str.String()); 132 133 *tip = ToolTip(); 134 135 return true; 136 } 137 138 139 void 140 PatchView::Draw(BRect /* updateRect */) 141 { 142 // draw producer icons 143 SetDrawingMode(B_OP_OVER); 144 int32 index = 0; 145 for (list<EndpointInfo>::const_iterator i = fProducers.begin(); 146 i != fProducers.end(); i++) { 147 const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon; 148 DrawBitmapAsync(bitmap, RowIconFrameAt(index++).LeftTop()); 149 } 150 151 // draw consumer icons 152 index = 0; 153 for (list<EndpointInfo>::const_iterator i = fConsumers.begin(); 154 i != fConsumers.end(); i++) { 155 const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon; 156 DrawBitmapAsync(bitmap, ColumnIconFrameAt(index++).LeftTop()); 157 } 158 } 159 160 161 BRect 162 PatchView::ColumnIconFrameAt(int32 index) const 163 { 164 BRect rect; 165 rect.left = ROW_LEFT + METER_PADDING + index * COLUMN_WIDTH; 166 rect.top = 10; 167 rect.right = rect.left + 31; 168 rect.bottom = rect.top + 31; 169 return rect; 170 } 171 172 173 BRect 174 PatchView::RowIconFrameAt(int32 index) const 175 { 176 BRect rect; 177 rect.left = 10; 178 rect.top = ROW_TOP + index * ROW_HEIGHT; 179 rect.right = rect.left + 31; 180 rect.bottom = rect.top + 31; 181 return rect; 182 } 183 184 185 void 186 PatchView::HandleMidiEvent(BMessage* msg) 187 { 188 SET_DEBUG_ENABLED(true); 189 190 int32 op; 191 if (msg->FindInt32("be:op", &op) != B_OK) { 192 PRINT(("PatchView::HandleMidiEvent: \"op\" field not found\n")); 193 return; 194 } 195 196 switch (op) { 197 case B_MIDI_REGISTERED: 198 { 199 int32 id; 200 if (msg->FindInt32("be:id", &id) != B_OK) { 201 PRINT(("PatchView::HandleMidiEvent: \"be:id\"" 202 " field not found in B_MIDI_REGISTERED event\n")); 203 break; 204 } 205 206 const char* type; 207 if (msg->FindString("be:type", &type) != B_OK) { 208 PRINT(("PatchView::HandleMidiEvent: \"be:type\"" 209 " field not found in B_MIDI_REGISTERED event\n")); 210 break; 211 } 212 213 PRINT(("MIDI Roster Event B_MIDI_REGISTERED: id=%ld, type=%s\n", 214 id, type)); 215 if (strcmp(type, "producer") == 0) 216 AddProducer(id); 217 else if (strcmp(type, "consumer") == 0) 218 AddConsumer(id); 219 } 220 break; 221 case B_MIDI_UNREGISTERED: 222 { 223 int32 id; 224 if (msg->FindInt32("be:id", &id) != B_OK) { 225 PRINT(("PatchView::HandleMidiEvent: \"be:id\"" 226 " field not found in B_MIDI_UNREGISTERED\n")); 227 break; 228 } 229 230 const char* type; 231 if (msg->FindString("be:type", &type) != B_OK) { 232 PRINT(("PatchView::HandleMidiEvent: \"be:type\"" 233 " field not found in B_MIDI_UNREGISTERED\n")); 234 break; 235 } 236 237 PRINT(("MIDI Roster Event B_MIDI_UNREGISTERED: id=%ld, type=%s\n", 238 id, type)); 239 if (strcmp(type, "producer") == 0) 240 RemoveProducer(id); 241 else if (strcmp(type, "consumer") == 0) 242 RemoveConsumer(id); 243 } 244 break; 245 case B_MIDI_CHANGED_PROPERTIES: 246 { 247 int32 id; 248 if (msg->FindInt32("be:id", &id) != B_OK) { 249 PRINT(("PatchView::HandleMidiEvent: \"be:id\"" 250 " field not found in B_MIDI_CHANGED_PROPERTIES\n")); 251 break; 252 } 253 254 const char* type; 255 if (msg->FindString("be:type", &type) != B_OK) { 256 PRINT(("PatchView::HandleMidiEvent: \"be:type\"" 257 " field not found in B_MIDI_CHANGED_PROPERTIES\n")); 258 break; 259 } 260 261 BMessage props; 262 if (msg->FindMessage("be:properties", &props) != B_OK) { 263 PRINT(("PatchView::HandleMidiEvent: \"be:properties\"" 264 " field not found in B_MIDI_CHANGED_PROPERTIES\n")); 265 break; 266 } 267 268 PRINT(("MIDI Roster Event B_MIDI_CHANGED_PROPERTIES: id=%ld, type=%s\n", 269 id, type)); 270 if (strcmp(type, "producer") == 0) 271 UpdateProducerProps(id, &props); 272 else if (strcmp(type, "consumer") == 0) 273 UpdateConsumerProps(id, &props); 274 275 } 276 break; 277 case B_MIDI_CHANGED_NAME: 278 case B_MIDI_CHANGED_LATENCY: 279 // we don't care about these 280 break; 281 case B_MIDI_CONNECTED: 282 { 283 int32 prod; 284 if (msg->FindInt32("be:producer", &prod) != B_OK) { 285 PRINT(("PatchView::HandleMidiEvent: \"be:producer\"" 286 " field not found in B_MIDI_CONNECTED\n")); 287 break; 288 } 289 290 int32 cons; 291 if (msg->FindInt32("be:consumer", &cons) != B_OK) { 292 PRINT(("PatchView::HandleMidiEvent: \"be:consumer\"" 293 " field not found in B_MIDI_CONNECTED\n")); 294 break; 295 } 296 PRINT(("MIDI Roster Event B_MIDI_CONNECTED: producer=%ld, consumer=%ld\n", 297 prod, cons)); 298 Connect(prod, cons); 299 } 300 break; 301 case B_MIDI_DISCONNECTED: 302 { 303 int32 prod; 304 if (msg->FindInt32("be:producer", &prod) != B_OK) { 305 PRINT(("PatchView::HandleMidiEvent: \"be:producer\"" 306 " field not found in B_MIDI_DISCONNECTED\n")); 307 break; 308 } 309 310 int32 cons; 311 if (msg->FindInt32("be:consumer", &cons) != B_OK) { 312 PRINT(("PatchView::HandleMidiEvent: \"be:consumer\"" 313 " field not found in B_MIDI_DISCONNECTED\n")); 314 break; 315 } 316 PRINT(("MIDI Roster Event B_MIDI_DISCONNECTED: producer=%ld, consumer=%ld\n", 317 prod, cons)); 318 Disconnect(prod, cons); 319 } 320 break; 321 default: 322 PRINT(("PatchView::HandleMidiEvent: unknown opcode %ld\n", op)); 323 break; 324 } 325 } 326 327 328 void 329 PatchView::AddProducer(int32 id) 330 { 331 EndpointInfo info(id); 332 fProducers.push_back(info); 333 334 Window()->BeginViewTransaction(); 335 PatchRow* row = new PatchRow(id); 336 fPatchRows.push_back(row); 337 BPoint p1 = CalcRowOrigin(fPatchRows.size() - 1); 338 BPoint p2 = CalcRowSize(); 339 row->MoveTo(p1); 340 row->ResizeTo(p2.x, p2.y); 341 for (list<EndpointInfo>::const_iterator i = fConsumers.begin(); 342 i != fConsumers.end(); i++) 343 row->AddColumn(i->ID()); 344 AddChild(row); 345 Invalidate(); 346 Window()->EndViewTransaction(); 347 } 348 349 350 void 351 PatchView::AddConsumer(int32 id) 352 { 353 EndpointInfo info(id); 354 fConsumers.push_back(info); 355 356 Window()->BeginViewTransaction(); 357 BPoint newSize = CalcRowSize(); 358 for (row_itor i = fPatchRows.begin(); i != fPatchRows.end(); i++) { 359 (*i)->AddColumn(id); 360 (*i)->ResizeTo(newSize.x, newSize.y - 1); 361 } 362 Invalidate(); 363 Window()->EndViewTransaction(); 364 } 365 366 367 void 368 PatchView::RemoveProducer(int32 id) 369 { 370 for (endpoint_itor i = fProducers.begin(); i != fProducers.end(); i++) { 371 if (i->ID() == id) { 372 fProducers.erase(i); 373 break; 374 } 375 } 376 377 Window()->BeginViewTransaction(); 378 for (row_itor i = fPatchRows.begin(); i != fPatchRows.end(); i++) { 379 if ((*i)->ID() == id) { 380 PatchRow* row = *i; 381 i = fPatchRows.erase(i); 382 RemoveChild(row); 383 delete row; 384 float moveBy = -1 * CalcRowSize().y; 385 while (i != fPatchRows.end()) { 386 (*i++)->MoveBy(0, moveBy); 387 } 388 break; 389 } 390 } 391 Invalidate(); 392 Window()->EndViewTransaction(); 393 } 394 395 396 void 397 PatchView::RemoveConsumer(int32 id) 398 { 399 Window()->BeginViewTransaction(); 400 for (endpoint_itor i = fConsumers.begin(); i != fConsumers.end(); i++) { 401 if (i->ID() == id) { 402 fConsumers.erase(i); 403 break; 404 } 405 } 406 407 BPoint newSize = CalcRowSize(); 408 for (row_itor i = fPatchRows.begin(); i != fPatchRows.end(); i++) { 409 (*i)->RemoveColumn(id); 410 (*i)->ResizeTo(newSize.x, newSize.y - 1); 411 } 412 Invalidate(); 413 Window()->EndViewTransaction(); 414 } 415 416 417 void 418 PatchView::UpdateProducerProps(int32 id, const BMessage* props) 419 { 420 for (endpoint_itor i = fProducers.begin(); i != fProducers.end(); i++) { 421 if (i->ID() == id) { 422 i->UpdateProperties(props); 423 Invalidate(); 424 break; 425 } 426 } 427 } 428 429 430 void 431 PatchView::UpdateConsumerProps(int32 id, const BMessage* props) 432 { 433 for (endpoint_itor i = fConsumers.begin(); i != fConsumers.end(); i++) { 434 if (i->ID() == id) { 435 i->UpdateProperties(props); 436 Invalidate(); 437 break; 438 } 439 } 440 } 441 442 443 void 444 PatchView::Connect(int32 prod, int32 cons) 445 { 446 for (row_itor i = fPatchRows.begin(); i != fPatchRows.end(); i++) { 447 if ((*i)->ID() == prod) { 448 (*i)->Connect(cons); 449 break; 450 } 451 } 452 } 453 454 455 void 456 PatchView::Disconnect(int32 prod, int32 cons) 457 { 458 for (row_itor i = fPatchRows.begin(); i != fPatchRows.end(); i++) { 459 if ((*i)->ID() == prod) { 460 (*i)->Disconnect(cons); 461 break; 462 } 463 } 464 } 465 466 467 BPoint 468 PatchView::CalcRowOrigin(int32 rowIndex) const 469 { 470 BPoint point; 471 point.x = ROW_LEFT; 472 point.y = ROW_TOP + rowIndex * ROW_HEIGHT; 473 return point; 474 } 475 476 477 BPoint 478 PatchView::CalcRowSize() const 479 { 480 BPoint point; 481 point.x = METER_PADDING + fConsumers.size()*COLUMN_WIDTH; 482 point.y = ROW_HEIGHT - 1; 483 return point; 484 } -
new file src/apps/patchbay/PatchView.h
diff --git a/src/apps/patchbay/PatchView.h b/src/apps/patchbay/PatchView.h new file mode 100644 index 0000000..3298c5b
- + 1 /* PatchView.h 2 * ----------- 3 * The main PatchBay view contains a row of icons along the top and 4 * left sides representing available consumers and producers, and 5 * a set of PatchRows which build the matrix of connections. 6 * 7 * Copyright 2013, Haiku, Inc. All rights reserved. 8 * Distributed under the terms of the MIT License. 9 * 10 * Revisions by Pete Goodeve 11 * 12 * Copyright 1999, Be Incorporated. All Rights Reserved. 13 * This file may be used under the terms of the Be Sample Code License. 14 */ 15 16 #ifndef _PatchView_h 17 #define _PatchView_h 18 19 #include <Rect.h> 20 #include <View.h> 21 #include <list> 22 #include "EndpointInfo.h" 23 24 class PatchRow; 25 class BBitmap; 26 27 using namespace std; 28 29 class PatchView : public BView 30 { 31 public: 32 PatchView(BRect r); 33 ~PatchView(); 34 35 void AttachedToWindow(); 36 void MessageReceived(BMessage* msg); 37 void Draw(BRect updateRect); 38 39 private: 40 typedef enum { 41 TRACK_COLUMN, 42 TRACK_ROW 43 } track_type; 44 45 BRect ColumnIconFrameAt(int32 index) const; 46 BRect RowIconFrameAt(int32 index) const; 47 virtual bool GetToolTipAt(BPoint point, BToolTip** tip); 48 49 void AddProducer(int32 id); 50 void AddConsumer(int32 id); 51 void RemoveProducer(int32 id); 52 void RemoveConsumer(int32 id); 53 void UpdateProducerProps(int32 id, const BMessage* props); 54 void UpdateConsumerProps(int32 id, const BMessage* props); 55 void Connect(int32 prod, int32 cons); 56 void Disconnect(int32 prod, int32 cons); 57 58 void HandleMidiEvent(BMessage* msg); 59 60 BPoint CalcRowOrigin(int32 rowIndex) const; 61 BPoint CalcRowSize() const; 62 63 typedef list<EndpointInfo>::iterator endpoint_itor; 64 typedef list<EndpointInfo>::const_iterator const_endpoint_itor; 65 typedef list<PatchRow*>::iterator row_itor; 66 67 list<EndpointInfo> fProducers; 68 list<EndpointInfo> fConsumers; 69 list<PatchRow*> fPatchRows; 70 BBitmap* fUnknownDeviceIcon; 71 }; 72 73 #endif /* _PatchView_h */ -
new file src/apps/patchbay/PatchWin.cpp
diff --git a/src/apps/patchbay/PatchWin.cpp b/src/apps/patchbay/PatchWin.cpp new file mode 100644 index 0000000..8c45054
- + 1 /* PatchWin.cpp 2 * ------------ 3 * Implements the main PatchBay window class. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #include "PatchWin.h" 15 16 #include <Application.h> 17 #include "PatchView.h" 18 19 20 PatchWin::PatchWin() 21 : 22 BWindow(BRect(50, 50, 450, 450), "Patch Bay", B_TITLED_WINDOW, 0) 23 { 24 BRect r = Bounds(); 25 fPatchView = new PatchView(r); 26 AddChild(fPatchView); 27 Show(); 28 } 29 30 31 bool 32 PatchWin::QuitRequested() 33 { 34 be_app->PostMessage(B_QUIT_REQUESTED); 35 return true; 36 } -
new file src/apps/patchbay/PatchWin.h
diff --git a/src/apps/patchbay/PatchWin.h b/src/apps/patchbay/PatchWin.h new file mode 100644 index 0000000..c5659ea
- + 1 /* PatchWin.h 2 * ---------- 3 * The main PatchBay window class. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #ifndef _PatchWin_h 15 #define _PatchWin_h 16 17 #include <Window.h> 18 19 class PatchView; 20 21 class PatchWin : public BWindow 22 { 23 public: 24 PatchWin(); 25 bool QuitRequested(); 26 private: 27 PatchView* fPatchView; 28 }; 29 30 #endif /* _PatchWin_h */ -
new file src/apps/patchbay/UnknownDeviceIcons.h
diff --git a/src/apps/patchbay/UnknownDeviceIcons.h b/src/apps/patchbay/UnknownDeviceIcons.h new file mode 100644 index 0000000..365d607
- + 1 /* UnknownDeviceIcons.h 2 * -------------------- 3 * The icons to be used in case a device doesn't supply its icons. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 14 #ifndef _UnknownDeviceIcons_h 15 #define _UnknownDeviceIcons_h 16 17 namespace UnknownDevice { 18 19 // For Haiku we only need the Vector Icon 20 const unsigned char kVectorIcon[] = { 21 0x6e, 0x63, 0x69, 0x66, 0x0c, 0x05, 0x01, 0x02, 0x00, 0x16, 0x05, 0xbf, 22 0x2f, 0x31, 0xbf, 0x38, 0xed, 0x3e, 0xd8, 0x5c, 0xbe, 0xcf, 0xc4, 0x49, 23 0x9a, 0x0c, 0x4b, 0x50, 0x22, 0x00, 0x01, 0x37, 0x70, 0x00, 0x71, 0x6d, 24 0x73, 0xff, 0xff, 0x02, 0x01, 0x16, 0x03, 0x3e, 0xb0, 0x00, 0x00, 0x00, 25 0x00, 0x00, 0x00, 0x00, 0x3e, 0xb0, 0x00, 0x48, 0x20, 0x00, 0x48, 0x20, 26 0x00, 0xbe, 0x4b, 0x00, 0x84, 0xff, 0x32, 0x02, 0x00, 0x06, 0x04, 0xbe, 27 0x37, 0xc8, 0xb7, 0xc4, 0x56, 0x37, 0x95, 0x53, 0xbe, 0x1c, 0x1a, 0x4b, 28 0x24, 0xcf, 0x4c, 0x81, 0xbe, 0x0e, 0x00, 0x00, 0x00, 0x8f, 0x04, 0x02, 29 0x02, 0xff, 0x68, 0x5b, 0x5b, 0xff, 0xff, 0xff, 0xff, 0x02, 0x03, 0x06, 30 0x03, 0xbc, 0xd4, 0xab, 0xbc, 0x8a, 0x9d, 0x3d, 0xad, 0x85, 0xbe, 0x0c, 31 0x57, 0x4a, 0x5f, 0x47, 0x4b, 0x05, 0xcb, 0x8a, 0x08, 0x08, 0x08, 0xff, 32 0xc9, 0xc4, 0xc4, 0xff, 0xb2, 0xa7, 0xa7, 0x02, 0x00, 0x06, 0x03, 0xba, 33 0x88, 0x02, 0xbc, 0x99, 0x3b, 0x3d, 0xd2, 0x26, 0xbb, 0xb8, 0xd2, 0x49, 34 0xca, 0x26, 0x4b, 0xd1, 0x37, 0x00, 0x08, 0x01, 0x01, 0x00, 0xff, 0xaa, 35 0x00, 0xff, 0x08, 0x01, 0x01, 0x02, 0x00, 0x06, 0x03, 0xba, 0x51, 0xe2, 36 0xb9, 0xcf, 0x15, 0xb9, 0x7d, 0x65, 0x3a, 0x20, 0x21, 0x4b, 0x39, 0x49, 37 0x4a, 0x12, 0xba, 0x00, 0x08, 0x01, 0x01, 0x00, 0xff, 0xaa, 0x00, 0xff, 38 0x08, 0x01, 0x01, 0x02, 0x00, 0x06, 0x03, 0x39, 0x0b, 0x9b, 0xbb, 0x2f, 39 0xca, 0xb9, 0xd8, 0xb1, 0xb7, 0xad, 0x04, 0x4a, 0x23, 0x00, 0x4b, 0x7f, 40 0x99, 0x00, 0x08, 0x01, 0x01, 0x00, 0xff, 0xaa, 0x00, 0xff, 0x08, 0x01, 41 0x01, 0x02, 0x00, 0x06, 0x03, 0x36, 0xa6, 0x66, 0x35, 0xf2, 0xe6, 0xbb, 42 0x18, 0x84, 0x3c, 0x13, 0xd8, 0x4a, 0x92, 0x1c, 0x4a, 0xb3, 0x4f, 0x00, 43 0xf9, 0xee, 0xd7, 0x00, 0x37, 0x29, 0x0d, 0xff, 0xf9, 0xee, 0xd7, 0x05, 44 0x00, 0x02, 0x00, 0x06, 0x03, 0x3a, 0x89, 0x7d, 0xbc, 0xf6, 0x83, 0x3d, 45 0x95, 0x65, 0x3b, 0x11, 0x89, 0xc0, 0xa4, 0x24, 0x4a, 0xaf, 0xae, 0x00, 46 0xff, 0xb1, 0x1b, 0x69, 0xf6, 0xff, 0x1a, 0xff, 0xff, 0xf9, 0xc7, 0x02, 47 0x00, 0x06, 0x03, 0xbc, 0xe8, 0xf1, 0x3d, 0xc1, 0x1a, 0xbf, 0x29, 0x59, 48 0xbe, 0x73, 0x51, 0x4b, 0x4e, 0xe9, 0x4b, 0x19, 0x62, 0x00, 0xe3, 0xf0, 49 0xeb, 0x81, 0x00, 0xff, 0xaa, 0xff, 0x00, 0x00, 0x00, 0x06, 0x02, 0x04, 50 0x40, 0x22, 0xc6, 0x59, 0x22, 0xb9, 0x26, 0x22, 0x22, 0x40, 0x22, 0xb9, 51 0x26, 0x22, 0xc6, 0x59, 0x40, 0x5e, 0xb9, 0x26, 0x5e, 0xc6, 0x59, 0x5e, 52 0x5e, 0x40, 0x5e, 0xc6, 0x59, 0x5e, 0xb9, 0x26, 0x0a, 0x04, 0x3a, 0x4e, 53 0x3a, 0x5a, 0x46, 0x5a, 0x46, 0x4e, 0x06, 0x0a, 0xfe, 0xf1, 0x07, 0xbf, 54 0x73, 0x48, 0xbf, 0x73, 0xc4, 0x6e, 0xbf, 0x73, 0xc4, 0x6e, 0xbf, 0x73, 55 0xc4, 0x6e, 0x3d, 0xc5, 0xed, 0x3d, 0xc4, 0x6e, 0x3d, 0xc7, 0x6b, 0xbf, 56 0x73, 0xc7, 0x6b, 0xbf, 0x73, 0xc7, 0xa6, 0xbf, 0x73, 0xc7, 0x30, 0x57, 57 0xc0, 0x0c, 0xc0, 0x0c, 0xc7, 0x6b, 0xc0, 0x0c, 0xc7, 0x77, 0xc0, 0x0c, 58 0xc7, 0x5f, 0x43, 0xc5, 0xed, 0x43, 0xc7, 0x6b, 0x43, 0xc4, 0x6e, 0xc0, 59 0x0c, 0xc4, 0x62, 0xc0, 0x0c, 0xc4, 0x57, 0xc0, 0x0c, 0xc4, 0x6e, 0x48, 60 0x06, 0x10, 0xff, 0xaf, 0xfb, 0xef, 0x29, 0x43, 0xb5, 0x83, 0xc1, 0xeb, 61 0xb7, 0x6e, 0xc0, 0x2d, 0x2e, 0x41, 0x2c, 0x41, 0x33, 0x41, 0x38, 0x44, 62 0xbb, 0x8b, 0xc0, 0x53, 0x3a, 0x46, 0x38, 0x4e, 0x3a, 0x4a, 0xbc, 0x0e, 63 0xc6, 0x56, 0x31, 0x52, 0x32, 0x51, 0x30, 0x53, 0x2f, 0x53, 0x2e, 0x55, 64 0xb9, 0x27, 0xc6, 0xf6, 0x2e, 0x58, 0x2c, 0x57, 0x2c, 0x53, 0x2b, 0x56, 65 0x2d, 0x50, 0x2f, 0x50, 0x35, 0x4b, 0xbb, 0x02, 0xc4, 0xd8, 0x37, 0x47, 66 0x32, 0x45, 0x34, 0x46, 0xb9, 0xa6, 0xc1, 0x7b, 0xb7, 0xbf, 0xc1, 0xb1, 67 0xb8, 0x82, 0xc1, 0x3e, 0x2a, 0x46, 0x29, 0x47, 0xb6, 0xdc, 0xc2, 0x1f, 68 0x28, 0xc3, 0x21, 0x28, 0x4c, 0x26, 0x47, 0x25, 0x49, 0xb6, 0x59, 0xc0, 69 0x9e, 0x02, 0x04, 0xb8, 0x61, 0x5a, 0xb8, 0xed, 0x5a, 0xb7, 0xd4, 0x5a, 70 0x2b, 0xcb, 0x1b, 0x2b, 0xca, 0x8e, 0x2b, 0xcb, 0xa7, 0xb8, 0x61, 0x5f, 71 0xb7, 0xd4, 0x5f, 0xb8, 0xed, 0x5f, 0x30, 0xcb, 0x1b, 0x30, 0xcb, 0xa7, 72 0x30, 0xca, 0x8e, 0x02, 0x04, 0x30, 0x3c, 0xbc, 0x74, 0x3c, 0xb6, 0x4b, 73 0x3c, 0x22, 0x4e, 0x22, 0x41, 0x22, 0x5c, 0x30, 0x60, 0xb6, 0x4b, 0x60, 74 0xbc, 0x74, 0x60, 0x3e, 0x4e, 0x3e, 0x5a, 0x3e, 0x41, 0x0f, 0x0a, 0x00, 75 0x01, 0x00, 0x10, 0x01, 0x17, 0x84, 0x00, 0x04, 0x0a, 0x04, 0x01, 0x00, 76 0x12, 0x3f, 0xaf, 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xb0, 77 0x19, 0x43, 0x01, 0xd6, 0x43, 0x01, 0x7d, 0x01, 0x17, 0x85, 0x00, 0x04, 78 0x0a, 0x03, 0x01, 0x00, 0x12, 0x3f, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 79 0x00, 0x00, 0x3f, 0xa0, 0x48, 0x41, 0xff, 0xfb, 0x42, 0xfb, 0x88, 0x01, 80 0x17, 0x82, 0x00, 0x04, 0x0a, 0x01, 0x01, 0x00, 0x02, 0x3f, 0x77, 0x77, 81 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x77, 0x77, 0x44, 0x22, 0x22, 82 0x44, 0x22, 0x22, 0x0a, 0x08, 0x01, 0x01, 0x12, 0x3f, 0x62, 0x76, 0x00, 83 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x62, 0x76, 0x44, 0x76, 0x27, 0xca, 84 0x10, 0x00, 0x01, 0x17, 0x81, 0x00, 0x04, 0x0a, 0x05, 0x01, 0x01, 0x02, 85 0x3f, 0x56, 0x9f, 0xb1, 0x54, 0xf4, 0x31, 0x54, 0xf4, 0x3f, 0x56, 0x9f, 86 0x44, 0x7a, 0x31, 0xca, 0x03, 0x0c, 0x0a, 0x06, 0x01, 0x02, 0x30, 0x20, 87 0x22, 0x01, 0x15, 0x80, 0x00, 0x04, 0x0a, 0x07, 0x01, 0x02, 0x12, 0x3f, 88 0x3e, 0x45, 0xbe, 0x57, 0x59, 0x3e, 0x57, 0x59, 0x3f, 0x3e, 0x45, 0xc6, 89 0xd2, 0x50, 0x49, 0x3a, 0x4c, 0x01, 0x15, 0x80, 0x00, 0x04, 0x0a, 0x06, 90 0x01, 0x02, 0x12, 0x3e, 0xe5, 0x49, 0x3e, 0xc2, 0x73, 0xbe, 0xc2, 0x73, 91 0x3e, 0xe5, 0x49, 0x49, 0xcc, 0x6e, 0xc6, 0xfe, 0xad, 0x01, 0x15, 0x80, 92 0x00, 0x04, 0x0a, 0x06, 0x01, 0x02, 0x12, 0x3c, 0x90, 0x42, 0x3f, 0xca, 93 0x00, 0xbf, 0xca, 0x00, 0x3c, 0x90, 0x42, 0x4b, 0x27, 0x4e, 0xc6, 0x7a, 94 0x92, 0x01, 0x15, 0x80, 0x00, 0x04, 0x0a, 0x07, 0x01, 0x02, 0x12, 0x3c, 95 0x77, 0x91, 0xbf, 0xce, 0x17, 0x3f, 0xce, 0x17, 0x3c, 0x77, 0x91, 0xc4, 96 0xf4, 0xbd, 0x4b, 0x40, 0x03, 0x01, 0x15, 0x80, 0x00, 0x04, 0x0a, 0x0b, 97 0x01, 0x05, 0x20, 0x30, 0x0d, 0x0a, 0x09, 0x02, 0x04, 0x03, 0x38, 0x30, 98 0x0d, 0x15, 0xff, 0x01, 0x17, 0x83, 0x00, 0x04, 0x0a, 0x09, 0x02, 0x03, 99 0x04, 0x38, 0x30, 0x0d, 0x00, 0x15, 0x01, 0x17, 0x86, 0x00, 0x04, 0x0a, 100 0x0a, 0x02, 0x04, 0x03, 0x20, 0x30, 0x0d 101 }; 102 103 } 104 105 #endif /* _UnknownDeviceIcons_h */ -
src/tests/kits/midi/Jamfile
diff --git a/src/tests/kits/midi/Jamfile b/src/tests/kits/midi/Jamfile index 485c5c8..88d119c 100644
a b SubDir HAIKU_TOP src tests kits midi ; 5 5 #SubInclude HAIKU_TOP src tests kits midi midi_player ; 6 6 #SubInclude HAIKU_TOP src tests kits midi midi_player_replacement ; 7 7 #SubInclude HAIKU_TOP src tests kits midi synth_file_reader ; 8 SubInclude HAIKU_TOP src tests kits midi patchbay ;8 #SubInclude HAIKU_TOP src tests kits midi patchbay ; 9 9 -
deleted file src/tests/kits/midi/patchbay/CountEventConsumer.h
diff --git a/src/tests/kits/midi/patchbay/CountEventConsumer.h b/src/tests/kits/midi/patchbay/CountEventConsumer.h deleted file mode 100644 index 553c1e0..0000000
+ - 1 // CountEventConsumer.h2 // --------------------3 // A simple MIDI consumer that counts incoming MIDI events.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #ifndef _CountEventConsumer_h9 #define _CountEventConsumer_h10 11 #include <MidiConsumer.h>12 #include <SupportDefs.h>13 14 class CountEventConsumer : public BMidiLocalConsumer15 {16 public:17 CountEventConsumer(const char* name)18 : BMidiLocalConsumer(name), m_eventCount(0)19 {}20 void Reset() { m_eventCount = 0; }21 int32 CountEvents() { return m_eventCount; }22 23 void Data(uchar*, size_t, bool, bigtime_t)24 { atomic_add(&m_eventCount, 1); }25 26 private:27 int32 m_eventCount;28 };29 30 #endif /* _CountEventConsumer_h */ -
deleted file src/tests/kits/midi/patchbay/EndpointInfo.cpp
diff --git a/src/tests/kits/midi/patchbay/EndpointInfo.cpp b/src/tests/kits/midi/patchbay/EndpointInfo.cpp deleted file mode 100644 index a4caf5a..0000000
+ - 1 // EndpointInfo.cpp2 // ----------------3 // Implements the EndpointInfo object.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #include "EndpointInfo.h"9 10 #include <Bitmap.h>11 #include <Debug.h>12 #include <IconUtils.h>13 #include <Message.h>14 #include <MidiRoster.h>15 #include <MidiEndpoint.h>16 17 const char* LARGE_ICON_NAME = "be:large_icon";18 const char* MINI_ICON_NAME = "be:mini_icon";19 const char* VECTOR_ICON_NAME = "icon";20 const uint32 LARGE_ICON_TYPE = 'ICON';21 const uint32 MINI_ICON_TYPE = 'MICN';22 const uint32 VECTOR_ICON_TYPE = 'VICN';23 extern const uint8 LARGE_ICON_SIZE = 32;24 extern const uint8 MINI_ICON_SIZE = 16;25 extern const icon_size DISPLAY_ICON_SIZE = B_LARGE_ICON;26 extern const color_space ICON_COLOR_SPACE = B_CMAP8;27 28 static BBitmap* CreateIcon(const BMessage* msg, icon_size which);29 30 EndpointInfo::EndpointInfo()31 : m_id(-1), m_icon(NULL)32 {}33 34 EndpointInfo::EndpointInfo(int32 id)35 : m_id(id), m_icon(NULL)36 {37 BMidiRoster* roster = BMidiRoster::MidiRoster();38 if (roster) {39 BMidiEndpoint* endpoint = roster->FindEndpoint(id);40 if (endpoint) {41 printf("endpoint %ld = %p\n", id, endpoint);42 BMessage msg;43 if (endpoint->GetProperties(&msg) == B_OK) {44 m_icon = CreateIcon(&msg, DISPLAY_ICON_SIZE);45 }46 endpoint->Release();47 }48 }49 }50 51 EndpointInfo::EndpointInfo(const EndpointInfo& info)52 : m_id(info.m_id)53 {54 m_icon = (info.m_icon) ? new BBitmap(info.m_icon) : NULL;55 }56 57 EndpointInfo& EndpointInfo::operator=(const EndpointInfo& info)58 {59 if (&info != this) {60 m_id = info.m_id;61 delete m_icon;62 m_icon = (info.m_icon) ? new BBitmap(info.m_icon) : NULL;63 }64 return *this;65 }66 67 EndpointInfo::~EndpointInfo()68 {69 delete m_icon;70 }71 72 void EndpointInfo::UpdateProperties(const BMessage* props)73 {74 delete m_icon;75 m_icon = CreateIcon(props, DISPLAY_ICON_SIZE);76 }77 78 static BBitmap* CreateIcon(const BMessage* msg, icon_size which)79 {80 float iconSize;81 uint32 iconType;82 const char* iconName;83 84 if (which == B_LARGE_ICON) {85 iconSize = LARGE_ICON_SIZE;86 iconType = LARGE_ICON_TYPE;87 iconName = LARGE_ICON_NAME;88 } else if (which == B_MINI_ICON) {89 iconSize = MINI_ICON_SIZE;90 iconType = MINI_ICON_TYPE;91 iconName = MINI_ICON_NAME;92 } else {93 return NULL;94 }95 96 const void* data;97 ssize_t size;98 BBitmap* bitmap = NULL;99 100 #ifdef __HAIKU__101 iconSize = LARGE_ICON_SIZE;102 103 if (msg->FindData(VECTOR_ICON_NAME, VECTOR_ICON_TYPE, &data,104 &size) == B_OK) {105 BRect r(0, 0, iconSize-1, iconSize-1);106 bitmap = new BBitmap(r, B_RGBA32);107 if (BIconUtils::GetVectorIcon((const uint8*)data, size,108 bitmap) == B_OK) {109 printf("Created vector icon bitmap\n");110 return bitmap;111 } else112 delete bitmap;113 }114 #endif115 116 if (msg->FindData(iconName, iconType, &data, &size) == B_OK)117 {118 BRect r(0, 0, iconSize-1, iconSize-1);119 bitmap = new BBitmap(r, ICON_COLOR_SPACE);120 ASSERT((bitmap->BitsLength() == size));121 memcpy(bitmap->Bits(), data, size);122 }123 return bitmap;124 } -
deleted file src/tests/kits/midi/patchbay/EndpointInfo.h
diff --git a/src/tests/kits/midi/patchbay/EndpointInfo.h b/src/tests/kits/midi/patchbay/EndpointInfo.h deleted file mode 100644 index b75c9a8..0000000
+ - 1 // EndpointInfo.h2 // --------------3 // A simple structure that describes a MIDI object.4 // Currently, it only contains icon data associated with the object.5 //6 // Copyright 1999, Be Incorporated. All Rights Reserved.7 // This file may be used under the terms of the Be Sample Code License.8 9 #ifndef _EndpointInfo_h10 #define _EndpointInfo_h11 12 #include <Mime.h> /* for icon_size */13 #include <GraphicsDefs.h> /* for color_space */14 15 class BMidiEndpoint;16 17 extern const uint8 LARGE_ICON_SIZE;18 extern const uint8 MINI_ICON_SIZE;19 extern const icon_size DISPLAY_ICON_SIZE;20 extern const color_space ICON_COLOR_SPACE;21 22 class EndpointInfo23 {24 public:25 EndpointInfo();26 EndpointInfo(int32 id);27 EndpointInfo(const EndpointInfo& info);28 EndpointInfo& operator=(const EndpointInfo& info);29 ~EndpointInfo();30 31 int32 ID() const { return m_id; }32 const BBitmap* Icon() const { return m_icon; }33 void UpdateProperties(const BMessage* props);34 35 private:36 int32 m_id;37 BBitmap* m_icon;38 };39 40 #endif /* _EndpointInfo_h */ -
deleted file src/tests/kits/midi/patchbay/Jamfile
diff --git a/src/tests/kits/midi/patchbay/Jamfile b/src/tests/kits/midi/patchbay/Jamfile deleted file mode 100644 index 7cea736..0000000
+ - 1 SubDir HAIKU_TOP src tests kits midi patchbay ;2 3 SetSubDirSupportedPlatformsBeOSCompatible ;4 5 SimpleTest PatchBay6 :7 PatchApp.cpp8 PatchWin.cpp9 PatchView.cpp10 PatchRow.cpp11 EndpointInfo.cpp12 MidiEventMeter.cpp13 TToolTip.cpp14 :15 midi midi2 be libicon.a $(TARGET_LIBSTDC++)16 ;17 -
deleted file src/tests/kits/midi/patchbay/MidiEventMeter.cpp
diff --git a/src/tests/kits/midi/patchbay/MidiEventMeter.cpp b/src/tests/kits/midi/patchbay/MidiEventMeter.cpp deleted file mode 100644 index f625be0..0000000
+ - 1 // MidiEventMeter.cpp2 // ------------------3 // Implements the MidiEventMeter class.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #include <stdio.h>9 #include <MidiRoster.h>10 #include <MidiProducer.h>11 #include <MidiConsumer.h>12 #include <View.h>13 #include "CountEventConsumer.h"14 #include "MidiEventMeter.h"15 16 static const BRect METER_BOUNDS(0,0,7,31);17 18 // If we get this number of events per pulse or greater, we will19 // max out the event meter.20 // Value was determined empirically based on my banging on a MIDI21 // keyboard controller with a pulse of 200ms.22 static const int32 METER_SCALE = 10;23 24 MidiEventMeter::MidiEventMeter(int32 producerID)25 : m_counter(NULL), m_meterLevel(0)26 {27 BMidiRoster* roster = BMidiRoster::MidiRoster();28 if (roster) {29 BMidiProducer* producer = roster->FindProducer(producerID);30 if (producer) {31 BString name;32 name << producer->Name() << " Event Meter";33 m_counter = new CountEventConsumer(name.String());34 producer->Connect(m_counter);35 producer->Release();36 }37 }38 }39 40 MidiEventMeter::~MidiEventMeter()41 {42 if (m_counter) m_counter->Release();43 }44 45 void MidiEventMeter::Pulse(BView* view)46 {47 int32 newLevel = m_meterLevel;48 if (m_counter) {49 newLevel = CalcMeterLevel(m_counter->CountEvents());50 m_counter->Reset();51 }52 if (newLevel != m_meterLevel) {53 m_meterLevel = newLevel;54 view->Invalidate(BRect(METER_BOUNDS).InsetBySelf(1,1));55 }56 }57 58 BRect MidiEventMeter::Bounds() const59 {60 return METER_BOUNDS;61 }62 63 void MidiEventMeter::Draw(BView* view)64 {65 const rgb_color METER_BLACK = { 0, 0, 0, 255 };66 const rgb_color METER_GREY = { 180, 180, 180, 255 };67 const rgb_color METER_GREEN = { 0, 255, 0, 255 };68 69 view->PushState();70 71 // draw the frame72 BPoint lt = METER_BOUNDS.LeftTop();73 BPoint rb = METER_BOUNDS.RightBottom();74 view->BeginLineArray(4);75 view->AddLine(BPoint(lt.x, lt.y), BPoint(rb.x - 1, lt.y), METER_BLACK);76 view->AddLine(BPoint(rb.x, lt.y), BPoint(rb.x, rb.y - 1), METER_BLACK);77 view->AddLine(BPoint(rb.x, rb.y), BPoint(lt.x + 1, rb.y), METER_BLACK);78 view->AddLine(BPoint(lt.x, rb.y), BPoint(lt.x, lt.y + 1), METER_BLACK);79 view->EndLineArray();80 81 // draw the cells82 BRect cell = METER_BOUNDS;83 cell.InsetBy(1,1);84 cell.bottom = cell.top + (cell.Height() + 1) / 5;85 cell.bottom--;86 87 const float kTintArray[] = { B_DARKEN_4_TINT, B_DARKEN_3_TINT, B_DARKEN_2_TINT, B_DARKEN_1_TINT, B_NO_TINT };88 89 for (int32 i=4; i>=0; i--)90 {91 rgb_color color;92 if (m_meterLevel > i) {93 color = tint_color(METER_GREEN, kTintArray[i]);94 } else {95 color = METER_GREY;96 }97 view->SetHighColor(color);98 view->FillRect(cell);99 cell.OffsetBy(0, cell.Height() + 1);100 }101 102 view->PopState();103 }104 105 int32 MidiEventMeter::CalcMeterLevel(int32 eventCount) const106 {107 // we use an approximately logarithmic scale for determing the actual108 // drawn meter level, so that low-density event streams show up well.109 if (eventCount == 0) {110 return 0;111 } else if (eventCount < (int32)(.5*METER_SCALE)) {112 return 1;113 } else if (eventCount < (int32)(.75*METER_SCALE)) {114 return 2;115 } else if (eventCount < (int32)(.9*METER_SCALE)) {116 return 3;117 } else if (eventCount < METER_SCALE) {118 return 4;119 } else {120 return 5;121 }122 } -
deleted file src/tests/kits/midi/patchbay/MidiEventMeter.h
diff --git a/src/tests/kits/midi/patchbay/MidiEventMeter.h b/src/tests/kits/midi/patchbay/MidiEventMeter.h deleted file mode 100644 index b154d05..0000000
+ - 1 // MidiEventMeter.h2 // ----------------3 // A UI widget that measures the amount of MIDI data generated by a4 // consumer.5 //6 // Copyright 1999, Be Incorporated. All Rights Reserved.7 // This file may be used under the terms of the Be Sample Code License.8 9 #ifndef _MidiEventMeter_h10 #define _MidiEventMeter_h11 12 #include <Point.h>13 #include <Rect.h>14 15 class BMidiProducer;16 class CountEventConsumer;17 class BView;18 19 class MidiEventMeter20 {21 public:22 MidiEventMeter(int32 producerID);23 ~MidiEventMeter();24 25 void Pulse(BView* view);26 BRect Bounds() const;27 void Draw(BView* view);28 29 private:30 int32 CalcMeterLevel(int32 eventCount) const;31 32 CountEventConsumer* m_counter;33 int32 m_meterLevel;34 };35 36 #endif /* _MidiMeterWidget_h */ -
deleted file src/tests/kits/midi/patchbay/PatchApp.cpp
diff --git a/src/tests/kits/midi/patchbay/PatchApp.cpp b/src/tests/kits/midi/patchbay/PatchApp.cpp deleted file mode 100644 index ebe42ea..0000000
+ - 1 // PatchApp.cpp2 // ------------3 // Implements the PatchBay application class and main().4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #include <Roster.h>9 #include "PatchApp.h"10 #include "PatchWin.h"11 #include "TToolTip.h"12 13 PatchApp::PatchApp()14 : BApplication("application/x-vnd.Be-DTS.PatchBay"), m_toolTip(NULL)15 {16 m_toolTip = new TToolTip;17 }18 19 void PatchApp::ReadyToRun()20 {21 new PatchWin;22 }23 24 void PatchApp::MessageReceived(BMessage* msg)25 {26 switch (msg->what) {27 case B_SOME_APP_ACTIVATED:28 case eToolTipStart:29 case eToolTipStop:30 if (m_toolTip) m_toolTip->PostMessage(msg);31 break;32 default:33 BApplication::MessageReceived(msg);34 break;35 }36 }37 38 int main()39 {40 PatchApp app;41 app.Run();42 return 0;43 }44 -
deleted file src/tests/kits/midi/patchbay/PatchApp.h
diff --git a/src/tests/kits/midi/patchbay/PatchApp.h b/src/tests/kits/midi/patchbay/PatchApp.h deleted file mode 100644 index b4537a1..0000000
+ - 1 // PatchApp.h2 // ----------3 // The PatchBay application class.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #ifndef _PatchApp_h9 #define _PatchApp_h10 11 #include <Application.h>12 13 class TToolTip;14 15 class PatchApp : public BApplication16 {17 public:18 PatchApp();19 void ReadyToRun();20 void MessageReceived(BMessage* msg);21 22 private:23 TToolTip* m_toolTip;24 };25 26 #endif /* _PatchApp_h */ -
deleted file src/tests/kits/midi/patchbay/PatchBay.rsrc
diff --git a/src/tests/kits/midi/patchbay/PatchBay.rsrc b/src/tests/kits/midi/patchbay/PatchBay.rsrc deleted file mode 100644 index 1fecbbae19ad01d276b85a22a5cae941b62e6418..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001
-
deleted file src/tests/kits/midi/patchbay/PatchRow.cpp
literal 2861 zcmeHJPfHs?9Q`>fEd+{x@Duc|(yO;D*(?EV7FPsMl3GEbSdk$1mZ;b?wJpSmCN-sE zDFp-SN!uQT-Rfn*&mi6kg?@zTd%J492^McVurKfJyx*J2@PnOUS429qsdoIN_&fmI zVX#(E``d^zrrILT*BXQG?}M)<L>dTYe)FNo<7gQ<1Mj}%=iuK|Buen}zg~^|+#A=3 z^P`iF&mlgCxCi1Mh<o7wdLTDD`(k<`m!Ez))4$L=Kl8lLoa{}FxP4A8KQU$IUda<P zo5sht`|9fleq-?bZ^)S5@dQjudCjC_T$JjzI;}{Laq*@kkShu0?I!*x@25Z(zKZfb zizvT9SR$+gPAUdqEwrrV;j7LAwph_1Y!YhElz&LeMp-NWShPAhqAV_J<$Vcjzti_a z8-JTc0W50BZOn#cg*xRYTK2K-qDD%YJ1CO9MV?=xd`J17?1KiZQetb$uWBUk979$p z>zw#VR)g=?0c5ZO8Ek=hd&mnmDQldlgLy~r1r17;1+Q=KJ$EQG#E#|jNK7m14kR6C z+|AhGRf_Fv+iqy#jjl7Yq%(uo_{f-Jx!0~y$4N4T_s*_X(5N-+X0lJOZRtxJ?}QyK QTY4~Qx3a3ca|4){e+oLnMgRZ+ diff --git a/src/tests/kits/midi/patchbay/PatchRow.cpp b/src/tests/kits/midi/patchbay/PatchRow.cpp deleted file mode 100644 index 5906a29..0000000
+ - 1 // PatchRow.cpp2 // ------------3 // Implements the PatchRow class.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #include <stdio.h>9 #include <CheckBox.h>10 #include <Debug.h>11 #include <MidiRoster.h>12 #include <MidiConsumer.h>13 #include <MidiProducer.h>14 #include <Window.h>15 #include "MidiEventMeter.h"16 #include "PatchRow.h"17 18 extern const float ROW_LEFT = 50.0f;19 extern const float ROW_TOP = 50.0f;20 extern const float ROW_HEIGHT = 40.0f;21 extern const float COLUMN_WIDTH = 40.0f;22 extern const float METER_PADDING = 15.0f;23 extern const uint32 MSG_CONNECT_REQUEST = 'mCRQ';24 25 static const BPoint kBoxOffset(8,7);26 27 // PatchCheckBox is the check box that describes a connection28 // between a producer and a consumer.29 class PatchCheckBox : public BCheckBox30 {31 public:32 PatchCheckBox(BRect r, int32 producerID, int32 consumerID)33 : BCheckBox(r, "", "", new BMessage(MSG_CONNECT_REQUEST))34 {35 m_producerID = producerID;36 m_consumerID = consumerID;37 }38 39 int32 ProducerID() const { return m_producerID; }40 int32 ConsumerID() const { return m_consumerID; }41 42 void DoConnect();43 44 private:45 int32 m_producerID;46 int32 m_consumerID;47 };48 49 PatchRow::PatchRow(int32 producerID)50 : BView(BRect(0,0,0,0), "PatchRow", B_FOLLOW_NONE,51 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED),52 m_producerID(producerID), m_eventMeter(NULL)53 {54 m_eventMeter = new MidiEventMeter(m_producerID);55 }56 57 PatchRow::~PatchRow()58 {59 delete m_eventMeter;60 }61 62 int32 PatchRow::ID() const63 {64 return m_producerID;65 }66 67 void PatchRow::Pulse()68 {69 if (m_eventMeter) m_eventMeter->Pulse(this);70 }71 72 void PatchRow::Draw(BRect)73 {74 if (m_eventMeter) m_eventMeter->Draw(this);75 }76 77 void PatchRow::AddColumn(int32 consumerID)78 {79 BRect r;80 int32 numColumns = CountChildren();81 r.left = numColumns*COLUMN_WIDTH + METER_PADDING + kBoxOffset.x;82 r.top = kBoxOffset.y;83 r.right = r.left + 20;84 r.bottom = r.top + 20;85 86 PatchCheckBox* box = new PatchCheckBox(r, m_producerID, consumerID);87 AddChild(box);88 box->SetTarget(this);89 }90 91 void PatchRow::RemoveColumn(int32 consumerID)92 {93 int32 numChildren = CountChildren();94 for (int32 i=0; i<numChildren; i++) {95 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i));96 if (box && box->ConsumerID() == consumerID) {97 RemoveChild(box);98 delete box;99 while (i < numChildren) {100 box = dynamic_cast<PatchCheckBox*>(ChildAt(i++));101 if (box) {102 box->MoveBy(-COLUMN_WIDTH, 0);103 }104 }105 break;106 }107 }108 }109 110 void PatchRow::Connect(int32 consumerID)111 {112 int32 numChildren = CountChildren();113 for (int32 i=0; i<numChildren; i++) {114 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i));115 if (box && box->ConsumerID() == consumerID) {116 box->SetValue(1);117 }118 }119 }120 121 void PatchRow::Disconnect(int32 consumerID)122 {123 int32 numChildren = CountChildren();124 for (int32 i=0; i<numChildren; i++) {125 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i));126 if (box && box->ConsumerID() == consumerID) {127 box->SetValue(0);128 }129 }130 }131 132 void PatchRow::AttachedToWindow()133 {134 Window()->SetPulseRate(200000);135 SetViewColor(Parent()->ViewColor());136 int32 numChildren = CountChildren();137 for (int32 i=0; i<numChildren; i++) {138 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ChildAt(i));139 if (box) {140 box->SetTarget(this);141 }142 }143 }144 145 void PatchRow::MessageReceived(BMessage* msg)146 {147 switch (msg->what) {148 case MSG_CONNECT_REQUEST:149 {150 BControl* ctrl;151 if (msg->FindPointer("source", (void**) &ctrl) == B_OK) {152 PatchCheckBox* box = dynamic_cast<PatchCheckBox*>(ctrl);153 if (box) {154 box->DoConnect();155 }156 }157 }158 break;159 default:160 BView::MessageReceived(msg);161 break;162 }163 }164 165 void PatchCheckBox::DoConnect()166 {167 int32 value = Value();168 int32 inverseValue = (value + 1) % 2;169 170 BMidiRoster* roster = BMidiRoster::MidiRoster();171 if (! roster) {172 SetValue(inverseValue);173 return;174 }175 176 BMidiProducer* producer = roster->FindProducer(m_producerID);177 BMidiConsumer* consumer = roster->FindConsumer(m_consumerID);178 if (producer && consumer) {179 status_t err;180 if (value) {181 err = producer->Connect(consumer);182 } else {183 err = producer->Disconnect(consumer);184 }185 186 if (err != B_OK) {187 SetValue(inverseValue);188 }189 } else {190 SetValue(inverseValue);191 }192 if (producer) producer->Release();193 if (consumer) consumer->Release();194 } -
deleted file src/tests/kits/midi/patchbay/PatchRow.h
diff --git a/src/tests/kits/midi/patchbay/PatchRow.h b/src/tests/kits/midi/patchbay/PatchRow.h deleted file mode 100644 index a534313..0000000
+ - 1 #ifndef _PatchRow_h2 #define _PatchRow_h3 4 #include <View.h>5 6 extern const float ROW_LEFT;7 extern const float ROW_TOP;8 extern const float ROW_HEIGHT;9 extern const float COLUMN_WIDTH;10 extern const float METER_PADDING;11 extern const uint32 MSG_CONNECT_REQUEST;12 13 class MidiEventMeter;14 15 class PatchRow : public BView16 {17 public:18 PatchRow(int32 producerID);19 ~PatchRow();20 21 int32 ID() const;22 23 void AttachedToWindow();24 void MessageReceived(BMessage* msg);25 void Pulse();26 void Draw(BRect updateRect);27 28 void AddColumn(int32 consumerID);29 void RemoveColumn(int32 consumerID);30 void Connect(int32 consumerID);31 void Disconnect(int32 consumerID);32 33 private:34 int32 m_producerID;35 MidiEventMeter* m_eventMeter;36 };37 38 #endif /* _PatchRow_h */ -
deleted file src/tests/kits/midi/patchbay/PatchView.cpp
diff --git a/src/tests/kits/midi/patchbay/PatchView.cpp b/src/tests/kits/midi/patchbay/PatchView.cpp deleted file mode 100644 index 8235577..0000000
+ - 1 // PatchView.cpp2 // -------------3 // Implements the main PatchBay view class.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #include <Application.h>9 #include <Bitmap.h>10 #include <Debug.h>11 #include <InterfaceDefs.h>12 #include <Message.h>13 #include <Messenger.h>14 #include <MidiRoster.h>15 #include <Window.h>16 #include "EndpointInfo.h"17 #include "PatchView.h"18 #include "PatchRow.h"19 #include "TToolTip.h"20 #include "UnknownDeviceIcons.h"21 22 PatchView::PatchView(BRect r)23 : BView(r, "PatchView", B_FOLLOW_ALL, B_WILL_DRAW),24 m_unknownDeviceIcon(NULL), m_trackIndex(-1), m_trackType(TRACK_COLUMN)25 {26 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));27 28 uint8 iconSize;29 const uint8* iconData;30 31 if (DISPLAY_ICON_SIZE == B_LARGE_ICON) {32 iconSize = LARGE_ICON_SIZE;33 iconData = UnknownDevice::kLargeIconBits;34 } else {35 iconSize = MINI_ICON_SIZE;36 iconData = UnknownDevice::kMiniIconBits;37 }38 39 BRect iconFrame(0, 0, iconSize-1, iconSize-1);40 m_unknownDeviceIcon = new BBitmap(iconFrame, ICON_COLOR_SPACE);41 memcpy(m_unknownDeviceIcon->Bits(), iconData, m_unknownDeviceIcon->BitsLength());42 }43 44 PatchView::~PatchView()45 {46 delete m_unknownDeviceIcon;47 }48 49 void PatchView::AttachedToWindow()50 {51 BMidiRoster* roster = BMidiRoster::MidiRoster();52 if (! roster) {53 PRINT(("Couldn't get MIDI roster\n"));54 be_app->PostMessage(B_QUIT_REQUESTED);55 return;56 }57 58 BMessenger msgr(this);59 roster->StartWatching(&msgr);60 }61 62 void PatchView::MessageReceived(BMessage* msg)63 {64 switch (msg->what) {65 case B_MIDI_EVENT:66 HandleMidiEvent(msg);67 break;68 default:69 BView::MessageReceived(msg);70 break;71 }72 }73 74 void PatchView::MouseMoved(BPoint pt, uint32 transit, const BMessage* /* dragMsg */)75 {76 if (transit == B_EXITED_VIEW || transit == B_OUTSIDE_VIEW) {77 StopTipTracking();78 return;79 }80 81 bool found = false;82 int32 size = m_consumers.size();83 for (int32 i=0; (! found) && i<size; i++) {84 BRect r = ColumnIconFrameAt(i);85 if (r.Contains(pt)) {86 StartTipTracking(pt, r, i, TRACK_COLUMN);87 found = true;88 }89 }90 size = m_producers.size();91 for (int32 i=0; (! found) && i<size; i++) {92 BRect r = RowIconFrameAt(i);93 if (r.Contains(pt)) {94 StartTipTracking(pt, r, i, TRACK_ROW);95 found = true;96 }97 }98 }99 100 void PatchView::StopTipTracking()101 {102 m_trackIndex = -1;103 m_trackType = TRACK_COLUMN;104 StopTip();105 }106 107 void PatchView::StartTipTracking(BPoint pt, BRect rect, int32 index, track_type type)108 {109 if (index == m_trackIndex && type == m_trackType)110 return;111 112 StopTip();113 m_trackIndex = index;114 m_trackType = type;115 116 endpoint_itor begin, end;117 if (type == TRACK_COLUMN) {118 begin = m_consumers.begin();119 end = m_consumers.end();120 } else {121 begin = m_producers.begin();122 end = m_producers.end();123 }124 125 endpoint_itor i;126 for (i = begin; i != end; i++, index--)127 if (index <= 0) break;128 129 if (i == end)130 return;131 132 BMidiRoster* roster = BMidiRoster::MidiRoster();133 if (! roster)134 return;135 BMidiEndpoint* obj = roster->FindEndpoint(i->ID());136 if (! obj)137 return;138 139 BString str;140 str << "<" << obj->ID() << ">: " << obj->Name();141 obj->Release();142 StartTip(pt, rect, str.String());143 }144 145 void PatchView::StartTip(BPoint pt, BRect rect, const char* str)146 {147 BMessage msg(eToolTipStart);148 msg.AddPoint("start", ConvertToScreen(pt));149 msg.AddRect("bounds", ConvertToScreen(rect));150 msg.AddString("string", str);151 be_app->PostMessage(&msg);152 }153 154 void PatchView::StopTip()155 {156 be_app->PostMessage(eToolTipStop);157 }158 159 void PatchView::Draw(BRect /* updateRect */)160 {161 // draw producer icons162 SetDrawingMode(B_OP_OVER);163 int32 index = 0;164 for (list<EndpointInfo>::const_iterator i = m_producers.begin(); i != m_producers.end(); i++) {165 const BBitmap* bitmap = (i->Icon()) ? i->Icon() : m_unknownDeviceIcon;166 DrawBitmapAsync(bitmap, RowIconFrameAt(index++).LeftTop());167 }168 169 // draw consumer icons170 index = 0;171 for (list<EndpointInfo>::const_iterator i = m_consumers.begin(); i != m_consumers.end(); i++) {172 const BBitmap* bitmap = (i->Icon()) ? i->Icon() : m_unknownDeviceIcon;173 DrawBitmapAsync(bitmap, ColumnIconFrameAt(index++).LeftTop());174 }175 }176 177 BRect PatchView::ColumnIconFrameAt(int32 index) const178 {179 BRect r;180 r.left = ROW_LEFT + METER_PADDING + index*COLUMN_WIDTH;181 r.top = 10;182 r.right = r.left + 31;183 r.bottom = r.top + 31;184 return r;185 }186 187 BRect PatchView::RowIconFrameAt(int32 index) const188 {189 BRect r;190 r.left = 10;191 r.top = ROW_TOP + index*ROW_HEIGHT;192 r.right = r.left + 31;193 r.bottom = r.top + 31;194 return r;195 }196 197 void PatchView::HandleMidiEvent(BMessage* msg)198 {199 SET_DEBUG_ENABLED(true);200 201 int32 op;202 if (msg->FindInt32("be:op", &op) != B_OK) {203 PRINT(("PatchView::HandleMidiEvent: \"op\" field not found\n"));204 return;205 }206 207 switch (op) {208 case B_MIDI_REGISTERED:209 {210 int32 id;211 if (msg->FindInt32("be:id", &id) != B_OK) {212 PRINT(("PatchView::HandleMidiEvent: \"be:id\" field not found in B_MIDI_REGISTERED event\n"));213 break;214 }215 216 const char* type;217 if (msg->FindString("be:type", &type) != B_OK) {218 PRINT(("PatchView::HandleMidiEvent: \"be:type\" field not found in B_MIDI_REGISTERED event\n"));219 break;220 }221 222 PRINT(("MIDI Roster Event B_MIDI_REGISTERED: id=%ld, type=%s\n", id, type));223 if (! strcmp(type, "producer")) {224 AddProducer(id);225 } else if (! strcmp(type, "consumer")) {226 AddConsumer(id);227 }228 }229 break;230 case B_MIDI_UNREGISTERED:231 {232 int32 id;233 if (msg->FindInt32("be:id", &id) != B_OK) {234 PRINT(("PatchView::HandleMidiEvent: \"be:id\" field not found in B_MIDI_UNREGISTERED\n"));235 break;236 }237 238 const char* type;239 if (msg->FindString("be:type", &type) != B_OK) {240 PRINT(("PatchView::HandleMidiEvent: \"be:type\" field not found in B_MIDI_UNREGISTERED\n"));241 break;242 }243 244 PRINT(("MIDI Roster Event B_MIDI_UNREGISTERED: id=%ld, type=%s\n", id, type));245 if (! strcmp(type, "producer")) {246 RemoveProducer(id);247 } else if (! strcmp(type, "consumer")) {248 RemoveConsumer(id);249 }250 }251 break;252 case B_MIDI_CHANGED_PROPERTIES:253 {254 int32 id;255 if (msg->FindInt32("be:id", &id) != B_OK) {256 PRINT(("PatchView::HandleMidiEvent: \"be:id\" field not found in B_MIDI_CHANGED_PROPERTIES\n"));257 break;258 }259 260 const char* type;261 if (msg->FindString("be:type", &type) != B_OK) {262 PRINT(("PatchView::HandleMidiEvent: \"be:type\" field not found in B_MIDI_CHANGED_PROPERTIES\n"));263 break;264 }265 266 BMessage props;267 if (msg->FindMessage("be:properties", &props) != B_OK) {268 PRINT(("PatchView::HandleMidiEvent: \"be:properties\" field not found in B_MIDI_CHANGED_PROPERTIES\n"));269 break;270 }271 272 PRINT(("MIDI Roster Event B_MIDI_CHANGED_PROPERTIES: id=%ld, type=%s\n", id, type));273 if (! strcmp(type, "producer")) {274 UpdateProducerProps(id, &props);275 } else if (! strcmp(type, "consumer")) {276 UpdateConsumerProps(id, &props);277 }278 279 }280 break;281 case B_MIDI_CHANGED_NAME:282 case B_MIDI_CHANGED_LATENCY:283 // we don't care about these284 break;285 case B_MIDI_CONNECTED:286 {287 int32 prod;288 if (msg->FindInt32("be:producer", &prod) != B_OK) {289 PRINT(("PatchView::HandleMidiEvent: \"be:producer\" field not found in B_MIDI_CONNECTED\n"));290 break;291 }292 293 int32 cons;294 if (msg->FindInt32("be:consumer", &cons) != B_OK) {295 PRINT(("PatchView::HandleMidiEvent: \"be:consumer\" field not found in B_MIDI_CONNECTED\n"));296 break;297 }298 PRINT(("MIDI Roster Event B_MIDI_CONNECTED: producer=%ld, consumer=%ld\n", prod, cons));299 Connect(prod, cons);300 }301 break;302 case B_MIDI_DISCONNECTED:303 {304 int32 prod;305 if (msg->FindInt32("be:producer", &prod) != B_OK) {306 PRINT(("PatchView::HandleMidiEvent: \"be:producer\" field not found in B_MIDI_DISCONNECTED\n"));307 break;308 }309 310 int32 cons;311 if (msg->FindInt32("be:consumer", &cons) != B_OK) {312 PRINT(("PatchView::HandleMidiEvent: \"be:consumer\" field not found in B_MIDI_DISCONNECTED\n"));313 break;314 }315 PRINT(("MIDI Roster Event B_MIDI_DISCONNECTED: producer=%ld, consumer=%ld\n", prod, cons));316 Disconnect(prod, cons);317 }318 break;319 default:320 PRINT(("PatchView::HandleMidiEvent: unknown opcode %ld\n", op));321 break;322 }323 }324 325 void PatchView::AddProducer(int32 id)326 {327 EndpointInfo info(id);328 m_producers.push_back(info);329 330 Window()->BeginViewTransaction();331 PatchRow* row = new PatchRow(id);332 m_patchRows.push_back(row);333 BPoint p1 = CalcRowOrigin(m_patchRows.size() - 1);334 BPoint p2 = CalcRowSize();335 row->MoveTo(p1);336 row->ResizeTo(p2.x, p2.y);337 for (list<EndpointInfo>::const_iterator i = m_consumers.begin(); i != m_consumers.end(); i++) {338 row->AddColumn(i->ID());339 }340 AddChild(row);341 Invalidate();342 Window()->EndViewTransaction();343 }344 345 void PatchView::AddConsumer(int32 id)346 {347 EndpointInfo info(id);348 m_consumers.push_back(info);349 350 Window()->BeginViewTransaction();351 BPoint newSize = CalcRowSize();352 for (row_itor i = m_patchRows.begin(); i != m_patchRows.end(); i++) {353 (*i)->AddColumn(id);354 (*i)->ResizeTo(newSize.x, newSize.y - 1);355 }356 Invalidate();357 Window()->EndViewTransaction();358 }359 360 void PatchView::RemoveProducer(int32 id)361 {362 for (endpoint_itor i = m_producers.begin(); i != m_producers.end(); i++) {363 if (i->ID() == id) {364 m_producers.erase(i);365 break;366 }367 }368 369 Window()->BeginViewTransaction();370 for (row_itor i = m_patchRows.begin(); i != m_patchRows.end(); i++) {371 if ((*i)->ID() == id) {372 PatchRow* row = *i;373 i = m_patchRows.erase(i);374 RemoveChild(row);375 delete row;376 float moveBy = -1*CalcRowSize().y;377 while (i != m_patchRows.end()) {378 (*i++)->MoveBy(0, moveBy);379 }380 break;381 }382 }383 Invalidate();384 Window()->EndViewTransaction();385 }386 387 void PatchView::RemoveConsumer(int32 id)388 {389 Window()->BeginViewTransaction();390 for (endpoint_itor i = m_consumers.begin(); i != m_consumers.end(); i++) {391 if (i->ID() == id) {392 m_consumers.erase(i);393 break;394 }395 }396 397 BPoint newSize = CalcRowSize();398 for (row_itor i = m_patchRows.begin(); i != m_patchRows.end(); i++) {399 (*i)->RemoveColumn(id);400 (*i)->ResizeTo(newSize.x, newSize.y - 1);401 }402 Invalidate();403 Window()->EndViewTransaction();404 }405 406 void PatchView::UpdateProducerProps(int32 id, const BMessage* props)407 {408 for (endpoint_itor i = m_producers.begin(); i != m_producers.end(); i++) {409 if (i->ID() == id) {410 i->UpdateProperties(props);411 Invalidate();412 break;413 }414 }415 }416 417 void PatchView::UpdateConsumerProps(int32 id, const BMessage* props)418 {419 for (endpoint_itor i = m_consumers.begin(); i != m_consumers.end(); i++) {420 if (i->ID() == id) {421 i->UpdateProperties(props);422 Invalidate();423 break;424 }425 }426 }427 428 void PatchView::Connect(int32 prod, int32 cons)429 {430 for (row_itor i = m_patchRows.begin(); i != m_patchRows.end(); i++) {431 if ((*i)->ID() == prod) {432 (*i)->Connect(cons);433 break;434 }435 }436 }437 438 void PatchView::Disconnect(int32 prod, int32 cons)439 {440 for (row_itor i = m_patchRows.begin(); i != m_patchRows.end(); i++) {441 if ((*i)->ID() == prod) {442 (*i)->Disconnect(cons);443 break;444 }445 }446 }447 448 BPoint PatchView::CalcRowOrigin(int32 rowIndex) const449 {450 BPoint pt;451 pt.x = ROW_LEFT;452 pt.y = ROW_TOP + rowIndex*ROW_HEIGHT;453 return pt;454 }455 456 BPoint PatchView::CalcRowSize() const457 {458 BPoint pt;459 pt.x = METER_PADDING + m_consumers.size()*COLUMN_WIDTH;460 pt.y = ROW_HEIGHT - 1;461 return pt;462 } -
deleted file src/tests/kits/midi/patchbay/PatchView.h
diff --git a/src/tests/kits/midi/patchbay/PatchView.h b/src/tests/kits/midi/patchbay/PatchView.h deleted file mode 100644 index 9b36d55..0000000
+ - 1 // PatchView.h2 // -----------3 // The main PatchBay view contains a row of icons along the top and4 // left sides representing available consumers and producers, and5 // a set of PatchRows which build the matrix of connections.6 //7 // Copyright 1999, Be Incorporated. All Rights Reserved.8 // This file may be used under the terms of the Be Sample Code License.9 10 #ifndef _PatchView_h11 #define _PatchView_h12 13 #include <Rect.h>14 #include <View.h>15 #include <list>16 #include "EndpointInfo.h"17 18 class PatchRow;19 class BBitmap;20 class TToolTip;21 22 using namespace std;23 24 class PatchView : public BView25 {26 public:27 PatchView(BRect r);28 ~PatchView();29 30 void AttachedToWindow();31 void MessageReceived(BMessage* msg);32 void Draw(BRect updateRect);33 void MouseMoved(BPoint point, uint32 transit, const BMessage* dragMsg);34 35 private:36 typedef enum {37 TRACK_COLUMN,38 TRACK_ROW39 } track_type;40 41 BRect ColumnIconFrameAt(int32 index) const;42 BRect RowIconFrameAt(int32 index) const;43 void StartTipTracking(BPoint pt, BRect rect, int32 index, track_type type=TRACK_COLUMN);44 void StopTipTracking();45 void StartTip(BPoint pt, BRect rect, const char* str);46 void StopTip();47 48 void AddProducer(int32 id);49 void AddConsumer(int32 id);50 void RemoveProducer(int32 id);51 void RemoveConsumer(int32 id);52 void UpdateProducerProps(int32 id, const BMessage* props);53 void UpdateConsumerProps(int32 id, const BMessage* props);54 void Connect(int32 prod, int32 cons);55 void Disconnect(int32 prod, int32 cons);56 57 void HandleMidiEvent(BMessage* msg);58 59 BPoint CalcRowOrigin(int32 rowIndex) const;60 BPoint CalcRowSize() const;61 62 typedef list<EndpointInfo>::iterator endpoint_itor;63 typedef list<EndpointInfo>::const_iterator const_endpoint_itor;64 typedef list<PatchRow*>::iterator row_itor;65 66 list<EndpointInfo> m_producers;67 list<EndpointInfo> m_consumers;68 list<PatchRow*> m_patchRows;69 BBitmap* m_unknownDeviceIcon;70 int32 m_trackIndex;71 track_type m_trackType;72 TToolTip* m_toolTip;73 };74 75 #endif /* _PatchView_h */ -
deleted file src/tests/kits/midi/patchbay/PatchWin.cpp
diff --git a/src/tests/kits/midi/patchbay/PatchWin.cpp b/src/tests/kits/midi/patchbay/PatchWin.cpp deleted file mode 100644 index 2511b85..0000000
+ - 1 // PatchWin.cpp2 // ------------3 // Implements the main PatchBay window class.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #include <Application.h>9 #include "PatchWin.h"10 #include "PatchView.h"11 12 PatchWin::PatchWin()13 : BWindow(BRect(50,50,450,450), "Patch Bay", B_TITLED_WINDOW, 0)14 {15 BRect r = Bounds();16 m_patchView = new PatchView(r);17 AddChild(m_patchView);18 Show();19 }20 21 bool PatchWin::QuitRequested()22 {23 be_app->PostMessage(B_QUIT_REQUESTED);24 return true;25 }26 -
deleted file src/tests/kits/midi/patchbay/PatchWin.h
diff --git a/src/tests/kits/midi/patchbay/PatchWin.h b/src/tests/kits/midi/patchbay/PatchWin.h deleted file mode 100644 index a7ab58e..0000000
+ - 1 // PatchWin.h2 // ----------3 // The main PatchBay window class.4 //5 // Copyright 1999, Be Incorporated. All Rights Reserved.6 // This file may be used under the terms of the Be Sample Code License.7 8 #ifndef _PatchWin_h9 #define _PatchWin_h10 11 #include <Window.h>12 13 class PatchView;14 15 class PatchWin : public BWindow16 {17 public:18 PatchWin();19 bool QuitRequested();20 private:21 PatchView* m_patchView;22 };23 24 #endif /* _PatchWin_h */ -
deleted file src/tests/kits/midi/patchbay/TToolTip.cpp
diff --git a/src/tests/kits/midi/patchbay/TToolTip.cpp b/src/tests/kits/midi/patchbay/TToolTip.cpp deleted file mode 100644 index 17ee1ca..0000000
+ - 1 //--------------------------------------------------------------------2 //3 // TToolTip.cpp4 //5 // Written by: Robert Polic6 //7 //--------------------------------------------------------------------8 9 #include <Screen.h>10 #include <stdio.h>11 #include <stdlib.h>12 #include <string.h>13 14 #include <Application.h>15 #include <Roster.h>16 17 #include "TToolTip.h"18 19 #define kHOR_MARGIN 4 // hor. gap between frame and tip20 #define kVER_MARGIN 3 // ver. gap between frame and tip21 #define kTIP_HOR_OFFSET 10 // tip position right of cursor22 #define kTIP_VER_OFFSET 16 // tip position below cursor23 #define kSLOP 4 // mouse slop before tip hides24 25 #define kTOOL_TIP_DELAY_TIME 500000 // default delay time before tip shows (.5 secs.)26 #define kTOOL_TIP_HOLD_TIME 3000000 // default hold time of time (3 secs.)27 28 #define kDRAW_WINDOW_FRAME29 30 const rgb_color kVIEW_COLOR = {255, 203, 0, 255}; // view background color (light yellow)31 const rgb_color kLIGHT_VIEW_COLOR = {255, 255, 80, 255}; // top left frame highlight32 const rgb_color kDARK_VIEW_COLOR = {175, 123, 0, 255}; // bottom right frame highlight33 const rgb_color kTEXT_COLOR = {0, 0, 0, 255}; // text color (black)34 35 36 //====================================================================37 38 TToolTip::TToolTip(tool_tip_settings *settings)39 :BWindow(BRect(0, 0, 10, 10), "tool_tip", B_NO_BORDER_WINDOW_LOOK,40 B_FLOATING_ALL_WINDOW_FEEL, B_AVOID_FRONT)41 {42 // setup the tooltip view43 AddChild(fView = new TToolTipView(settings));44 // start the message loop thread45 Run();46 }47 48 //--------------------------------------------------------------------49 50 void TToolTip::MessageReceived(BMessage *msg)51 {52 switch (msg->what) {53 // forward interesting messages to the view54 case B_SOME_APP_ACTIVATED:55 case eToolTipStart:56 case eToolTipStop:57 PostMessage(msg, fView);58 break;59 default:60 BWindow::MessageReceived(msg);61 }62 }63 64 //--------------------------------------------------------------------65 66 void TToolTip::GetSettings(tool_tip_settings *settings)67 {68 fView->GetSettings(settings);69 }70 71 //--------------------------------------------------------------------72 73 void TToolTip::SetSettings(tool_tip_settings *settings)74 {75 fView->SetSettings(settings);76 }77 78 79 //====================================================================80 81 TToolTipView::TToolTipView(tool_tip_settings *settings)82 :BView(BRect(0, 0, 10, 10), "tool_tip", B_FOLLOW_ALL, B_WILL_DRAW)83 {84 // initialize tooltip settings85 if (settings)86 // we should probably sanity-check user defined settings (but we won't)87 fTip.settings = *settings;88 else {89 // use defaults if no settings are passed90 fTip.settings.enabled = true;91 fTip.settings.one_time_only = false;92 fTip.settings.delay = kTOOL_TIP_DELAY_TIME;93 fTip.settings.hold = kTOOL_TIP_HOLD_TIME;94 fTip.settings.font = be_plain_font;95 }96 97 // initialize the tip98 fString = (char *)malloc(1);99 fString[0] = 0;100 101 // initialize the view102 SetFont(&fTip.settings.font);103 SetViewColor(kVIEW_COLOR);104 }105 106 //--------------------------------------------------------------------107 108 TToolTipView::~TToolTipView()109 {110 status_t status;111 112 // kill tool_tip thread113 fTip.quit = true;114 wait_for_thread(fThread, &status);115 116 // free tip117 free(fString);118 }119 120 //--------------------------------------------------------------------121 122 void TToolTipView::AllAttached()123 {124 // initialize internal settings125 fTip.app_active = true;126 fTip.quit = false;127 fTip.stopped = true;128 129 fTip.tool_tip_view = this;130 fTip.tool_tip_window = Window();131 132 // start tool_tip thread133 resume_thread(fThread = spawn_thread((status_t (*)(void *)) ToolTipThread,134 "tip_thread", B_DISPLAY_PRIORITY, &fTip));135 }136 137 //--------------------------------------------------------------------138 139 void TToolTipView::Draw(BRect /* where */)140 {141 char *src_strings[1];142 char *tmp_string;143 char *truncated_strings[1];144 BFont font;145 BRect r = Bounds();146 font_height finfo;147 148 // draw border around window149 #ifdef kDRAW_WINDOW_FRAME150 SetHighColor(0, 0, 0, 255);151 StrokeRect(r);152 r.InsetBy(1, 1);153 #endif154 SetHighColor(kLIGHT_VIEW_COLOR);155 StrokeLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top));156 StrokeLine(BPoint(r.left + 1, r.top), BPoint(r.right - 1, r.top));157 SetHighColor(kDARK_VIEW_COLOR);158 StrokeLine(BPoint(r.right, r.top), BPoint(r.right, r.bottom));159 StrokeLine(BPoint(r.right - 1, r.bottom), BPoint(r.left + 1, r.bottom));160 161 // set pen position162 GetFont(&font);163 font.GetHeight(&finfo);164 MovePenTo(kHOR_MARGIN + 1, kVER_MARGIN + finfo.ascent);165 166 // truncate string if needed167 src_strings[0] = fString;168 tmp_string = (char *)malloc(strlen(fString) + 16);169 truncated_strings[0] = tmp_string;170 font.GetTruncatedStrings((const char **)src_strings, 1, B_TRUNCATE_END,171 Bounds().Width() - (2 * kHOR_MARGIN) + 1, truncated_strings);172 173 // draw string174 SetLowColor(kVIEW_COLOR);175 SetHighColor(kTEXT_COLOR);176 DrawString(tmp_string);177 free(tmp_string);178 }179 180 //--------------------------------------------------------------------181 182 void TToolTipView::MessageReceived(BMessage *msg)183 {184 switch (msg->what) {185 case B_SOME_APP_ACTIVATED:186 msg->FindBool("active", &fTip.app_active);187 break;188 189 case eToolTipStart:190 {191 const char *str;192 193 // extract parameters194 msg->FindPoint("start", &fTip.start);195 msg->FindRect("bounds", &fTip.bounds);196 msg->FindString("string", &str);197 free(fString);198 fString = (char *)malloc(strlen(str) + 1);199 strcpy(fString, str);200 201 // force window to fit new parameters202 AdjustWindow();203 204 // flag thread to reset205 fTip.reset = true;206 }207 break;208 209 case eToolTipStop:210 // flag thread to stop211 fTip.stop = true;212 break;213 }214 }215 216 //--------------------------------------------------------------------217 218 void TToolTipView::GetSettings(tool_tip_settings *settings)219 {220 // return current settings221 *settings = fTip.settings;222 }223 224 //--------------------------------------------------------------------225 226 void TToolTipView::SetSettings(tool_tip_settings *settings)227 {228 bool invalidate = fTip.settings.font != settings->font;229 230 // we should probably sanity-check user defined settings (but we won't)231 fTip.settings = *settings;232 233 // if the font changed, adjust window to fit234 if (invalidate) {235 Window()->Lock();236 SetFont(&fTip.settings.font);237 AdjustWindow();238 Window()->Unlock();239 }240 }241 242 //--------------------------------------------------------------------243 244 void TToolTipView::AdjustWindow()245 {246 float width;247 float height;248 float x;249 float y;250 BScreen s(B_MAIN_SCREEN_ID);251 BRect screen = s.Frame();252 BWindow *wind = Window();253 font_height finfo;254 255 screen.InsetBy(2, 2); // we want a 2-pixel clearance256 fTip.settings.font.GetHeight(&finfo);257 width = fTip.settings.font.StringWidth(fString) + (kHOR_MARGIN * 2); // string width258 height = (finfo.ascent + finfo.descent + finfo.leading) + (kVER_MARGIN * 2); // string height259 260 // calculate new position and size of window261 x = fTip.start.x + kTIP_HOR_OFFSET;262 if ((x + width) > screen.right)263 x = screen.right - width;264 y = fTip.start.y + kTIP_VER_OFFSET;265 if ((y + height) > screen.bottom) {266 y = screen.bottom - height;267 if ((fTip.start.y >= (y - kSLOP)) && (fTip.start.y <= (y + height)))268 y = fTip.start.y - kTIP_VER_OFFSET - height;269 }270 if (x < screen.left) {271 width -= screen.left - x;272 x = screen.left;273 }274 if (y < screen.top) {275 height -= screen.top - y;276 y = screen.top;277 }278 279 wind->MoveTo((int)x, (int)y);280 wind->ResizeTo((int)width, (int)height);281 282 // force an update283 Invalidate(Bounds());284 }285 286 //--------------------------------------------------------------------287 288 status_t TToolTipView::ToolTipThread(tool_tip *tip)289 {290 uint32 buttons;291 BPoint where;292 BScreen s(B_MAIN_SCREEN_ID);293 BRect screen = s.Frame();294 295 screen.InsetBy(2, 2);296 while (!tip->quit) {297 if (tip->tool_tip_window->LockWithTimeout(0) == B_NO_ERROR) {298 tip->tool_tip_view->GetMouse(&where, &buttons);299 tip->tool_tip_view->ConvertToScreen(&where);300 301 tip->stopped = tip->stop;302 if (tip->reset) {303 if (tip->showing)304 tip->tool_tip_window->Hide();305 tip->stop = false;306 tip->stopped = false;307 tip->reset = false;308 tip->shown = false;309 tip->showing = false;310 tip->start_time = system_time() + tip->settings.delay;311 }312 else if (tip->showing) {313 if ((tip->stop) ||314 (!tip->settings.enabled) ||315 (!tip->app_active) ||316 (!tip->bounds.Contains(where)) ||317 (tip->expire_time < system_time()) ||318 (abs((int)tip->start.x - (int)where.x) > kSLOP) ||319 (abs((int)tip->start.y - (int)where.y) > kSLOP) ||320 (buttons)) {321 tip->tool_tip_window->Hide();322 tip->shown = tip->settings.one_time_only;323 tip->showing = false;324 tip->tip_timed_out = (tip->expire_time < system_time());325 tip->start_time = system_time() + tip->settings.delay;326 }327 }328 else if ((tip->settings.enabled) &&329 (!tip->stopped) &&330 (tip->app_active) &&331 (!tip->shown) &&332 (!tip->tip_timed_out) &&333 (!buttons) &&334 (tip->bounds.Contains(where)) &&335 (tip->start_time < system_time())) {336 tip->start = where;337 tip->tool_tip_view->AdjustWindow();338 tip->tool_tip_window->Show();339 tip->tool_tip_window->Activate(false);340 tip->showing = true;341 tip->expire_time = system_time() + tip->settings.hold;342 tip->start = where;343 }344 else if ((abs((int)tip->start.x - (int)where.x) > kSLOP) ||345 (abs((int)tip->start.y - (int)where.y) > kSLOP)) {346 tip->start = where;347 tip->start_time = system_time() + tip->settings.delay;348 tip->tip_timed_out = false;349 }350 if (buttons)351 tip->start_time = system_time() + tip->settings.delay;352 tip->tool_tip_window->Unlock();353 }354 snooze(50000);355 }356 return B_NO_ERROR;357 }358 No newline at end of file -
deleted file src/tests/kits/midi/patchbay/TToolTip.h
diff --git a/src/tests/kits/midi/patchbay/TToolTip.h b/src/tests/kits/midi/patchbay/TToolTip.h deleted file mode 100644 index 1288d55..0000000
+ - 1 //--------------------------------------------------------------------2 //3 // TToolTip.h4 //5 // Written by: Robert Polic6 //7 //--------------------------------------------------------------------8 9 #ifndef T_TOOL_TIPS_H10 #define T_TOOL_TIPS_H11 12 #include <Font.h>13 #include <Window.h>14 #include <View.h>15 16 enum TOOL_TIP_MESSAGES {eToolTipStart = 'ttGo',17 eToolTipStop = 'ttSp'};18 19 // ui settings20 struct tool_tip_settings {21 bool enabled; // flag whether tips are enables or not22 bool one_time_only; // flag to only display the tip once per time in view23 bigtime_t delay; // delay before tip is shown in microseconds24 bigtime_t hold; // amount of time tip is displayed in microseconds25 BFont font; // font tip is drawn in26 };27 28 // internal settings29 struct tool_tip {30 bool app_active;31 bool quit;32 bool stop;33 bool stopped;34 bool reset;35 bool shown;36 bool showing;37 bool tip_timed_out;38 BPoint start;39 BRect bounds;40 class TToolTipView *tool_tip_view;41 BWindow *tool_tip_window;42 bigtime_t start_time;43 bigtime_t expire_time;44 tool_tip_settings settings;45 };46 47 48 //====================================================================49 50 class TToolTip : public BWindow {51 52 public:53 TToolTip(tool_tip_settings *settings = NULL);54 virtual void MessageReceived(BMessage*);55 56 void GetSettings(tool_tip_settings*);57 void SetSettings(tool_tip_settings*);58 59 private:60 class TToolTipView *fView;61 };62 63 64 //====================================================================65 66 class TToolTipView : public BView {67 68 public:69 TToolTipView(tool_tip_settings *settings = NULL);70 ~TToolTipView();71 virtual void AllAttached();72 virtual void Draw(BRect);73 virtual void MessageReceived(BMessage*);74 75 void GetSettings(tool_tip_settings*);76 void SetSettings(tool_tip_settings*);77 78 private:79 void AdjustWindow();80 static status_t ToolTipThread(tool_tip*);81 82 char *fString;83 thread_id fThread;84 tool_tip fTip;85 };86 #endif -
deleted file src/tests/kits/midi/patchbay/UnknownDeviceIcons.h
diff --git a/src/tests/kits/midi/patchbay/UnknownDeviceIcons.h b/src/tests/kits/midi/patchbay/UnknownDeviceIcons.h deleted file mode 100644 index 27efec7..0000000
+ - 1 // UnknownDeviceIcons.h2 // --------------------3 // The icons to be used in case a device doesn't supply its icons.4 // In the future, this could be better selected if the device supported5 // other descriptive property fields.6 //7 // Large and mini versions are available. PatchBay currently uses the8 // large version.9 //10 // Copyright 1999, Be Incorporated. All Rights Reserved.11 // This file may be used under the terms of the Be Sample Code License.12 13 #ifndef _UnknownDeviceIcons_h14 #define _UnknownDeviceIcons_h15 16 namespace UnknownDevice {17 18 const unsigned char kLargeIconBits [] = {19 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,20 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,21 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,22 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,23 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,24 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,25 0xff,0xff,0xff,0xff,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,26 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0xff,27 0xff,0xff,0xff,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,28 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0c,0x0c,29 0xff,0xff,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,30 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x08,0x08,0x0c,31 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,32 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x08,0x0c,33 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,34 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,35 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x0d,0x04,0x00,0x00,0x04,36 0x0d,0x1b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,37 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x16,0x00,0x00,0x00,0x00,0x00,0x00,38 0x00,0x00,0x12,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,39 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,40 0x00,0x00,0x00,0x16,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,41 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x0d,0x00,0x00,0x00,0x0d,0x1b,0x3f,0x16,42 0x04,0x00,0x00,0x09,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,43 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x04,0x00,0x00,0x0d,0x3f,0x3f,0x3f,0x3f,44 0x16,0x00,0x00,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,45 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x1b,0x3f,0x3f,0x3f,0x3f,46 0x1b,0x00,0x00,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,47 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,48 0x04,0x00,0x00,0x04,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,49 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x0d,0x00,50 0x00,0x00,0x00,0x16,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,51 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,0x00,0x00,0x00,52 0x00,0x0d,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,53 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x04,0x00,0x00,0x09,54 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,55 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x3f,56 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,57 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,58 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,59 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,60 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,61 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x00,62 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,63 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x00,64 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0x0c,65 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x00,66 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0x08,0xff,67 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,0x00,0x00,68 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x04,0xff,0xff,69 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,70 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0xff,0xff,0xff,71 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,72 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,73 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,74 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,75 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,76 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,77 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,78 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,79 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,80 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,81 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,82 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff83 };84 85 const unsigned char kMiniIconBits [] = {86 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,87 0xff,0xff,0xff,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0xff,88 0xff,0xff,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0c,0x0c,89 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x0c,90 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0x0c,91 0x00,0x3f,0x3f,0x3f,0x16,0x00,0x00,0x00,0x1b,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0x0c,92 0x00,0x3f,0x3f,0x3f,0x00,0x16,0x3f,0x1b,0x00,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0x0c,93 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,0x00,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0x0c,94 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x09,0x00,0x1b,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0x0c,95 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x1b,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0x0c,96 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0x0c,97 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x08,0xff,98 0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0xff,0xff,99 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,100 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,101 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff102 };103 104 }105 106 #endif /* _UnknownDeviceIcons_h */