Skip to content

Commit

Permalink
Polish UI a bit more.
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoru committed Nov 21, 2020
1 parent 5040181 commit 4e50ea4
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 58 deletions.
80 changes: 40 additions & 40 deletions src/AudioSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,111 +18,106 @@ wxBEGIN_EVENT_TABLE(AudioSplitter, wxFrame)
EVT_COMMAND(ID_BrowseOutPath, wxEVT_COMMAND_BUTTON_CLICKED, AudioSplitter::OnBrowseOutput)
EVT_COMMAND(wxID_CLOSE, wxEVT_COMMAND_BUTTON_CLICKED, AudioSplitter::OnClose)
EVT_DROP_FILES(AudioSplitter::OnDropFiles)
EVT_SIZE(AudioSplitter::OnSize)
wxEND_EVENT_TABLE()

AudioSplitter::AudioSplitter(wxWindow *parent, const wxPoint &pos, const wxSize &size, Division *div)
: wxFrame(parent, wxID_ANY,
wxString::Format(_("Audio splitter (division: \"%s\")"), div->get_name()),
pos, size),
pos, size, wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX)),
division(div) {

panel = new wxPanel(this);
auto sizer = new wxBoxSizer(wxVERTICAL);
auto inner_flags = wxSizerFlags().Border(wxALL, 10);

/* audio file input */
auto panel_input = new wxPanel(this);
auto panel_input = new wxPanel(panel);
auto panel_input_sizer = new wxStaticBoxSizer(wxVERTICAL, panel_input, _("Audio File"));
panel_input->SetSizer(panel_input_sizer);

auto lbl = new wxStaticText(panel_input, wxID_ANY, _("You can drag and drop a .wav file into this window."));
panel_input_sizer->Add(lbl, 0, wxEXPAND);
panel_input_sizer->Add(lbl, inner_flags.Expand());

auto panel_input_second_row = new wxBoxSizer(wxHORIZONTAL);
filename_ctrl = new wxTextCtrl(panel_input, ID_FilenameCtrl);
filename_ctrl->SetToolTip(new wxToolTip(_("You can drag and drop a wav file into this window.")));
panel_input_second_row->Add(filename_ctrl, 1);

panel_input_second_row->AddSpacer(5);
panel_input_second_row->Add(filename_ctrl, inner_flags.Expand().Proportion(1));

auto browse_btn = new wxButton(panel_input, ID_BrowseFilename, _("Browse..."));
panel_input_second_row->Add(browse_btn, 0);
panel_input_sizer->Add(panel_input_second_row, 1, wxEXPAND);
panel_input_second_row->Add(browse_btn, inner_flags.Proportion(0));
panel_input_sizer->Add(panel_input_second_row, inner_flags.Expand());

/* audio file output */
auto panel_output = new wxPanel(this);
auto panel_output = new wxPanel(panel);
auto panel_output_sizer = new wxStaticBoxSizer(wxVERTICAL, panel_output, _("Output Directory"));
panel_output->SetSizer(panel_output_sizer);

/* 1st row */
auto panel_output_path_sizer = new wxBoxSizer(wxHORIZONTAL);

output_dir_ctrl = new wxTextCtrl(panel_output, ID_OutPathCtrl);
panel_output_path_sizer->Add(output_dir_ctrl, 2);

panel_output_path_sizer->AddSpacer(5);
panel_output_path_sizer->Add(output_dir_ctrl, inner_flags.Expand().Proportion(1));

auto browse_output_btn = new wxButton(panel_output, ID_BrowseOutPath, _("Browse..."));
panel_output_path_sizer->Add(browse_output_btn, 0);
panel_output_path_sizer->Add(browse_output_btn, inner_flags.Proportion(0));

panel_output_sizer->Add(panel_output_path_sizer, 2, wxEXPAND);

panel_output_sizer->AddSpacer(20);
panel_output_sizer->Add(panel_output_path_sizer, inner_flags.Expand().Proportion(1));

/* 2nd row */
auto panel_output_filename_sizer = new wxBoxSizer(wxHORIZONTAL);
panel_output_filename_sizer->Add(new wxStaticText(panel_output, wxID_ANY, _("Output sound file prefix:")), 1);

panel_output_filename_sizer->AddSpacer(20);
panel_output_filename_sizer->Add(
new wxStaticText(panel_output, wxID_ANY, _("Output sound file prefix:")),
wxSizerFlags().Border(wxALL, 10).Expand()
);

output_prefix_ctrl = new wxTextCtrl(panel_output, ID_OutputPrefix, div->get_name());
panel_output_filename_sizer->Add(output_prefix_ctrl, 2);
panel_output_filename_sizer->Add(output_prefix_ctrl, inner_flags);
output_prefix_ctrl->SetToolTip(new wxToolTip(_("Should be the same as the BMS WAV definitions.")));

panel_output_sizer->Add(panel_output_filename_sizer, 2, wxEXPAND);
panel_output_sizer->Add(panel_output_filename_sizer, inner_flags);

/* slice parameters */
auto panel_parameters = new wxPanel(this);
auto panel_parameters = new wxPanel(panel);
auto panel_parameters_sizer = new wxStaticBoxSizer(wxHORIZONTAL, panel_parameters, _("Slice Parameters"));
panel_parameters->SetSizer(panel_parameters_sizer);

auto lbl_bpm = new wxStaticText(panel_parameters, wxID_ANY, "BPM:");
panel_parameters_sizer->Add(lbl_bpm, 1);
panel_parameters_sizer->Add(lbl_bpm, inner_flags);

bpm_ctrl = new wxSpinCtrlDouble(panel_parameters);
bpm_ctrl->SetRange(1, 5000);
bpm_ctrl->SetDigits(3);
bpm_ctrl->SetDigits(2);
bpm_ctrl->SetValue(120);
panel_parameters_sizer->Add(bpm_ctrl, 3);

panel_parameters_sizer->AddSpacer(20);
panel_parameters_sizer->Add(bpm_ctrl, inner_flags.Proportion(1));

auto lbl_offset = new wxStaticText(panel_parameters, wxID_ANY, "Offset (MS):");
panel_parameters_sizer->Add(lbl_offset, 1);
panel_parameters_sizer->Add(lbl_offset, inner_flags.Proportion(1));

offset_ctrl = new wxSpinCtrlDouble(panel_parameters);
offset_ctrl->SetRange(-10000, 10000);
offset_ctrl->SetValue(0);
panel_parameters_sizer->Add(offset_ctrl, 2);
panel_parameters_sizer->Add(offset_ctrl, inner_flags.Proportion(1));


/* Actions */
auto panel_bottom = new wxPanel(this);
auto panel_bottom = new wxPanel(panel);
auto panel_bottom_sizer = new wxBoxSizer(wxHORIZONTAL);
panel_bottom->SetSizer(panel_bottom_sizer);


auto split_btn = new wxButton(panel_bottom, ID_Split, _("Split"));
auto close_btn = new wxButton(panel_bottom, wxID_CLOSE, _("Close"));
panel_bottom_sizer->Add(split_btn, 3);
panel_bottom_sizer->AddSpacer(20);
panel_bottom_sizer->Add(close_btn, 3);

panel_bottom_sizer->Add(split_btn);
panel_bottom_sizer->Add(close_btn);

sizer->Add(panel_input, 1, wxEXPAND);
sizer->Add(panel_output, 1, wxEXPAND);
sizer->Add(panel_parameters, 1, wxEXPAND);
sizer->Add(panel_bottom, 0, wxEXPAND);
sizer->Add(panel_input, wxSizerFlags().Border(wxALL, 10).Expand());
sizer->Add(panel_output, wxSizerFlags().Border(wxALL, 10).Expand());
sizer->Add(panel_parameters, wxSizerFlags().Border(wxALL, 10).Expand());
sizer->Add(panel_bottom, wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL, 10));

SetSizerAndFit(sizer);
SetMinSize(size);
panel->SetSize(GetSize());
// SetMinSize(size);

DragAcceptFiles(true);
}
Expand Down Expand Up @@ -216,4 +211,9 @@ void AudioSplitter::OnClose(wxCommandEvent &evt) {
Close(true);
}

void AudioSplitter::OnSize(wxSizeEvent &evt) {
wxTopLevelWindowBase::OnSize(evt);
panel->SetSize(GetSize());
}


2 changes: 2 additions & 0 deletions src/AudioSplitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AudioSplitter : public wxFrame {

wxSpinCtrlDouble *bpm_ctrl;
wxSpinCtrlDouble *offset_ctrl;
wxPanel *panel;
public:
AudioSplitter(wxWindow *parent, const wxPoint &pos, const wxSize& size, Division* div);

Expand All @@ -21,6 +22,7 @@ class AudioSplitter : public wxFrame {
void OnBrowseInput(wxCommandEvent &evt);
void OnBrowseOutput(wxCommandEvent &evt);
void OnDropFiles(wxDropFilesEvent &evt);
void OnSize(wxSizeEvent &evt);
wxDECLARE_EVENT_TABLE();

void SetInputAudioFile(wxString input_file);
Expand Down
2 changes: 1 addition & 1 deletion src/divedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ bool DivisionEditor::DivRename() {
void DivisionEditor::OnOpenAudioSplitter(wxCommandEvent &event) {
if (!division) return;

auto splitter = new AudioSplitter(this, wxDefaultPosition, wxSize(800, 300), division);
auto splitter = new AudioSplitter(this, wxDefaultPosition, wxSize(-1, -1), division);
splitter->Show();
}

Expand Down
2 changes: 1 addition & 1 deletion src/divview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class DivisionSettingDialog : public wxDialog{
}
this->EndDialog(wxID_OK);
}
DECLARE_EVENT_TABLE()
wxDECLARE_EVENT_TABLE();
};


Expand Down
46 changes: 30 additions & 16 deletions src/midi_smfin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,11 @@ class LoadSmfDialog : public wxDialog {
ID_Channels_Check = 0x120
};

void _on_size() {
wxSize size = GetClientSize();
if (combo_trk) combo_trk->SetSize(95, 5, size.x - 100, 15);
if (button_ok) button_ok->SetSize(size.x - 125, size.y - 30, 120, 25);
}

public:
LoadSmfDialog(std::vector<MidiData_PreLoader> &_tracks)
: wxDialog(0, -1, _("MIDI file import settings"), wxDefaultPosition,
wxSize(290, 185), wxDEFAULT_DIALOG_STYLE & ~wxCLOSE_BOX | wxRESIZE_BORDER),
wxSize(290, 130), wxDEFAULT_DIALOG_STYLE & ~wxCLOSE_BOX),
tracks(_tracks), combo_trk(0), button_ok(0) {
size_t def = 0;
for (size_t i = 0; i < tracks.size(); i++) {
Expand All @@ -70,27 +65,46 @@ class LoadSmfDialog : public wxDialog {
track_choices[i] = wxString::Format(_("%04X: %s"), (int) i, tracks[i].track_name.c_str());
}

new wxStaticText(this, ID_Tracks_Text, _("Tracks (&T):"), wxPoint(5, 8), wxSize(85, 15));
combo_trk = new wxComboBox(this, ID_Tracks_Choice, track_choices[def], wxPoint(95, 5),
wxSize(200, 15), tracks.size(), track_choices.data(), wxCB_DROPDOWN | wxCB_READONLY);
auto this_sizer = new wxBoxSizer(wxVERTICAL);
auto dlg_sizer = new wxGridSizer(2, 2, 10, 10);

this_sizer->Add(dlg_sizer, wxSizerFlags().Border(wxALL, 10));

auto tracks_lbl = new wxStaticText(this, ID_Tracks_Text, _("Tracks (&T):"), wxPoint(5, 8), wxSize(85, 15));
dlg_sizer->Add(tracks_lbl);

combo_trk = new wxComboBox(this, ID_Tracks_Choice, track_choices[def],
wxDefaultPosition,
wxDefaultSize,
tracks.size(),
track_choices.data(),
wxCB_DROPDOWN | wxCB_READONLY);
combo_trk->SetSelection(def);
new wxStaticText(this, ID_Tracks_Text, _("Channels (&C):"), wxPoint(5, 38), wxSize(85, 15));
dlg_sizer->Add(combo_trk);

auto channels_lbl = new wxStaticText(this, ID_Tracks_Text, _("Channels (&C):"));
dlg_sizer->Add(channels_lbl);

auto chan_grid = new wxGridSizer(4, 4, 3, 3);
dlg_sizer->Add(chan_grid);

for (int i = 0; i < 16; i++) {
int ix = i % 4, iy = i / 4;
check_chs[i] = new wxCheckBox(this, ID_Channels_Check + i, wxString::Format(_("%02X"), i),
wxPoint(95 + ix * 40, 35 + iy * 20), wxSize(35, 15));
check_chs[i] = new wxCheckBox(this, ID_Channels_Check + i, wxString::Format("%02X", i));
check_chs[i]->SetValue(true);
chan_grid->Add(check_chs[i]);
}

button_ok = new wxButton(this, wxID_OK, _("OK"));
button_ok->SetDefault();
SetMinSize(wxSize(290, 185));
this_sizer->Add(button_ok, wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL, 10));

// SetMinSize(wxSize(290, 185));
SetSizerAndFit(this_sizer);
SetEscapeId(wxID_NONE);
_on_size();
}

~LoadSmfDialog() override = default;

void OnSize(wxSizeEvent &WXUNUSED(ev)) { _on_size(); }

DECLARE_EVENT_TABLE()
public:
Expand Down

0 comments on commit 4e50ea4

Please sign in to comment.