mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Theme-ified MIDI note colours, implemented automagic crossfading thereof.
git-svn-id: svn://localhost/ardour2/trunk@2243 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
7185f8e53f
commit
c1b73d4a41
6 changed files with 99 additions and 24 deletions
|
|
@ -83,6 +83,15 @@
|
||||||
<Option name="TrimHandle" value="1900ff44"/>
|
<Option name="TrimHandle" value="1900ff44"/>
|
||||||
<Option name="EditCursor" value="0000ffff"/>
|
<Option name="EditCursor" value="0000ffff"/>
|
||||||
<Option name="PlayHead" value="ff0000ff"/>
|
<Option name="PlayHead" value="ff0000ff"/>
|
||||||
|
<Option name="MidiSelectRectOutline" value="ff000099"/>
|
||||||
|
<Option name="MidiSelectRectFill" value="ffdddd33"/>
|
||||||
|
<Option name="MidiNoteOutlineMin" value="44ff4466"/>
|
||||||
|
<Option name="MidiNoteOutlineMid" value="ffff4466"/>
|
||||||
|
<Option name="MidiNoteOutlineMax" value="ff4444ee"/>
|
||||||
|
<Option name="MidiNoteFillMin" value="44ee4433"/>
|
||||||
|
<Option name="MidiNoteFillMid" value="eeee4444"/>
|
||||||
|
<Option name="MidiNoteFillMax" value="dd999955"/>
|
||||||
|
<Option name="MidiNoteSelectedOutline" value="ff000099"/>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</Ardour>
|
</Ardour>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
const ARDOUR::MidiModel::Note* note() { return _note; }
|
const ARDOUR::MidiModel::Note* note() { return _note; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
enum State { None, Pressed, Dragging };
|
enum State { None, Pressed, Dragging };
|
||||||
|
|
||||||
MidiRegionView& _region;
|
MidiRegionView& _region;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "simplerect.h"
|
#include "simplerect.h"
|
||||||
#include "canvas-midi-event.h"
|
#include "canvas-midi-event.h"
|
||||||
|
#include "midi_util.h"
|
||||||
|
|
||||||
namespace Gnome {
|
namespace Gnome {
|
||||||
namespace Canvas {
|
namespace Canvas {
|
||||||
|
|
@ -35,9 +36,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void selected(bool yn) {
|
virtual void selected(bool yn) {
|
||||||
// Temporary hack, no reversal for now
|
if (!_note)
|
||||||
if (yn)
|
return;
|
||||||
property_outline_color_rgba() = 0xFF000099;
|
else if (yn)
|
||||||
|
property_outline_color_rgba()
|
||||||
|
= ARDOUR_UI::config()->canvasvar_MidiNoteSelectedOutline.get();
|
||||||
|
else
|
||||||
|
property_outline_color_rgba() = note_outline_color(_note->velocity());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool on_event(GdkEvent* ev) { return CanvasMidiEvent::on_event(ev); }
|
bool on_event(GdkEvent* ev) { return CanvasMidiEvent::on_event(ev); }
|
||||||
|
|
|
||||||
|
|
@ -80,3 +80,12 @@ CANVAS_VARIABLE(canvasvar_TrimHandleLocked, "TrimHandleLocked")
|
||||||
CANVAS_VARIABLE(canvasvar_TrimHandle, "TrimHandle")
|
CANVAS_VARIABLE(canvasvar_TrimHandle, "TrimHandle")
|
||||||
CANVAS_VARIABLE(canvasvar_EditCursor, "EditCursor")
|
CANVAS_VARIABLE(canvasvar_EditCursor, "EditCursor")
|
||||||
CANVAS_VARIABLE(canvasvar_PlayHead, "PlayHead")
|
CANVAS_VARIABLE(canvasvar_PlayHead, "PlayHead")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiSelectRectOutline, "MidiSelectRectOutline")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiSelectRectFill, "MidiSelectRectFill")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMin, "MidiNoteOutlineMin")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMid, "MidiNoteOutlineMid")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMax, "MidiNoteOutlineMax")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiNoteFillMin, "MidiNoteFillMin")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiNoteFillMid, "MidiNoteFillMid")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiNoteFillMax, "MidiNoteFillMax")
|
||||||
|
CANVAS_VARIABLE(canvasvar_MidiNoteSelectedOutline, "MidiNoteSelectedOutline")
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
#include "ghostregion.h"
|
#include "ghostregion.h"
|
||||||
#include "midi_time_axis.h"
|
#include "midi_time_axis.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "rgb_macros.h"
|
#include "midi_util.h"
|
||||||
#include "gui_thread.h"
|
#include "gui_thread.h"
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
@ -176,8 +176,10 @@ MidiRegionView::canvas_event(GdkEvent* ev)
|
||||||
drag_rect->property_x2() = event_x;
|
drag_rect->property_x2() = event_x;
|
||||||
drag_rect->property_y2() = event_y;
|
drag_rect->property_y2() = event_y;
|
||||||
drag_rect->property_outline_what() = 0xFF;
|
drag_rect->property_outline_what() = 0xFF;
|
||||||
drag_rect->property_outline_color_rgba() = 0xFF000099;
|
drag_rect->property_outline_color_rgba()
|
||||||
drag_rect->property_fill_color_rgba() = 0xFFDDDD33;
|
= ARDOUR_UI::config()->canvasvar_MidiSelectRectOutline.get();
|
||||||
|
drag_rect->property_fill_color_rgba()
|
||||||
|
= ARDOUR_UI::config()->canvasvar_MidiSelectRectFill.get();
|
||||||
|
|
||||||
_state = SelectDragging;
|
_state = SelectDragging;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -483,10 +485,10 @@ MidiRegionView::add_event (const MidiEvent& ev)
|
||||||
ev_rect->property_x2() = trackview.editor.frame_to_pixel (
|
ev_rect->property_x2() = trackview.editor.frame_to_pixel (
|
||||||
_region->length());
|
_region->length());
|
||||||
ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height());
|
ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height());
|
||||||
ev_rect->property_outline_color_rgba() = 0xFFFFFFAA;
|
ev_rect->property_fill_color_rgba() = note_fill_color(ev.velocity());
|
||||||
|
ev_rect->property_outline_color_rgba() = note_outline_color(ev.velocity());
|
||||||
/* outline all but right edge */
|
/* outline all but right edge */
|
||||||
ev_rect->property_outline_what() = (guint32) (0x1 & 0x4 & 0x8);
|
ev_rect->property_outline_what() = (guint32) (0x1 & 0x4 & 0x8);
|
||||||
ev_rect->property_fill_color_rgba() = 0xFFFFFF66;
|
|
||||||
|
|
||||||
ev_rect->raise_to_top();
|
ev_rect->raise_to_top();
|
||||||
|
|
||||||
|
|
@ -512,9 +514,9 @@ MidiRegionView::add_event (const MidiEvent& ev)
|
||||||
CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size);
|
CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size);
|
||||||
ev_diamond->move(x, y);
|
ev_diamond->move(x, y);
|
||||||
ev_diamond->show();
|
ev_diamond->show();
|
||||||
ev_diamond->property_outline_color_rgba() = 0xFFFFFFDD;
|
ev_diamond->property_fill_color_rgba() = note_fill_color(ev.velocity());
|
||||||
ev_diamond->property_fill_color_rgba() = 0xFFFFFF66;
|
ev_diamond->property_outline_color_rgba() = note_outline_color(ev.velocity());
|
||||||
|
|
||||||
_events.push_back(ev_diamond);
|
_events.push_back(ev_diamond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -544,17 +546,9 @@ MidiRegionView::add_note (const MidiModel::Note& note)
|
||||||
{
|
{
|
||||||
assert(note.time() >= 0);
|
assert(note.time() >= 0);
|
||||||
assert(note.time() < _region->length());
|
assert(note.time() < _region->length());
|
||||||
//assert(note.time() + note.duration < _region->length());
|
|
||||||
|
|
||||||
ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
|
ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
|
||||||
|
|
||||||
const uint8_t fill_alpha = 0x20 + (uint8_t)(note.velocity() * 1.5);
|
|
||||||
const uint32_t fill = RGBA_TO_UINT(0xE0 + note.velocity()/127.0 * 0x10, 0xE0, 0xE0, fill_alpha);
|
|
||||||
const uint8_t outline_alpha = 0x80 + (uint8_t)(note.velocity());
|
|
||||||
const uint32_t outline = RGBA_TO_UINT(0xE0 + note.velocity()/127.0 * 0x10, 0xE0, 0xE0, outline_alpha);
|
|
||||||
|
|
||||||
//printf("Event, time = %f, note = %d\n", note.time(), note.note());
|
|
||||||
|
|
||||||
if (midi_view()->note_mode() == Sustained) {
|
if (midi_view()->note_mode() == Sustained) {
|
||||||
const double y1 = midi_stream_view()->note_to_y(note.note());
|
const double y1 = midi_stream_view()->note_to_y(note.note());
|
||||||
|
|
||||||
|
|
@ -564,8 +558,8 @@ MidiRegionView::add_note (const MidiModel::Note& note)
|
||||||
ev_rect->property_x2() = trackview.editor.frame_to_pixel((nframes_t)(note.end_time()));
|
ev_rect->property_x2() = trackview.editor.frame_to_pixel((nframes_t)(note.end_time()));
|
||||||
ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height());
|
ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height());
|
||||||
|
|
||||||
ev_rect->property_fill_color_rgba() = fill;
|
ev_rect->property_fill_color_rgba() = note_fill_color(note.velocity());
|
||||||
ev_rect->property_outline_color_rgba() = outline;
|
ev_rect->property_outline_color_rgba() = note_outline_color(note.velocity());
|
||||||
ev_rect->property_outline_what() = (guint32) 0xF; // all edges
|
ev_rect->property_outline_what() = (guint32) 0xF; // all edges
|
||||||
|
|
||||||
ev_rect->show();
|
ev_rect->show();
|
||||||
|
|
@ -579,8 +573,8 @@ MidiRegionView::add_note (const MidiModel::Note& note)
|
||||||
CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size);
|
CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size);
|
||||||
ev_diamond->move(x, y);
|
ev_diamond->move(x, y);
|
||||||
ev_diamond->show();
|
ev_diamond->show();
|
||||||
ev_diamond->property_fill_color_rgba() = fill;
|
ev_diamond->property_fill_color_rgba() = note_fill_color(note.velocity());
|
||||||
ev_diamond->property_outline_color_rgba() = outline;
|
ev_diamond->property_outline_color_rgba() = note_outline_color(note.velocity());
|
||||||
_events.push_back(ev_diamond);
|
_events.push_back(ev_diamond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
58
gtk2_ardour/midi_util.h
Normal file
58
gtk2_ardour/midi_util.h
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2007 Paul Davis
|
||||||
|
Author: Dave Robillard
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __gtk_ardour_midi_util_h__
|
||||||
|
#define __gtk_ardour_midi_util_h__
|
||||||
|
|
||||||
|
#include "rgb_macros.h"
|
||||||
|
#include "ardour_ui.h"
|
||||||
|
#include "ui_config.h"
|
||||||
|
|
||||||
|
inline static uint32_t note_outline_color(uint8_t vel)
|
||||||
|
{
|
||||||
|
if (vel < 64) {
|
||||||
|
return UINT_INTERPOLATE(
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMin.get(),
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
|
||||||
|
(vel / (double)63.0));
|
||||||
|
} else {
|
||||||
|
return UINT_INTERPOLATE(
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMax.get(),
|
||||||
|
((vel-64) / (double)63.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static uint32_t note_fill_color(uint8_t vel)
|
||||||
|
{
|
||||||
|
if (vel < 64) {
|
||||||
|
return UINT_INTERPOLATE(
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMin.get(),
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
|
||||||
|
(vel / (double)63.0));
|
||||||
|
} else {
|
||||||
|
return UINT_INTERPOLATE(
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
|
||||||
|
ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMax.get(),
|
||||||
|
((vel-64) / (double)63.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __gtk_ardour_midi_util_h__ */
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue