group { name: "e/modules/cpufreq/main"; alias: "e/gadget/cpuclock/main"; alias: "e/gadget/cpuclock/main_vert"; images.image: "tacho_base.png" COMP; images.image: "inset_round_hilight.png" COMP; images.image: "inset_round_shadow.png" COMP; images.image: "inset_round_shading.png" COMP; set { name: "tacho_hand_big"; image { image: "tacho_hand_big.png" COMP; size: 73 73 99999 99999; } image { image: "tacho_hand_big2.png" COMP; size: 37 37 72 72; } image { image: "tacho_hand_big3.png" COMP; size: 19 19 36 36; } image { image: "tacho_hand_big4.png" COMP; size: 0 0 18 18; } } images.image: "tacho_hand_big_shadow.png" COMP; set { name: "tacho_hand_small_min"; image { image: "tacho_hand_small_min.png" COMP; size: 73 73 99999 99999; } image { image: "tacho_hand_small_min2.png" COMP; size: 37 37 72 72; } image { image: "tacho_hand_small_min3.png" COMP; size: 19 19 36 36; } image { image: "tacho_hand_small_min4.png" COMP; size: 0 0 18 18; } } images.image: "tacho_hand_small_shadow.png" COMP; set { name: "knob"; image { image: "knob_sz_24.png" COMP; size: 31 31 32 32; } image { image: "knob_sz_22.png" COMP; size: 29 29 30 30; } image { image: "knob_sz_20.png" COMP; size: 27 27 28 28; } image { image: "knob_sz_18.png" COMP; size: 25 25 26 26; } image { image: "knob_sz_16.png" COMP; size: 23 23 24 24; } image { image: "knob_sz_14.png" COMP; size: 21 21 22 22; } image { image: "knob_sz_12.png" COMP; size: 19 19 20 20; } image { image: "knob_sz_10.png" COMP; size: 17 17 18 18; } image { image: "knob_sz_08.png" COMP; size: 15 15 16 16; } image { image: "knob_sz_06.png" COMP; size: 13 13 14 14; } image { image: "knob_sz_04.png" COMP; size: 0 0 12 12; } } script { public available_frequencies; public available_governors; public cur_freq_old; public cur_freq_new; public cur_freq_now; public cur_freq_anim; public min_freq_old; public min_freq_new; public min_freq_now; public max_freq_old; public max_freq_new; public max_freq_now; public slide_cur_freq(val, Float:v) { new Float:freq, Float:min_freq, Float:max_freq, Float:tf; new f, f0, f1; v = (1.0 - cos(v * 3.141592654)) / 2.0; min_freq = fetch_int(available_frequencies, 0); max_freq = fetch_int(available_frequencies, count(available_frequencies) - 1); f0 = get_int(cur_freq_old); f1 = get_int(cur_freq_new); f = f1 - f0; freq = float(f) * v; f = round(freq); f = f + f0; set_int(cur_freq_now, f); freq = (float(f) - min_freq) / (max_freq - min_freq); tf = (freq * 225.0) - 135.0; custom_state(PART:"meter", "default", 0.0); set_state_val(PART:"meter", STATE_MAP_ROT_Z, tf); set_state(PART:"meter", "custom", 0.0); custom_state(PART:"meter_sh", "default", 0.0); set_state_val(PART:"meter_sh", STATE_MAP_ROT_Z, tf); set_state(PART:"meter_sh", "custom", 0.0); f0 = get_int(min_freq_old); f1 = get_int(min_freq_new); f = f1 - f0; freq = float(f) * v; f = round(freq); f = f + f0; set_int(min_freq_now, f); freq = (float(f) - min_freq) / (max_freq - min_freq); tf = (freq * 225.0) - 135.0; custom_state(PART:"meter_min", "default", 0.0); set_state_val(PART:"meter_min", STATE_MAP_ROT_Z, tf); set_state(PART:"meter_min", "custom", 0.0); custom_state(PART:"meter_min_sh", "default", 0.0); set_state_val(PART:"meter_min_sh", STATE_MAP_ROT_Z, tf); set_state(PART:"meter_min_sh", "custom", 0.0); f0 = get_int(max_freq_old); f1 = get_int(max_freq_new); f = f1 - f0; freq = float(f) * v; f = round(freq); f = f + f0; set_int(max_freq_now, f); freq = (float(f) - min_freq) / (max_freq - min_freq); tf = (freq * 225.0) - 135.0; custom_state(PART:"meter_max", "default", 0.0); set_state_val(PART:"meter_max", STATE_MAP_ROT_Z, tf); set_state(PART:"meter_max", "custom", 0.0); custom_state(PART:"meter_max_sh", "default", 0.0); set_state_val(PART:"meter_max_sh", STATE_MAP_ROT_Z, tf); set_state(PART:"meter_max_sh", "custom", 0.0); if (v >= 1.0) { set_int(cur_freq_anim, 0); return 0; } return 1; } public message(Msg_Type:type, id, ...) { if ((type == MSG_INT_SET) && (id == 1)) { // add an available freq while (count(available_frequencies) > 0) { remove(available_frequencies, 0); } for (new i = 2; i < numargs(); i++) { append_int(available_frequencies, getarg(i)); } } else if ((type == MSG_STRING_SET) && (id == 2)) { // add a governor new text[100]; while (count(available_governors) > 0) { remove(available_governors, 0); } for (new i = 2; i < numargs(); i++) { snprintf(text, 100, "%s", getarg(i)); append_str(available_governors, text); } } else if ((type == MSG_INT_SET) && (id == 3)) { // avg freq new f; new ani, curf, minf, maxf; new text[100]; f = getarg(2); if (f < 1000000) { f += 500; snprintf(text, 100, "%i", f / 1000); } else { f += 50000; snprintf(text, 100, "%i.%i", f / 1000000, (f % 1000000) / 100000); } set_text(PART:"readout", text); ani = get_int(cur_freq_anim); if (ani > 0) cancel_anim(ani); ani = anim(0.25, "slide_cur_freq", 0); set_int(cur_freq_anim, ani); f = getarg(2); curf = get_int(cur_freq_now); set_int(cur_freq_old, curf); set_int(cur_freq_new, f); f = getarg(4); minf = get_int(min_freq_now); set_int(min_freq_old, minf); set_int(min_freq_new, f); f = getarg(5); maxf = get_int(max_freq_now); set_int(max_freq_old, maxf); set_int(max_freq_new, f); } else if ((type == MSG_STRING) && (id == 4)) { new text[100]; snprintf(text, 100, "%s", getarg(2)); } } } parts { part { name: "fade_clip"; type: RECT; description { state: "default" 0.0; color: 255 255 255 255; } description { state: "faded" 0.0; color: 255 255 255 128; } } part { name: "base-sh"; description { state: "default" 0.0; rel1.to: "base"; rel1.offset: 0 -1; rel2.to: "base"; rel2.offset: -1 -2; image.normal: "inset_round_shadow.png"; } } part { name: "base-hi"; description { state: "default" 0.0; rel1.to: "base"; rel1.offset: 0 1; rel2.to: "base"; rel2.offset: -1 0; image.normal: "inset_round_hilight.png"; } } part { name: "base"; description { state: "default" 0.0; rel1.relative: (25/380) (25/380); rel2.relative: (365/380) (365/380); aspect: 1.0 1.0; aspect_preference: BOTH; image.normal: "tacho_base.png"; } } part { name: "readout"; type: TEXT; mouse_events: 0; scale: 1; effect: SHADOW BOTTOM; clip_to: "fade_clip"; description { state: "default" 0.0; rel1.to: "knob2"; rel1.relative: 1.0 1.0; rel1.offset: -2 -2; rel2.relative: 0.75 0.75; color_class: "module_label"; color3: 255 255 255 255; text { font: FNBOLD; size: 6; align: 0.5 0.5; ellipsis: -1; text_class: "module_small"; } } } part { name: "meter_min_sh"; mouse_events: 0; clip_to: "fade_clip"; description { state: "default" 0.0; image.normal: "tacho_hand_small_shadow.png"; rel1.to: "meter_sh"; rel2.to: "meter_sh"; map { on: 1; rotation.center: "meter_min_sh"; } } } part { name: "meter_min"; mouse_events: 0; clip_to: "fade_clip"; description { state: "default" 0.0; image.normal: "tacho_hand_small_min"; color: 51 153 255 255; rel1.to: "base"; rel2.to: "base"; map { on: 1; rotation.center: "base"; } } } part { name: "meter_max_sh"; mouse_events: 0; clip_to: "fade_clip"; description { state: "default" 0.0; image.normal: "tacho_hand_small_shadow.png"; rel1.to: "meter_sh"; rel2.to: "meter_sh"; map { on: 1; rotation.center: "meter_max_sh"; } } } part { name: "meter_max"; mouse_events: 0; clip_to: "fade_clip"; description { state: "default" 0.0; image.normal: "tacho_hand_small_min"; color: 255 153 51 255; rel1.to: "base"; rel2.to: "base"; map { on: 1; rotation.center: "base"; } } } part { name: "meter_sh"; mouse_events: 0; clip_to: "fade_clip"; description { state: "default" 0.0; image.normal: "tacho_hand_big_shadow.png"; rel1.to: "meter"; rel1.relative: 0.0 (15/380); rel1.offset: 0 1; rel2.to: "meter"; rel2.relative: 1.0 (395/380); rel2.offset: -1 0; map { on: 1; rotation.center: "meter_sh"; } } } part { name: "meter"; mouse_events: 0; clip_to: "fade_clip"; description { state: "default" 0.0000; color: 255 0 0 255; image.normal: "tacho_hand_big"; rel1.to: "base"; rel2.to: "base"; map { on: 1; rotation.center: "base"; } } } part { name: "over"; mouse_events: 0; description { state: "default" 0.0; rel1.to: "base"; rel2.to: "base"; image.normal: "inset_round_shading.png"; } } part { name: "knob"; type: SPACER; description { state: "default" 0.0; rel1.relative: (140/340) (140/340); rel1.to: "base"; rel2.relative: (205/340) (205/340); rel2.to: "base"; min: 4 4; step: 2 2; max: 24 24; } } part { name: "knob2"; description { state: "default" 0.0; rel1.offset: -4 -4; rel1.to: "knob"; rel2.offset: 3 3; rel2.to: "knob"; min: 12 12; max: 32 32; image.normal: "knob"; } } } programs { program { signal: "e,state,enabled"; source: "e"; action: STATE_SET "default" 0.0; target: "fade_clip"; } program { signal: "e,state,disabled"; source: "e"; action: STATE_SET "faded" 0.0; target: "fade_clip"; } } } group { name: "e/gadget/cpuclock/main"; alias: "e/gadget/cpuclock/main_vert"; inherit: "e/modules/cpufreq/main"; parts { part { name: "readout"; type: TEXT; mouse_events: 0; scale: 1; effect: SHADOW BOTTOM; clip_to: "fade_clip"; description { state: "default" 0.0; visible: 0; } } } }