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:
David Robillard 2007-08-04 18:43:32 +00:00
parent 7185f8e53f
commit c1b73d4a41
6 changed files with 99 additions and 24 deletions

View File

@ -83,6 +83,15 @@
<Option name="TrimHandle" value="1900ff44"/>
<Option name="EditCursor" value="0000ffff"/>
<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>
</Ardour>

View File

@ -50,7 +50,7 @@ public:
const ARDOUR::MidiModel::Note* note() { return _note; }
private:
protected:
enum State { None, Pressed, Dragging };
MidiRegionView& _region;

View File

@ -23,6 +23,7 @@
#include <iostream>
#include "simplerect.h"
#include "canvas-midi-event.h"
#include "midi_util.h"
namespace Gnome {
namespace Canvas {
@ -35,9 +36,13 @@ public:
}
virtual void selected(bool yn) {
// Temporary hack, no reversal for now
if (yn)
property_outline_color_rgba() = 0xFF000099;
if (!_note)
return;
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); }

View File

@ -80,3 +80,12 @@ CANVAS_VARIABLE(canvasvar_TrimHandleLocked, "TrimHandleLocked")
CANVAS_VARIABLE(canvasvar_TrimHandle, "TrimHandle")
CANVAS_VARIABLE(canvasvar_EditCursor, "EditCursor")
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")

View File

@ -46,7 +46,7 @@
#include "ghostregion.h"
#include "midi_time_axis.h"
#include "utils.h"
#include "rgb_macros.h"
#include "midi_util.h"
#include "gui_thread.h"
#include "i18n.h"
@ -176,8 +176,10 @@ MidiRegionView::canvas_event(GdkEvent* ev)
drag_rect->property_x2() = event_x;
drag_rect->property_y2() = event_y;
drag_rect->property_outline_what() = 0xFF;
drag_rect->property_outline_color_rgba() = 0xFF000099;
drag_rect->property_fill_color_rgba() = 0xFFDDDD33;
drag_rect->property_outline_color_rgba()
= ARDOUR_UI::config()->canvasvar_MidiSelectRectOutline.get();
drag_rect->property_fill_color_rgba()
= ARDOUR_UI::config()->canvasvar_MidiSelectRectFill.get();
_state = SelectDragging;
return true;
@ -483,10 +485,10 @@ MidiRegionView::add_event (const MidiEvent& ev)
ev_rect->property_x2() = trackview.editor.frame_to_pixel (
_region->length());
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 */
ev_rect->property_outline_what() = (guint32) (0x1 & 0x4 & 0x8);
ev_rect->property_fill_color_rgba() = 0xFFFFFF66;
ev_rect->raise_to_top();
@ -512,9 +514,9 @@ MidiRegionView::add_event (const MidiEvent& ev)
CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size);
ev_diamond->move(x, y);
ev_diamond->show();
ev_diamond->property_outline_color_rgba() = 0xFFFFFFDD;
ev_diamond->property_fill_color_rgba() = 0xFFFFFF66;
ev_diamond->property_fill_color_rgba() = note_fill_color(ev.velocity());
ev_diamond->property_outline_color_rgba() = note_outline_color(ev.velocity());
_events.push_back(ev_diamond);
}
}
@ -544,17 +546,9 @@ MidiRegionView::add_note (const MidiModel::Note& note)
{
assert(note.time() >= 0);
assert(note.time() < _region->length());
//assert(note.time() + note.duration < _region->length());
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) {
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_y2() = y1 + floor(midi_stream_view()->note_height());
ev_rect->property_fill_color_rgba() = fill;
ev_rect->property_outline_color_rgba() = outline;
ev_rect->property_fill_color_rgba() = note_fill_color(note.velocity());
ev_rect->property_outline_color_rgba() = note_outline_color(note.velocity());
ev_rect->property_outline_what() = (guint32) 0xF; // all edges
ev_rect->show();
@ -579,8 +573,8 @@ MidiRegionView::add_note (const MidiModel::Note& note)
CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size);
ev_diamond->move(x, y);
ev_diamond->show();
ev_diamond->property_fill_color_rgba() = fill;
ev_diamond->property_outline_color_rgba() = outline;
ev_diamond->property_fill_color_rgba() = note_fill_color(note.velocity());
ev_diamond->property_outline_color_rgba() = note_outline_color(note.velocity());
_events.push_back(ev_diamond);
}
}

58
gtk2_ardour/midi_util.h Normal file
View 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__ */