Theme-ified MIDI note colours, implemented automagic crossfading thereof.
[ardour.git] / gtk2_ardour / midi_util.h
1 /*
2     Copyright (C) 2007 Paul Davis 
3     Author: Dave Robillard
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __gtk_ardour_midi_util_h__
21 #define __gtk_ardour_midi_util_h__
22
23 #include "rgb_macros.h"
24 #include "ardour_ui.h"
25 #include "ui_config.h"
26
27 inline static uint32_t note_outline_color(uint8_t vel)
28 {
29         if (vel < 64) {
30                 return UINT_INTERPOLATE(
31                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMin.get(),
32                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
33                                 (vel / (double)63.0));
34         } else {
35                 return UINT_INTERPOLATE(
36                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
37                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMax.get(),
38                                 ((vel-64) / (double)63.0));
39         }
40 }
41
42 inline static uint32_t note_fill_color(uint8_t vel)
43 {
44         if (vel < 64) {
45                 return UINT_INTERPOLATE(
46                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMin.get(),
47                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
48                                 (vel / (double)63.0));
49         } else {
50                 return UINT_INTERPOLATE(
51                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMid.get(),
52                                 ARDOUR_UI::config()->canvasvar_MidiNoteOutlineMax.get(),
53                                 ((vel-64) / (double)63.0));
54         }
55 }
56
57 #endif /* __gtk_ardour_midi_util_h__ */
58