implement tabbed tracklist/sample list
This commit is contained in:
parent
5a745b30f0
commit
96adadac52
@ -184,7 +184,10 @@ namespace scene::tracker {
|
||||
|
||||
float y = 8 + ((glyph::vert_advance + 5) * 2) + 8;
|
||||
top.freeze(5, y);
|
||||
|
||||
playlist::next();
|
||||
|
||||
tracklist::init(top.width + 5, 5);
|
||||
}
|
||||
|
||||
void update_pick(cursor::cursor& c)
|
||||
@ -192,6 +195,8 @@ namespace scene::tracker {
|
||||
widget::widget * w = top.pick(c.x, c.y);
|
||||
if (w != nullptr) {
|
||||
w->click();
|
||||
} else {
|
||||
tracklist::update_pick(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,43 @@
|
||||
#include "tracklist.hpp"
|
||||
#include "ta_parameter.hpp"
|
||||
#include "playlist.hpp"
|
||||
#include "interpreter.hpp"
|
||||
|
||||
#include "widget/button_label.hpp"
|
||||
#include "widget/left_aligned.hpp"
|
||||
|
||||
namespace scene::tracker::tracklist {
|
||||
|
||||
static bool samples_tab = false;
|
||||
|
||||
void playlist_click()
|
||||
{
|
||||
samples_tab = false;
|
||||
}
|
||||
|
||||
void samples_click()
|
||||
{
|
||||
samples_tab = true;
|
||||
}
|
||||
|
||||
const float width = glyph::hori_advance * 20 + 3 * 2;
|
||||
const int line_rows_half = 5;
|
||||
const int line_rows = line_rows_half * 2 + 1;
|
||||
const float height = glyph::vert_advance * line_rows + 3 * 2;
|
||||
|
||||
#define __length(c) ((sizeof (c)) / (sizeof (c[0])))
|
||||
|
||||
widget::button_label playlist_button(width / 2 - 1, 20, "playlist", playlist_click);
|
||||
widget::button_label instruments_button(width / 2 - 1, 20, "samples", samples_click);
|
||||
|
||||
widget::widget * playlist_instruments_children[] = {
|
||||
&playlist_button,
|
||||
&instruments_button,
|
||||
};
|
||||
int playlist_instruments_length = __length(playlist_instruments_children);
|
||||
|
||||
widget::left_aligned playlist_instruments(0, 0, 1, playlist_instruments_children, playlist_instruments_length);
|
||||
|
||||
void draw_borders(ta_parameter_writer& writer, float x, float y)
|
||||
{
|
||||
transfer_horizontal_border(writer, x, y, width);
|
||||
@ -34,6 +63,20 @@ namespace scene::tracker::tracklist {
|
||||
}
|
||||
}
|
||||
|
||||
void draw_sample_names(ta_parameter_writer& writer, float x, float y)
|
||||
{
|
||||
int count = interpreter::state.xm.header->number_of_instruments;
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (i >= line_rows)
|
||||
break;
|
||||
|
||||
transfer_string(writer, (const char *)interpreter::state.xm.instrument_header[i]->instrument_name,
|
||||
x, y, 1.0 / 10.0,
|
||||
0xffffff);
|
||||
y += glyph::vert_advance;
|
||||
}
|
||||
}
|
||||
|
||||
void draw_middle_line(ta_parameter_writer& writer, float x, float y)
|
||||
{
|
||||
int middle_width = width;
|
||||
@ -90,21 +133,78 @@ namespace scene::tracker::tracklist {
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
void draw_tab_connector(ta_parameter_writer& writer, float x, float y)
|
||||
{
|
||||
const static float background_depth = 1.0 / 9.5;
|
||||
const static int background_color = 0x282c2c;
|
||||
|
||||
const static float shadow_depth = 1.0 / 10.0;
|
||||
const static int shadow_color = 0x0000000;
|
||||
|
||||
float x0;
|
||||
|
||||
if (samples_tab) {
|
||||
x0 = x + width / 2 + 2;
|
||||
} else {
|
||||
x0 = x + 2;
|
||||
}
|
||||
|
||||
float y0 = y;
|
||||
float x1 = x0 + width / 2 - 5;
|
||||
float y1 = y0 + 5;
|
||||
|
||||
quad_type_0(writer,
|
||||
{x0, y0, background_depth},
|
||||
{x1, y0, background_depth},
|
||||
{x1, y1, background_depth},
|
||||
{x0, y1, background_depth},
|
||||
background_color);
|
||||
|
||||
quad_type_0(writer,
|
||||
{x0 - 1, y0, shadow_depth},
|
||||
{x1 + 1, y0, shadow_depth},
|
||||
{x1 + 1, y1, shadow_depth},
|
||||
{x0 - 1, y1, shadow_depth},
|
||||
shadow_color);
|
||||
}
|
||||
|
||||
void init(float x, float y)
|
||||
{
|
||||
playlist_instruments.freeze(x, y);
|
||||
}
|
||||
|
||||
void update_pick(cursor::cursor& c)
|
||||
{
|
||||
widget::widget * w = playlist_instruments.pick(c.x, c.y);
|
||||
if (w != nullptr) {
|
||||
w->click();
|
||||
}
|
||||
}
|
||||
|
||||
void draw(ta_multiwriter& multi, float x, float y)
|
||||
{
|
||||
transfer_global_polygon_glyph(multi.pt);
|
||||
|
||||
draw_heading(multi.pt, x, y);
|
||||
playlist_instruments.draw(multi);
|
||||
//draw_heading(multi.pt, x, y);
|
||||
|
||||
draw_middle_line(multi.op, x, y + 3);
|
||||
y = y + playlist_instruments.height - 10;
|
||||
|
||||
global_polygon_untextured(multi.op,
|
||||
para_control::list_type::translucent,
|
||||
tsp_instruction_word::dst_alpha_instr::zero);
|
||||
|
||||
draw_tab_connector(multi.op, x, y + 10 - 2);
|
||||
|
||||
|
||||
float yi = y + glyph::vert_advance + 3;
|
||||
draw_borders(multi.op, x, yi);
|
||||
|
||||
draw_track_names(multi.pt, x + 3, yi + 3);
|
||||
if (samples_tab) {
|
||||
draw_sample_names(multi.pt, x + 3, yi + 3);
|
||||
} else {
|
||||
draw_track_names(multi.pt, x + 3, yi + 3);
|
||||
draw_middle_line(multi.op, x, y + 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "ta_multiwriter.hpp"
|
||||
#include "cursor.hpp"
|
||||
|
||||
namespace scene::tracker::tracklist {
|
||||
void init(float x, float y);
|
||||
void update_pick(cursor::cursor& c);
|
||||
void draw(ta_multiwriter& multi, float x, float y);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user