First draft of a midi preflet.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
SubDir HAIKU_TOP src preferences midi ;
|
||||
|
||||
Preference Midi :
|
||||
MidiApp.cpp
|
||||
MidiView.cpp
|
||||
MidiWindow.cpp
|
||||
: midi be localestub [ TargetLibsupc++ ]
|
||||
;
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2014, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
#include "MidiWindow.h"
|
||||
|
||||
class MidiApp : public BApplication {
|
||||
public:
|
||||
MidiApp();
|
||||
virtual void ReadyToRun();
|
||||
};
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
MidiApp app;
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
MidiApp::MidiApp()
|
||||
:
|
||||
BApplication("application/x-vnd.MidiPreflet")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* virtual */
|
||||
void
|
||||
MidiApp::ReadyToRun()
|
||||
{
|
||||
(new MidiWindow())->Show();
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2014, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "MidiView.h"
|
||||
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <GridView.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <ListView.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const static uint32 kImportSoundFont = 'ImSf';
|
||||
|
||||
MidiView::MidiView()
|
||||
:
|
||||
BGroupView(B_VERTICAL, B_USE_DEFAULT_SPACING)
|
||||
{
|
||||
BBox* defaultsBox = new BBox("defaults");
|
||||
defaultsBox->SetLabel("Defaults");
|
||||
BGridView* defaultsGridView = new BGridView();
|
||||
|
||||
fListView = new BListView(B_SINGLE_SELECTION_LIST);
|
||||
fImportButton = new BButton("Import SoundFont",
|
||||
new BMessage(kImportSoundFont));
|
||||
|
||||
BLayoutBuilder::Grid<>(defaultsGridView)
|
||||
.SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING,
|
||||
B_USE_DEFAULT_SPACING)
|
||||
.Add(fListView, 0, 0)
|
||||
.Add(fImportButton, 0, 1);
|
||||
|
||||
defaultsBox->AddChild(defaultsGridView);
|
||||
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.SetInsets(0, 0, 0, 0)
|
||||
.Add(defaultsBox)
|
||||
.AddGlue();
|
||||
}
|
||||
|
||||
|
||||
/* virtual */
|
||||
void
|
||||
MidiView::AttachedToWindow()
|
||||
{
|
||||
fImportButton->SetTarget(this);
|
||||
_RetrieveSoftSynthList();
|
||||
}
|
||||
|
||||
|
||||
/* virtual */
|
||||
void
|
||||
MidiView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kImportSoundFont:
|
||||
break;
|
||||
|
||||
default:
|
||||
BGroupView::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MidiView::_RetrieveSoftSynthList()
|
||||
{
|
||||
char **paths = NULL;
|
||||
size_t pathCount = 0;
|
||||
status_t status = find_paths(B_FIND_PATH_DATA_DIRECTORY, "synth",
|
||||
&paths, &pathCount);
|
||||
if (status != B_OK)
|
||||
return;
|
||||
|
||||
fListView->MakeEmpty();
|
||||
|
||||
for (size_t i = 0; i < pathCount; i++) {
|
||||
BDirectory directory(paths[i]);
|
||||
BEntry entry;
|
||||
if (directory.InitCheck() != B_OK)
|
||||
continue;
|
||||
while (directory.GetNextEntry(&entry) == B_OK) {
|
||||
fListView->AddItem(new BStringItem(entry.Name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2014, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef MIDIVIEW_H_
|
||||
#define MIDIVIEW_H_
|
||||
|
||||
|
||||
#include <GroupView.h>
|
||||
|
||||
class BButton;
|
||||
class BListView;
|
||||
class MidiView : public BGroupView {
|
||||
public:
|
||||
MidiView();
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
void _RetrieveSoftSynthList();
|
||||
|
||||
BButton* fImportButton;
|
||||
BListView* fListView;
|
||||
};
|
||||
|
||||
#endif /* MIDIVIEW_H_ */
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2014, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "MidiWindow.h"
|
||||
|
||||
#include <LayoutBuilder.h>
|
||||
|
||||
#include "MidiView.h"
|
||||
|
||||
|
||||
MidiWindow::MidiWindow()
|
||||
:
|
||||
BWindow(BRect(40, 40, 260, 260), "Midi Preferences",
|
||||
B_TITLED_WINDOW, B_SUPPORTS_LAYOUT)
|
||||
{
|
||||
fMidiView = new MidiView();
|
||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL)
|
||||
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||
.Add(fMidiView, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2014, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef MIDIWINDOW_H_
|
||||
#define MIDIWINDOW_H_
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
class MidiView;
|
||||
class MidiWindow : public BWindow {
|
||||
public:
|
||||
MidiWindow();
|
||||
private:
|
||||
MidiView* fMidiView;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MIDIWINDOW_H_ */
|
||||
Reference in New Issue
Block a user