* preparation for different color coding schemes

git-svn-id: svn://localhost/ardour2/branches/3.0@4342 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-12-23 16:18:54 +00:00
parent c15f5d24fd
commit 270f1abe8d
6 changed files with 58 additions and 66 deletions

View File

@ -58,15 +58,8 @@
<Option name="meter marker" value="f2425bff"/>
<Option name="midi bus base" value="00000000"/>
<Option name="midi frame base" value="393d3766"/>
<Option name="midi note fill inactive channel" value="bfbfbf88"/>
<Option name="midi note fill max" value="ee33338a"/>
<Option name="midi note fill mid" value="eeee338a"/>
<Option name="midi note fill min" value="33ee338a"/>
<Option name="midi note outline inactive channel" value="bfbfbfff"/>
<Option name="midi note outline max" value="ff2222b0"/>
<Option name="midi note outline mid" value="ffff22b0"/>
<Option name="midi note outline min" value="22ff22b0"/>
<Option name="midi note selected outline" value="5566ffee"/>
<Option name="midi note inactive channel" value="bfbfbf88"/>
<Option name="midi note selected" value="000000ff"/>
<Option name="midi note velocity text" value="000000ff"/>
<Option name="midi program change fill" value="0000ffa0"/>
<Option name="midi program change outline" value="a7a7d4ff"/>

View File

@ -30,6 +30,13 @@ using ARDOUR::MidiModel;
namespace Gnome {
namespace Canvas {
/// dividing the hue circle in 16 parts, hand adjusted for equal look, courtesy Thorsten Wilms
const uint32_t CanvasNoteEvent::midi_channel_colors[16] = {
0xd32d2d00, 0xd36b2d00, 0xd3972d00, 0xd3d12d00,
0xa0d32d00, 0x7dd32d00, 0x2dd45e00, 0x2dd3c400,
0x2da5d300, 0x2d6fd300, 0x432dd300, 0x662dd300,
0x832dd300, 0xa92dd300, 0xd32dbf00, 0xd32d6700
};
CanvasNoteEvent::CanvasNoteEvent(MidiRegionView& region, Item* item,
const boost::shared_ptr<Evoral::Note> note)
@ -77,8 +84,7 @@ CanvasNoteEvent::show_velocity()
_text->property_justification() = Gtk::JUSTIFY_CENTER;
_text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiNoteVelocityText.get();
_text->show();
_text->lower_to_bottom();
_text->raise(2);
_text->raise_to_top();
}
void
@ -96,8 +102,8 @@ CanvasNoteEvent::on_channel_selection_change(uint16_t selection)
{
// make note change its color if its channel is not marked active
if ( (selection & (1 << _note->channel())) == 0 ) {
set_fill_color(ARDOUR_UI::config()->canvasvar_MidiNoteFillInactiveChannel.get());
set_outline_color(ARDOUR_UI::config()->canvasvar_MidiNoteOutlineInactiveChannel.get());
set_fill_color(ARDOUR_UI::config()->canvasvar_MidiNoteInactiveChannel.get());
set_outline_color(calculate_outline(ARDOUR_UI::config()->canvasvar_MidiNoteInactiveChannel.get()));
} else {
// set the color according to the notes selection state
selected(_selected);
@ -157,13 +163,13 @@ CanvasNoteEvent::selected(bool yn)
if (!_note) {
return;
} else if (yn) {
set_fill_color(UINT_INTERPOLATE(note_fill_color(_note->velocity()),
ARDOUR_UI::config()->canvasvar_MidiNoteSelectedOutline.get(), 0.1));
set_outline_color(ARDOUR_UI::config()->canvasvar_MidiNoteSelectedOutline.get());
set_fill_color(UINT_INTERPOLATE(meter_style_fill_color(_note->velocity()),
ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get(), 0.1));
set_outline_color(calculate_outline(ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get()));
show_velocity();
} else {
set_fill_color(note_fill_color(_note->velocity()));
set_outline_color(note_outline_color(_note->velocity()));
set_fill_color(meter_style_fill_color(_note->velocity()));
set_outline_color(meter_style_outline_color(_note->velocity()));
hide_velocity();
}

View File

@ -20,12 +20,17 @@
#ifndef __gtk_ardour_canvas_midi_event_h__
#define __gtk_ardour_canvas_midi_event_h__
#include "simplerect.h"
#include "midi_channel_selector.h"
#include <libgnomecanvasmm/text.h>
#include <libgnomecanvasmm/widget.h>
#include <ardour/midi_model.h>
#include "rgb_macros.h"
#include "ardour_ui.h"
#include "ui_config.h"
#include "simplerect.h"
#include "midi_channel_selector.h"
class Editor;
class MidiRegionView;
@ -82,6 +87,35 @@ public:
virtual double y2() = 0;
const boost::shared_ptr<Evoral::Note> note() const { return _note; }
inline static uint32_t meter_style_fill_color(uint8_t vel)
{
if (vel < 64) {
return UINT_INTERPOLATE(
ARDOUR_UI::config()->canvasvar_MeterColorBase.get(),
ARDOUR_UI::config()->canvasvar_MeterColorMid.get(),
(vel / (double)63.0));
} else {
return UINT_INTERPOLATE(
ARDOUR_UI::config()->canvasvar_MeterColorMid.get(),
ARDOUR_UI::config()->canvasvar_MeterColorTop.get(),
((vel-64) / (double)63.0));
}
}
inline static uint32_t meter_style_outline_color(uint8_t vel)
{
return calculate_outline(meter_style_fill_color(vel));
}
/// calculate outline colors from fill colors of notes
inline static uint32_t calculate_outline(uint32_t color)
{
return UINT_INTERPOLATE(color, 0x000000ff, 0.5);
}
/// dividing the hue circle in 16 parts, hand adjusted for equal look, courtesy Thorsten Wilms
static const uint32_t midi_channel_colors[16];
protected:
enum State { None, Pressed, Dragging };

View File

@ -56,15 +56,8 @@ CANVAS_VARIABLE(canvasvar_MeterColorTop, "meter fill max")
CANVAS_VARIABLE(canvasvar_MeterMarker, "meter marker")
CANVAS_VARIABLE(canvasvar_MidiBusBase, "midi bus base")
CANVAS_VARIABLE(canvasvar_MidiFrameBase, "midi frame base")
CANVAS_VARIABLE(canvasvar_MidiNoteFillMax, "midi note fill max")
CANVAS_VARIABLE(canvasvar_MidiNoteFillMid, "midi note fill mid")
CANVAS_VARIABLE(canvasvar_MidiNoteFillMin, "midi note fill min")
CANVAS_VARIABLE(canvasvar_MidiNoteFillInactiveChannel, "midi note fill inactive channel")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMax, "midi note outline max")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMid, "midi note outline mid")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMin, "midi note outline min")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineInactiveChannel, "midi note outline inactive channel")
CANVAS_VARIABLE(canvasvar_MidiNoteSelectedOutline, "midi note selected outline")
CANVAS_VARIABLE(canvasvar_MidiNoteInactiveChannel, "midi note inactive channel")
CANVAS_VARIABLE(canvasvar_MidiNoteSelected, "midi note selected")
CANVAS_VARIABLE(canvasvar_MidiNoteVelocityText, "midi note velocity text")
CANVAS_VARIABLE(canvasvar_MidiProgramChangeFill, "midi program change fill")
CANVAS_VARIABLE(canvasvar_MidiProgramChangeOutline, "midi program change outline")

View File

@ -1417,7 +1417,7 @@ MidiRegionView::begin_resizing(CanvasNote::NoteEnd note_end)
// calculate the colors: get the color settings
uint32_t fill_color =
UINT_RGBA_CHANGE_A(
ARDOUR_UI::config()->canvasvar_MidiNoteSelectedOutline.get(),
ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get(),
128);
// make the resize preview notes more transparent and bright
@ -1426,12 +1426,12 @@ MidiRegionView::begin_resizing(CanvasNote::NoteEnd note_end)
// calculate color based on note velocity
resize_rect->property_fill_color_rgba() =
UINT_INTERPOLATE(
note_fill_color(note->note()->velocity()),
CanvasNoteEvent::meter_style_fill_color(note->note()->velocity()),
fill_color,
0.85);
resize_rect->property_outline_color_rgba() =
ARDOUR_UI::config()->canvasvar_MidiNoteSelectedOutline.get();
CanvasNoteEvent::calculate_outline(ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get());
resize_data->resize_rect = resize_rect;

View File

@ -20,40 +20,6 @@
#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_MidiNoteFillMin.get(),
ARDOUR_UI::config()->canvasvar_MidiNoteFillMid.get(),
(vel / (double)63.0));
} else {
return UINT_INTERPOLATE(
ARDOUR_UI::config()->canvasvar_MidiNoteFillMid.get(),
ARDOUR_UI::config()->canvasvar_MidiNoteFillMax.get(),
((vel-64) / (double)63.0));
}
}
inline static void clamp_0_to_127(uint8_t &val)
{
if( (127 < val) && (val < 192) ) {