13
0

Dynamically generated meter gradients

git-svn-id: svn://localhost/ardour2/trunk@570 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sampo Savolainen 2006-06-07 21:21:21 +00:00
parent d6cf62e911
commit 9d01165d3d
5 changed files with 293 additions and 779 deletions

View File

@ -209,22 +209,6 @@ ARDOUR_UI::set_engine (AudioEngine& e)
keyboard = new Keyboard;
string meter_path;
meter_path = ARDOUR::find_data_file("v_meter_strip.xpm", "pixmaps");
if (meter_path.empty()) {
error << _("no vertical meter strip image found") << endmsg;
exit (1);
}
FastMeter::set_vertical_xpm (meter_path);
meter_path = ARDOUR::find_data_file("h_meter_strip.xpm", "pixmaps");
if (meter_path.empty()) {
error << _("no horizontal meter strip image found") << endmsg;
exit (1);
}
FastMeter::set_horizontal_xpm (meter_path);
if (setup_windows ()) {
throw failed_constructor ();
}

View File

@ -1,195 +0,0 @@
/* XPM */
static const gchar *h_meter_strip_xpm[] = {
"186 5 187 2",
" c None",
". c #2BFE00",
"+ c #2DFE00",
"@ c #2FFE01",
"# c #32FE01",
"$ c #34FE02",
"% c #36FE02",
"& c #38FE03",
"* c #3BFE03",
"= c #3DFD04",
"- c #3FFD04",
"; c #41FD05",
"> c #44FD05",
", c #46FD06",
"' c #48FD06",
") c #4AFD07",
"! c #4DFD07",
"~ c #4FFD08",
"{ c #51FC08",
"] c #53FC09",
"^ c #56FC09",
"/ c #58FC09",
"( c #5AFC0A",
"_ c #5CFC0A",
": c #5FFC0B",
"< c #61FC0B",
"[ c #63FB0C",
"} c #65FB0C",
"| c #68FB0D",
"1 c #6AFB0D",
"2 c #6CFB0E",
"3 c #6EFB0E",
"4 c #71FB0F",
"5 c #73FB0F",
"6 c #75FB10",
"7 c #77FA10",
"8 c #7AFA11",
"9 c #7CFA11",
"0 c #7EFA12",
"a c #80FA12",
"b c #83FA12",
"c c #85FA13",
"d c #87FA13",
"e c #89FA14",
"f c #8CF914",
"g c #8EF915",
"h c #90F915",
"i c #92F916",
"j c #95F916",
"k c #97F917",
"l c #99F917",
"m c #9BF918",
"n c #9EF818",
"o c #A0F819",
"p c #A2F819",
"q c #A4F81A",
"r c #A7F81A",
"s c #A9F81A",
"t c #ABF81B",
"u c #ADF81B",
"v c #B0F81C",
"w c #B2F71C",
"x c #B4F71D",
"y c #B6F71D",
"z c #B9F71E",
"A c #BBF71E",
"B c #BDF71F",
"C c #BFF71F",
"D c #C2F720",
"E c #C4F720",
"F c #C6F621",
"G c #C8F621",
"H c #CBF622",
"I c #CDF622",
"J c #CFF623",
"K c #D1F623",
"L c #D4F624",
"M c #D6F624",
"N c #D8F524",
"O c #DAF525",
"P c #DDF525",
"Q c #DFF526",
"R c #E1F526",
"S c #E3F527",
"T c #E6F527",
"U c #E8F528",
"V c #EAF528",
"W c #ECF429",
"X c #EFF429",
"Y c #F1F42A",
"Z c #F3F42A",
"` c #F5F42B",
" . c #F8F42B",
".. c #FAF42C",
"+. c #FCF42C",
"@. c #FFF42D",
"#. c #FFF22C",
"$. c #FFF12B",
"%. c #FFF02A",
"&. c #FFEF2A",
"*. c #FFEE29",
"=. c #FFED28",
"-. c #FFEC28",
";. c #FFEB27",
">. c #FFE926",
",. c #FFE826",
"'. c #FFE725",
"). c #FFE624",
"!. c #FFE524",
"~. c #FFE423",
"{. c #FFE322",
"]. c #FFE222",
"^. c #FFE021",
"/. c #FFDF20",
"(. c #FFDE20",
"_. c #FFDD1F",
":. c #FFDC1E",
"<. c #FFDB1E",
"[. c #FFDA1D",
"}. c #FFD91C",
"|. c #FFD71B",
"1. c #FFD61B",
"2. c #FFD51A",
"3. c #FFD419",
"4. c #FFD319",
"5. c #FFD218",
"6. c #FFD117",
"7. c #FFD017",
"8. c #FFCF16",
"9. c #FFCD15",
"0. c #FFCC15",
"a. c #FFCB14",
"b. c #FFCA13",
"c. c #FFC913",
"d. c #FFC812",
"e. c #FFC711",
"f. c #FFC611",
"g. c #FFC410",
"h. c #FFC30F",
"i. c #FFC20F",
"j. c #FFC10E",
"k. c #FFC00D",
"l. c #FFBF0C",
"m. c #FFBE0C",
"n. c #FFBD0B",
"o. c #FFBB0A",
"p. c #FFBA0A",
"q. c #FFB909",
"r. c #FFB808",
"s. c #FFB708",
"t. c #FFB607",
"u. c #FFB506",
"v. c #FFB406",
"w. c #FFB205",
"x. c #FFB104",
"y. c #FFB004",
"z. c #FFAF03",
"A. c #FFAE02",
"B. c #FFAD02",
"C. c #FFAC01",
"D. c #FFAB00",
"E. c #FFA900",
"F. c #F11F00",
"G. c #F21E00",
"H. c #F21C00",
"I. c #F31B00",
"J. c #F31A00",
"K. c #F41800",
"L. c #F41700",
"M. c #F51600",
"N. c #F61400",
"O. c #F61300",
"P. c #F71100",
"Q. c #F71000",
"R. c #F80F00",
"S. c #F90D00",
"T. c #F90C00",
"U. c #FA0B00",
"V. c #FA0900",
"W. c #FB0800",
"X. c #FC0600",
"Y. c #FC0500",
"Z. c #FD0400",
"`. c #FD0200",
" + c #FE0100",
".+ c #FE0000",
"++ c #FF0000",
". + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ` ...+.@.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +.+",
". + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ` ...+.@.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +.+",
". + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ` ...+.@.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +++",
". + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ` ...+.@.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +++",
". + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ` ...+.@.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +++"};

View File

@ -1,483 +0,0 @@
/* XPM */
static const gchar * v_meter_strip_xpm[] = {
"5 250 230 2",
" c None",
". c #FE0000",
"+ c #FF0000",
"@ c #FE0100",
"# c #FD0200",
"$ c #FD0300",
"% c #FD0400",
"& c #FC0500",
"* c #FC0600",
"= c #FC0700",
"- c #FB0800",
"; c #FA0900",
"> c #FA0A00",
", c #FA0B00",
"' c #F90C00",
") c #F90D00",
"! c #F80E00",
"~ c #F80F00",
"{ c #F71000",
"] c #F71100",
"^ c #F61200",
"/ c #F61300",
"( c #F61400",
"_ c #F51600",
": c #F41700",
"< c #F41800",
"[ c #F31A00",
"} c #F31B00",
"| c #F21C00",
"1 c #F21E00",
"2 c #F11F00",
"3 c #F54A00",
"4 c #FFA900",
"5 c #FFAB00",
"6 c #FFAC01",
"7 c #FFAD02",
"8 c #FFAE02",
"9 c #FFAF03",
"0 c #FFB004",
"a c #FFB104",
"b c #FFB205",
"c c #FFB406",
"d c #FFB506",
"e c #FFB607",
"f c #FFB708",
"g c #FFB808",
"h c #FFB909",
"i c #FFBA0A",
"j c #FFBB0A",
"k c #FFBC0A",
"l c #FFBD0B",
"m c #FFBE0C",
"n c #FFBF0C",
"o c #FFC00D",
"p c #FFC10E",
"q c #FFC20F",
"r c #FFC30F",
"s c #FFC410",
"t c #FFC511",
"u c #FFC611",
"v c #FFC711",
"w c #FFC812",
"x c #FFC913",
"y c #FFCA13",
"z c #FFCB14",
"A c #FFCC15",
"B c #FFCD15",
"C c #FFCF16",
"D c #FFD017",
"E c #FFD117",
"F c #FFD218",
"G c #FFD319",
"H c #FFD419",
"I c #FFD51A",
"J c #FFD61B",
"K c #FFD71B",
"L c #FFD81C",
"M c #FFD91C",
"N c #FFDA1D",
"O c #FFDB1E",
"P c #FFDC1E",
"Q c #FFDD1F",
"R c #FFDE20",
"S c #FFDF20",
"T c #FFE021",
"U c #FFE222",
"V c #FFE322",
"W c #FFE423",
"X c #FFE524",
"Y c #FFE624",
"Z c #FFE725",
"` c #FFE826",
" . c #FFE926",
".. c #FFEA26",
"+. c #FFEB27",
"@. c #FFEC28",
"#. c #FFED28",
"$. c #FFEE29",
"%. c #FFEF2A",
"&. c #FFF02A",
"*. c #FFF12B",
"=. c #FFF22C",
"-. c #FFF32D",
";. c #FFF42D",
">. c #FDF42C",
",. c #FBF42C",
"'. c #FAF42C",
"). c #F8F42B",
"!. c #F6F42B",
"~. c #F4F42B",
"{. c #F3F42A",
"]. c #F1F42A",
"^. c #F0F429",
"/. c #EEF429",
"(. c #ECF429",
"_. c #EAF528",
":. c #E9F528",
"<. c #E7F528",
"[. c #E5F527",
"}. c #E3F527",
"|. c #E2F526",
"1. c #E0F526",
"2. c #DFF526",
"3. c #DDF525",
"4. c #DBF525",
"5. c #D9F525",
"6. c #D8F524",
"7. c #D6F624",
"8. c #D5F624",
"9. c #D3F624",
"0. c #D1F623",
"a. c #CFF623",
"b. c #CEF622",
"c. c #CCF622",
"d. c #CBF622",
"e. c #C9F621",
"f. c #C7F621",
"g. c #C5F621",
"h. c #C4F720",
"i. c #C2F720",
"j. c #C0F71F",
"k. c #BEF71F",
"l. c #BDF71F",
"m. c #BBF71E",
"n. c #BAF71E",
"o. c #B8F71E",
"p. c #B6F71D",
"q. c #B5F71D",
"r. c #B3F71D",
"s. c #B2F71C",
"t. c #B0F81C",
"u. c #AEF81B",
"v. c #ACF81B",
"w. c #ABF81B",
"x. c #A9F81A",
"y. c #A8F81A",
"z. c #A6F81A",
"A. c #A4F81A",
"B. c #A2F819",
"C. c #A1F819",
"D. c #9FF819",
"E. c #9EF818",
"F. c #9BF918",
"G. c #9AF917",
"H. c #98F917",
"I. c #97F917",
"J. c #95F916",
"K. c #93F916",
"L. c #91F916",
"M. c #90F915",
"N. c #8EF915",
"O. c #8DF914",
"P. c #8BF914",
"Q. c #89FA14",
"R. c #87FA13",
"S. c #86FA13",
"T. c #84FA13",
"U. c #83FA12",
"V. c #81FA12",
"W. c #7FFA12",
"X. c #7DFA12",
"Y. c #7CFA11",
"Z. c #7AFA11",
"`. c #78FA10",
" + c #76FA10",
".+ c #75FB10",
"++ c #73FB0F",
"@+ c #72FB0F",
"#+ c #70FB0F",
"$+ c #6EFB0E",
"%+ c #6DFB0E",
"&+ c #6BFB0E",
"*+ c #6AFB0D",
"=+ c #68FB0D",
"-+ c #66FB0C",
";+ c #64FB0C",
">+ c #63FB0C",
",+ c #61FC0B",
"'+ c #60FC0B",
")+ c #5EFC0B",
"!+ c #5CFC0A",
"~+ c #5AFC0A",
"{+ c #59FC09",
"]+ c #57FC09",
"^+ c #56FC09",
"/+ c #53FC09",
"(+ c #52FC08",
"_+ c #50FC08",
":+ c #4FFD08",
"<+ c #4DFD07",
"[+ c #4BFD07",
"}+ c #49FD07",
"|+ c #48FD06",
"1+ c #46FD06",
"2+ c #45FD05",
"3+ c #43FD05",
"4+ c #41FD05",
"5+ c #3FFD04",
"6+ c #3EFD04",
"7+ c #3CFD04",
"8+ c #3BFE03",
"9+ c #39FE03",
"0+ c #37FE02",
"a+ c #35FE02",
"b+ c #34FE02",
"c+ c #32FE01",
"d+ c #30FE01",
"e+ c #2EFE01",
"f+ c #2DFE00",
"g+ c #2BFE00",
". . + + + ",
". . + + + ",
"@ @ @ @ @ ",
"# # # # # ",
"$ $ $ $ $ ",
"% % % % % ",
"& & & & & ",
"* * * * * ",
"= = = = = ",
"- - - - - ",
"; ; ; ; ; ",
"> > > > > ",
", , , , , ",
"' ' ' ' ' ",
") ) ) ) ) ",
"! ! ! ! ! ",
"~ ~ ~ ~ ~ ",
"{ { { { { ",
"] ] ] ] ] ",
"^ ^ ^ ^ ^ ",
"/ / / / / ",
"( ( ( ( ( ",
"_ _ _ _ _ ",
": : : : : ",
": : : : : ",
"< < < < < ",
"[ [ [ [ [ ",
"} } } } } ",
"} } } } } ",
"| | | | | ",
"1 1 1 1 1 ",
"2 2 2 2 2 ",
"3 3 3 3 3 ",
"4 4 4 4 4 ",
"5 5 5 5 5 ",
"6 6 6 6 6 ",
"6 6 6 6 6 ",
"7 7 7 7 7 ",
"8 8 8 8 8 ",
"9 9 9 9 9 ",
"9 9 9 9 9 ",
"0 0 0 0 0 ",
"a a a a a ",
"a a a a a ",
"b b b b b ",
"c c c c c ",
"d d d d d ",
"d d d d d ",
"e e e e e ",
"f f f f f ",
"g g g g g ",
"g g g g g ",
"h h h h h ",
"i i i i i ",
"j j j j j ",
"k k k k k ",
"l l l l l ",
"m m m m m ",
"n n n n n ",
"n n n n n ",
"o o o o o ",
"p p p p p ",
"q q q q q ",
"q q q q q ",
"r r r r r ",
"s s s s s ",
"t t t t t ",
"u u u u u ",
"v v v v v ",
"w w w w w ",
"x x x x x ",
"x x x x x ",
"y y y y y ",
"z z z z z ",
"A A A A A ",
"A A A A A ",
"B B B B B ",
"C C C C C ",
"D D D D D ",
"D D D D D ",
"E E E E E ",
"F F F F F ",
"G G G G G ",
"G G G G G ",
"H H H H H ",
"I I I I I ",
"I I I I I ",
"J J J J J ",
"K K K K K ",
"L L L L L ",
"M M M M M ",
"N N N N N ",
"O O O O O ",
"P P P P P ",
"P P P P P ",
"Q Q Q Q Q ",
"R R R R R ",
"S S S S S ",
"S S S S S ",
"T T T T T ",
"U U U U U ",
"V V V V V ",
"V V V V V ",
"W W W W W ",
"X X X X X ",
"Y Y Y Y Y ",
"Y Y Y Y Y ",
"Z Z Z Z Z ",
"` ` ` ` ` ",
" . . . . .",
"..........",
"+.+.+.+.+.",
"@.@.@.@.@.",
"#.#.#.#.#.",
"#.#.#.#.#.",
"$.$.$.$.$.",
"%.%.%.%.%.",
"&.&.&.&.&.",
"&.&.&.&.&.",
"*.*.*.*.*.",
"=.=.=.=.=.",
"-.-.-.-.-.",
";.;.;.;.;.",
";.;.;.;.;.",
">.>.>.>.>.",
",.,.,.,.,.",
"'.'.'.'.'.",
").).).).).",
"!.!.!.!.!.",
"~.~.~.~.~.",
"{.{.{.{.{.",
"].].].].].",
"^.^.^.^.^.",
"/././././.",
"(.(.(.(.(.",
"_._._._._.",
":.:.:.:.:.",
"<.<.<.<.<.",
"[.[.[.[.[.",
"}.}.}.}.}.",
"|.|.|.|.|.",
"1.1.1.1.1.",
"2.2.2.2.2.",
"3.3.3.3.3.",
"4.4.4.4.4.",
"5.5.5.5.5.",
"6.6.6.6.6.",
"7.7.7.7.7.",
"8.8.8.8.8.",
"9.9.9.9.9.",
"0.0.0.0.0.",
"a.a.a.a.a.",
"b.b.b.b.b.",
"c.c.c.c.c.",
"d.d.d.d.d.",
"e.e.e.e.e.",
"f.f.f.f.f.",
"g.g.g.g.g.",
"h.h.h.h.h.",
"i.i.i.i.i.",
"j.j.j.j.j.",
"k.k.k.k.k.",
"l.l.l.l.l.",
"m.m.m.m.m.",
"n.n.n.n.n.",
"o.o.o.o.o.",
"p.p.p.p.p.",
"q.q.q.q.q.",
"r.r.r.r.r.",
"s.s.s.s.s.",
"t.t.t.t.t.",
"u.u.u.u.u.",
"v.v.v.v.v.",
"w.w.w.w.w.",
"x.x.x.x.x.",
"y.y.y.y.y.",
"z.z.z.z.z.",
"A.A.A.A.A.",
"B.B.B.B.B.",
"C.C.C.C.C.",
"D.D.D.D.D.",
"E.E.E.E.E.",
"F.F.F.F.F.",
"G.G.G.G.G.",
"H.H.H.H.H.",
"I.I.I.I.I.",
"J.J.J.J.J.",
"K.K.K.K.K.",
"L.L.L.L.L.",
"M.M.M.M.M.",
"N.N.N.N.N.",
"O.O.O.O.O.",
"P.P.P.P.P.",
"Q.Q.Q.Q.Q.",
"R.R.R.R.R.",
"S.S.S.S.S.",
"T.T.T.T.T.",
"U.U.U.U.U.",
"V.V.V.V.V.",
"W.W.W.W.W.",
"X.X.X.X.X.",
"Y.Y.Y.Y.Y.",
"Z.Z.Z.Z.Z.",
"`.`.`.`.`.",
" + + + + +",
".+.+.+.+.+",
"++++++++++",
"@+@+@+@+@+",
"#+#+#+#+#+",
"$+$+$+$+$+",
"%+%+%+%+%+",
"&+&+&+&+&+",
"*+*+*+*+*+",
"=+=+=+=+=+",
"-+-+-+-+-+",
";+;+;+;+;+",
">+>+>+>+>+",
",+,+,+,+,+",
"'+'+'+'+'+",
")+)+)+)+)+",
"!+!+!+!+!+",
"~+~+~+~+~+",
"{+{+{+{+{+",
"]+]+]+]+]+",
"^+^+^+^+^+",
"/+/+/+/+/+",
"(+(+(+(+(+",
"_+_+_+_+_+",
":+:+:+:+:+",
"<+<+<+<+<+",
"[+[+[+[+[+",
"}+}+}+}+}+",
"|+|+|+|+|+",
"1+1+1+1+1+",
"2+2+2+2+2+",
"3+3+3+3+3+",
"4+4+4+4+4+",
"5+5+5+5+5+",
"6+6+6+6+6+",
"7+7+7+7+7+",
"8+8+8+8+8+",
"9+9+9+9+9+",
"0+0+0+0+0+",
"a+a+a+a+a+",
"b+b+b+b+b+",
"c+c+c+c+c+",
"d+d+d+d+d+",
"e+e+e+e+e+",
"f+f+f+f+f+",
"g+g+g+g+g+"};

View File

@ -25,6 +25,7 @@
#include <gtkmm2ext/fastmeter.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm/style.h>
#include <string.h>
using namespace Gtk;
using namespace Gdk;
@ -32,15 +33,15 @@ using namespace Glib;
using namespace Gtkmm2ext;
using namespace std;
string FastMeter::v_image_path;
string FastMeter::h_image_path;
RefPtr<Pixbuf> FastMeter::v_pixbuf;
gint FastMeter::v_pixheight = 0;
gint FastMeter::v_pixwidth = 0;
RefPtr<Pixbuf> FastMeter::h_pixbuf;
gint FastMeter::h_pixheight = 0;
gint FastMeter::h_pixwidth = 0;
int FastMeter::min_v_pixbuf_size = 50;
int FastMeter::max_v_pixbuf_size = 1024;
Glib::RefPtr<Gdk::Pixbuf>* FastMeter::v_pixbuf_cache = 0;
int FastMeter::min_h_pixbuf_size = 50;
int FastMeter::max_h_pixbuf_size = 1024;
Glib::RefPtr<Gdk::Pixbuf>* FastMeter::h_pixbuf_cache = 0;
FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o)
{
@ -56,46 +57,184 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o)
pixrect.x = 0;
pixrect.y = 0;
if (!v_image_path.empty() && v_pixbuf == 0) {
v_pixbuf = Pixbuf::create_from_file (v_image_path);
v_pixheight = v_pixbuf->get_height();
v_pixwidth = v_pixbuf->get_width();
}
if (!h_image_path.empty() && h_pixbuf == 0) {
h_pixbuf = Pixbuf::create_from_file (h_image_path);
h_pixheight = h_pixbuf->get_height();
h_pixwidth = h_pixbuf->get_width();
}
if (orientation == Vertical) {
pixrect.width = min (v_pixwidth, (gint) dimen);
pixrect.height = v_pixheight;
pixbuf = request_vertical_meter(250);
} else {
pixrect.width = h_pixwidth;
pixrect.height = min (h_pixheight, (gint) dimen);
pixbuf = request_horizontal_meter(186);
}
pixheight = pixbuf->get_height();
pixwidth = pixbuf->get_width();
if (orientation == Vertical) {
pixrect.width = min (pixwidth, (gint) dimen);
pixrect.height = pixheight;
} else {
pixrect.width = pixwidth;
pixrect.height = min (pixheight, (gint) dimen);
}
request_width = pixrect.width;
request_height= pixrect.height;
}
Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_vertical_meter(int length)
{
if (length < min_v_pixbuf_size)
length = min_v_pixbuf_size;
if (length > max_v_pixbuf_size)
length = max_v_pixbuf_size;
int index = length - 1;
if (v_pixbuf_cache == 0) {
v_pixbuf_cache = (Glib::RefPtr<Gdk::Pixbuf>*) malloc(sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_v_pixbuf_size);
memset(v_pixbuf_cache,0,sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_v_pixbuf_size);
}
Glib::RefPtr<Gdk::Pixbuf> ret = v_pixbuf_cache[index];
if (ret)
return ret;
guint8* data;
int width = 5;
int height = length;
data = (guint8*) malloc(width*height * 3);
guint8 r,g,b;
r=0;
g=255;
b=0;
// fake log calculation copied from log_meter.h
// actual calculation:
// log_meter(0.0f) =
// def = (0.0f + 20.0f) * 2.5f + 50f
// return def / 115.0f
int knee = (int)floor((float)height * 100.0f / 115.0f);
int y;
for (y = 0; y < knee / 2; y++) {
r = (guint8)floor(255.0 * (float)y/(float)(knee / 2));
for (int x = 0; x < width; x++) {
data[ (x+(height-y-1)*width) * 3 + 0 ] = r;
data[ (x+(height-y-1)*width) * 3 + 1 ] = g;
data[ (x+(height-y-1)*width) * 3 + 2 ] = b;
}
}
for (; y < knee; y++) {
g = 255 - (guint8)floor(170.0 * (float)(y - knee/ 2)/(float)(knee / 2));
for (int x = 0; x < width; x++) {
data[ (x+(height-y-1)*width) * 3 + 0 ] = r;
data[ (x+(height-y-1)*width) * 3 + 1 ] = g;
data[ (x+(height-y-1)*width) * 3 + 2 ] = b;
}
}
r=255;
g=0;
b=0;
for (; y < height; y++) {
for (int x = 0; x < width; x++) {
data[ (x+(height-y-1)*width) * 3 + 0 ] = r;
data[ (x+(height-y-1)*width) * 3 + 1 ] = g;
data[ (x+(height-y-1)*width) * 3 + 2 ] = b;
}
}
ret = Pixbuf::create_from_data(data, COLORSPACE_RGB, false, 8, width, height, width * 3);
v_pixbuf_cache[index] = ret;
return ret;
}
Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_horizontal_meter(int length)
{
if (length < min_h_pixbuf_size)
length = min_h_pixbuf_size;
if (length > max_h_pixbuf_size)
length = max_h_pixbuf_size;
int index = length - 1;
if (h_pixbuf_cache == 0) {
h_pixbuf_cache = (Glib::RefPtr<Gdk::Pixbuf>*) malloc(sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_h_pixbuf_size);
memset(h_pixbuf_cache,0,sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_h_pixbuf_size);
}
Glib::RefPtr<Gdk::Pixbuf> ret = h_pixbuf_cache[index];
if (ret)
return ret;
guint8* data;
int width = length;
int height = 5;
data = (guint8*) malloc(width*height * 3);
guint8 r,g,b;
r=0;
g=255;
b=0;
// fake log calculation copied from log_meter.h
// actual calculation:
// log_meter(0.0f) =
// def = (0.0f + 20.0f) * 2.5f + 50f
// return def / 115.0f
int knee = (int)floor((float)width * 100.0f / 115.0f);
int x;
for (x = 0; x < knee / 2; x++) {
r = (guint8)floor(255.0 * (float)x/(float)(knee / 2));
for (int y = 0; y < height; y++) {
data[ (x+(height-y-1)*width) * 3 + 0 ] = r;
data[ (x+(height-y-1)*width) * 3 + 1 ] = g;
data[ (x+(height-y-1)*width) * 3 + 2 ] = b;
}
}
for (; x < knee; x++) {
g = 255 - (guint8)floor(170.0 * (float)(x - knee/ 2)/(float)(knee / 2));
for (int y = 0; y < height; y++) {
data[ (x+(height-y-1)*width) * 3 + 0 ] = r;
data[ (x+(height-y-1)*width) * 3 + 1 ] = g;
data[ (x+(height-y-1)*width) * 3 + 2 ] = b;
}
}
r=255;
g=0;
b=0;
for (; x < width; x++) {
for (int y = 0; y < height; y++) {
data[ (x+(height-y-1)*width) * 3 + 0 ] = r;
data[ (x+(height-y-1)*width) * 3 + 1 ] = g;
data[ (x+(height-y-1)*width) * 3 + 2 ] = b;
}
}
ret = Pixbuf::create_from_data(data, COLORSPACE_RGB, false, 8, width, height, width * 3);
h_pixbuf_cache[index] = ret;
return ret;
}
FastMeter::~FastMeter ()
{
}
void
FastMeter::set_vertical_xpm (std::string path)
{
v_image_path = path;
}
void
FastMeter::set_horizontal_xpm (std::string path)
{
h_image_path = path;
}
void
FastMeter::set_hold_count (long val)
{
@ -113,8 +252,63 @@ FastMeter::set_hold_count (long val)
void
FastMeter::on_size_request (GtkRequisition* req)
{
req->width = request_width;
req->height = request_height;
if (orientation == Vertical) {
req->height = request_height;
req->height = max(req->height, min_v_pixbuf_size);
req->height = min(req->height, max_v_pixbuf_size);
req->width = 5;
} else {
req->width = request_width;
req->width = max(req->width, min_h_pixbuf_size);
req->width = min(req->width, max_h_pixbuf_size);
req->height = 5;
}
}
void
FastMeter::on_size_allocate (Gtk::Allocation &alloc)
{
if (orientation == Vertical) {
if (alloc.get_width() != 5) {
alloc.set_width(5);
}
int h = alloc.get_height();
h = max(h, min_v_pixbuf_size);
h = min(h, max_v_pixbuf_size);
if ( h != alloc.get_height())
alloc.set_height(h);
if (pixheight != h) {
pixbuf = request_vertical_meter(h);
}
} else {
if (alloc.get_height() != 5) {
alloc.set_height(5);
}
int w = alloc.get_width();
w = max(w, min_h_pixbuf_size);
w = min(w, max_h_pixbuf_size);
if ( w != alloc.get_width())
alloc.set_width(w);
if (pixwidth != w) {
pixbuf = request_horizontal_meter(w);
}
}
pixheight = pixbuf->get_height();
pixwidth = pixbuf->get_width();
DrawingArea::on_size_allocate(alloc);
}
bool
@ -134,78 +328,87 @@ FastMeter::vertical_expose (GdkEventExpose* ev)
GdkRectangle intersection;
GdkRectangle background;
top_of_meter = (gint) floor (v_pixheight * current_level);
top_of_meter = (gint) floor (pixheight * current_level);
pixrect.height = top_of_meter;
background.x = 0;
background.y = 0;
background.width = pixrect.width;
background.height = v_pixheight - top_of_meter;
background.height = pixheight - top_of_meter;
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
get_window()->draw_rectangle (get_style()->get_black_gc(), true,
intersection.x, intersection.y,
intersection.width, intersection.height);
}
if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
/* draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom)
*/
get_window()->draw_pixbuf(get_style()->get_fg_gc(get_state()), v_pixbuf,
intersection.x, v_pixheight - top_of_meter,
intersection.x, v_pixheight - top_of_meter,
// draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom)
get_window()->draw_pixbuf(get_style()->get_fg_gc(get_state()), pixbuf,
intersection.x, pixheight - top_of_meter,
intersection.x, pixheight - top_of_meter,
intersection.width, intersection.height,
Gdk::RGB_DITHER_NONE, 0, 0);
}
/* draw peak bar */
if (hold_state) {
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), v_pixbuf,
intersection.x, v_pixheight - (gint) floor (v_pixheight * current_peak),
intersection.x, v_pixheight - (gint) floor (v_pixheight * current_peak),
// draw peak bar
if (hold_state && intersection.width > 0) {
gint y = pixheight - (gint) floor (pixheight * current_peak);
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), pixbuf,
intersection.x, y,
intersection.x, y,
intersection.width, 3,
Gdk::RGB_DITHER_NONE, 0, 0);
}
return true;
return TRUE;
}
bool
FastMeter::horizontal_expose (GdkEventExpose* ev)
{
GdkRectangle intersection;
gint right_of_meter;
GdkRectangle intersection;
GdkRectangle background;
right_of_meter = (gint) floor (h_pixwidth * current_level);
right_of_meter = (gint) floor (pixwidth * current_level);
pixrect.width = right_of_meter;
if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
/* draw the part of the meter image that we need.
*/
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), h_pixbuf,
intersection.x, intersection.y,
intersection.x, intersection.y,
intersection.width, intersection.height,
Gdk::RGB_DITHER_NONE, 0, 0);
background.x = 0;
background.y = 0;
background.width = pixwidth - right_of_meter;
background.height = pixrect.height;
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
get_window()->draw_rectangle (get_style()->get_black_gc(), true,
intersection.x + right_of_meter, intersection.y,
intersection.width, intersection.height);
}
/* draw peak bar */
if (hold_state) {
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), h_pixbuf,
right_of_meter, intersection.y,
right_of_meter, intersection.y,
if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
// draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom)
get_window()->draw_pixbuf(get_style()->get_fg_gc(get_state()), pixbuf,
intersection.x, intersection.y,
intersection.x, intersection.y,
intersection.width, intersection.height,
Gdk::RGB_DITHER_NONE, 0, 0);
}
// draw peak bar
// XXX: peaks don't work properly
/*
if (hold_state && intersection.height > 0) {
gint x = (gint) floor(pixwidth * current_peak);
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), pixbuf,
x, intersection.y,
x, intersection.y,
3, intersection.height,
Gdk::RGB_DITHER_NONE, 0, 0);
}
*/
return true;
}

View File

@ -46,23 +46,16 @@ class FastMeter : public Gtk::DrawingArea {
long hold_count() { return hold_cnt; }
void set_hold_count (long);
static void set_horizontal_xpm (std::string);
static void set_vertical_xpm (std::string);
protected:
bool on_expose_event (GdkEventExpose*);
void on_size_request (GtkRequisition*);
void on_size_allocate (Gtk::Allocation&);
private:
static std::string h_image_path;
static std::string v_image_path;
static Glib::RefPtr<Gdk::Pixbuf> h_pixbuf;
static gint h_pixheight;
static gint h_pixwidth;
static Glib::RefPtr<Gdk::Pixbuf> v_pixbuf;
static gint v_pixheight;
static gint v_pixwidth;
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
gint pixheight;
gint pixwidth;
Orientation orientation;
GdkRectangle pixrect;
@ -76,6 +69,18 @@ class FastMeter : public Gtk::DrawingArea {
bool vertical_expose (GdkEventExpose*);
bool horizontal_expose (GdkEventExpose*);
static Glib::RefPtr<Gdk::Pixbuf> request_vertical_meter(int);
static Glib::RefPtr<Gdk::Pixbuf> *v_pixbuf_cache;
static int min_v_pixbuf_size;
static int max_v_pixbuf_size;
static Glib::RefPtr<Gdk::Pixbuf> request_horizontal_meter(int);
static Glib::RefPtr<Gdk::Pixbuf> *h_pixbuf_cache;
static int min_h_pixbuf_size;
static int max_h_pixbuf_size;
};