Old 09-12-2019, 04:16 PM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default help fix time display script?

below is a script by spk77 that i've tried to simplify but probably wound up butchering. it does work but i have two problems with it.

first, i can't seem to get the window any smaller. this may be an os thing but, the way i want to use this, it's not ideal this way. i'd like to be able to drag the display window to the top of my monitor, high enough to not completely block the cursor placement lanes and such atop the tcp window. right now the script's display window is just big enough to block cursor placement in this manner where the window sits. if i could get the window smaller it would solve the problem.

second has more to do with my own lack of coding ability. i've hard coded some things in trying to figure out how this works and have caused some problems while solving others. the original script displays a message below the time readout that tells the user what format the time is displayed in when the mouse is hovered over the time. i managed to simplify the message and get it to display alongside rather than under the time but, in doing so, have caused problems when the font size is modified with the mouse wheel. the message is anchored to its position and, as the time enlarges via the mouse, it begins to overlap the time display. i couldn't figure out how to get it to follow the time display as they both enlarge.

any advice on fixing these is much appreciated.

thanks,
babag
Code:
// Time display tool (EEL script by spk77 21.7.2014)
// Use mouse wheel to increase/decrease font size
// left click on time string -> cycle through time formatting modes

font_size = 24;
font_name = "Verdana";

function adjust_font_size(mouse_wheel_val)
(
  mouse_wheel_val > 0 ? (
    font_size < 40 ? (
      font_size += 2;
    );
  );
  
  mouse_wheel_val < 0 ? (
    (font_size > 6 ) ? (
      font_size -= 2;
    );
  );
  gfx_setfont(1, font_name, font_size);
  mouse_wheel = 0;
);

function init(window_w, window_h)
(
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  gfx_init("Time Duration tool", window_w, window_h);
  gfx_setfont(1, font_name, font_size);
);

function run() local(time_range, time_sel_start, time_sel_end)
(
  gfx_a = 0.5; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  gfx_x = 0;
  gfx_y = 0;
  GetSet_LoopTimeRange(0, 0, time_sel_start, time_sel_end, 0);
  time_range = time_sel_end - time_sel_start;
  format_timestr_pos(time_range, #ts_buf, ts_format);
  
  
  y_ts = gfx_y;
  gfx_printf("Duration:  ");
  x_ts = gfx_x;
  
  gfx_x = 10;
  gfx_y += 2 * gfx_texth;
  
  //gfx_printf(#buf);
  gfx_measurestr(#ts_buf, w_ts, 0);
  
  mouse_wheel != 0 ? adjust_font_size(mouse_wheel);
  
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  
  mouse_x > x_ts && mouse_x < x_ts + w_ts && mouse_y > y_ts && mouse_y < y_ts + gfx_texth /*&& mouse_state == 0*/ ? (
    gfx_x = 300;
//    gfx_y = 1 * gfx_texth;
    gfx_y = y_ts;

    
    ts_format == 0 ? (
      gfx_printf("(h:)m:s.ms");
    ) : ts_format == 1 ? (
      gfx_printf("measures.beats.time");
    ) : ts_format == 2 ? (
      gfx_printf("measures.beats");
    ) : ts_format == 3 ? (
      gfx_printf("seconds");
    ) : ts_format == 4 ? (
      gfx_printf("samples");
    ) : ts_format == 5 ? (
      gfx_printf("h:m:s:fr");
    );

    gfx_r = 0.5; gfx_g = 0.5;
    mouse_cap == 1 ? (
      //gfx_r = 0.5; gfx_g = 0.5;
      mouse_state == 0 ? (
        mouse_state = 1;
        ts_format < 5 ? ts_format += 1 : ts_format = 0;
      );
    );
  );
  gfx_x = x_ts;
  gfx_y = y_ts;
  gfx_printf(#ts_buf);
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  
  mouse_cap == 0 ? mouse_state = 0;// : mouse_state = 1;
  gfx_update();
  gfx_getchar() >= 0 ? defer("run();");
);

// init(window_w, window_h);
init(320, 32);
run();
babag is offline   Reply With Quote
Old 09-12-2019, 10:16 PM   #2
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

i've solved some problems. the big one remaining is getting a smaller window.

i made two versions of the spk77 script. the first is simpler, having a static unit of display. the original script used the mouse to click through different units of display (h:m:s:ms, measures:beats, samples, etc). it also had cursor info i didn't need or want. this one just has time selection duration displayed in the units defined in the script. you edit the script to get different units.

the second is more like spk77's except for the layout and elimination of the cursor info. it retains the ability to cycle through display modes by clicking.

edit: made some more modifications to get the window to open at a specific location on my screens. be careful with this. i have a lot of screen real estate and these numbers will likely put the window off screen for many, especially laptop, users.

static
Code:
// Time display tool (EEL script by spk77 21.7.2014)
// Modified by BabaG (12.9.2019) to eliminate cycling through time formatting modes and cursor position info.
// This version only displays the time selection duration in the mode defined in the script.
// Use mouse wheel to increase/decrease font size
// left click on time string -> cycle through time formatting modes (this is disabled in this version)

font_size = 24;
font_name = "Verdana";

function adjust_font_size(mouse_wheel_val)
(
  mouse_wheel_val > 0 ? (// sets max font size
    font_size < 40 ? (
      font_size += 2;
    );
  );
  
  mouse_wheel_val < 0 ? (// sets min font size
    (font_size > 6 ) ? (
      font_size -= 2;
    );
  );
  gfx_setfont(1, font_name, font_size);
  mouse_wheel = 0;
);

function init(window_w, window_h, window_s, window_x, window_y)// draws window at specofoc size and position
(
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  gfx_init("Time Duration tool", window_w, window_h, window_s, window_x, window_y);
  gfx_setfont(1, font_name, font_size);
);

function run() local(time_range, time_sel_start, time_sel_end)
(
  gfx_a = 0.5; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  gfx_x = 0;
  gfx_y = 0;
  GetSet_LoopTimeRange(0, 0, time_sel_start, time_sel_end, 0);
  time_range = time_sel_end - time_sel_start;
  format_timestr_pos(time_range, #ts_buf, ts_format);
  
  
  y_ts = gfx_y;
  gfx_printf("Duration:  ");
  x_ts = gfx_x;
  
  gfx_x = 10;
  gfx_y += 2 * gfx_texth;
  
  //gfx_printf(#buf);
  gfx_measurestr(#ts_buf, w_ts, 0);
  
  mouse_wheel != 0 ? adjust_font_size(mouse_wheel);
  
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  
//  mouse_x > x_ts && mouse_x < x_ts + w_ts && mouse_y > y_ts && mouse_y < y_ts + gfx_texth /*&& mouse_state == 0*/ ? (// uncommenting this line restricts mouse click operations to when hovering over displayed value
    gfx_x = x_ts + w_ts + 20;// this sets where unit identification (hmsf, seconds, samples, etc) will display to the right of value display
//    gfx_y = 1 * gfx_texth;
    gfx_y = y_ts;

    ts_format = 0;// sets displayed value's units. see below for options and uncomment the appropriate one. 
    
    ts_format == 0 ? (
      gfx_printf("(h:)m:s.ms");
//    ) : ts_format == 1 ? (
//      gfx_printf("measures.beats.time");
//    ) : ts_format == 2 ? (
//      gfx_printf("measures.beats");
//    ) : ts_format == 3 ? (
//      gfx_printf("seconds");
//    ) : ts_format == 4 ? (
//      gfx_printf("samples");
//    ) : ts_format == 5 ? (
//      gfx_printf("h:m:s:fr");
//    );

    gfx_r = 0.5; gfx_g = 0.5;// sets the color of the displayed value
//    mouse_cap == 1 ? (
//      //gfx_r = 0.5; gfx_g = 0.5;
//      mouse_state == 0 ? (
//        mouse_state = 1;
//        ts_format < 5 ? ts_format += 1 : ts_format = 0;
//      );
//    );
  );
  gfx_x = x_ts;
  gfx_y = y_ts;
  gfx_printf(#ts_buf);// prints the time selection duration
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  
  mouse_cap == 0 ? mouse_state = 0;// : mouse_state = 1;
  gfx_update();
  gfx_getchar() >= 0 ? defer("run();");
);

// init(window_w, window_h);
init(420, 32, 0, 4500, 2148);
run();
cycling
Code:
// Time display tool (EEL script by spk77 21.7.2014)
// Modified by BabaG (12.9.2019) to eliminate cursor position info and have a smaller window.
// Use mouse wheel to increase/decrease font size
// left click on time string -> cycle through time formatting modes

font_size = 24;
font_name = "Verdana";

function adjust_font_size(mouse_wheel_val)
(
  mouse_wheel_val > 0 ? (// sets max font size
    font_size < 40 ? (
      font_size += 2;
    );
  );
  
  mouse_wheel_val < 0 ? (// sets min font size
    (font_size > 6 ) ? (
      font_size -= 2;
    );
  );
  gfx_setfont(1, font_name, font_size);
  mouse_wheel = 0;
);

function init(window_w, window_h, window_s, window_x, window_y)// draws window at specofoc size and position
(
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  gfx_init("Time Duration tool", window_w, window_h, window_s, window_x, window_y);
  gfx_setfont(1, font_name, font_size);
);

function run() local(time_range, time_sel_start, time_sel_end)
(
  gfx_a = 0.5; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  gfx_x = 0;
  gfx_y = 0;
  GetSet_LoopTimeRange(0, 0, time_sel_start, time_sel_end, 0);
  time_range = time_sel_end - time_sel_start;
  format_timestr_pos(time_range, #ts_buf, ts_format);
  
  
  y_ts = gfx_y;
  gfx_printf("Duration:  ");
  x_ts = gfx_x;
  
  gfx_x = 10;
  gfx_y += 2 * gfx_texth;
  
  //gfx_printf(#buf);
  gfx_measurestr(#ts_buf, w_ts, 0);
  
  mouse_wheel != 0 ? adjust_font_size(mouse_wheel);
  
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  
//  mouse_x > x_ts && mouse_x < x_ts + w_ts && mouse_y > y_ts && mouse_y < y_ts + gfx_texth /*&& mouse_state == 0*/ ? (// uncommenting this line restricts mouse click operations to when hovering over displayed value
    gfx_x = x_ts + w_ts + 20;// this sets where unit identification (hmsf, seconds, samples, etc) will display to the right of value display
//    gfx_y = 1 * gfx_texth;
    gfx_y = y_ts;

    
    ts_format == 0 ? (
      gfx_printf("(h:)m:s.ms");
    ) : ts_format == 1 ? (
      gfx_printf("measures.beats.time");
    ) : ts_format == 2 ? (
      gfx_printf("measures.beats");
    ) : ts_format == 3 ? (
      gfx_printf("seconds");
    ) : ts_format == 4 ? (
      gfx_printf("samples");
    ) : ts_format == 5 ? (
      gfx_printf("h:m:s:fr");
    );

    gfx_r = 0.5; gfx_g = 0.5;// sets the color of the displayed value
    mouse_cap == 1 ? (
      //gfx_r = 0.5; gfx_g = 0.5;
      mouse_state == 0 ? (
        mouse_state = 1;
        ts_format < 5 ? ts_format += 1 : ts_format = 0;
      );
    );
//  );
  gfx_x = x_ts;
  gfx_y = y_ts;
  gfx_printf(#ts_buf);// prints the time selection duration
  gfx_a = 1; gfx_r = 1; gfx_g = 1; gfx_b = 1;
  
  mouse_cap == 0 ? mouse_state = 0;// : mouse_state = 1;
  gfx_update();
  gfx_getchar() >= 0 ? defer("run();");
);

// init(window_w, window_h);
init(420, 32, 0, 4500, 2148);
run();
for anyone interested, i do some work in which a lot of my time is spent at the top of the tcp window and wanted a larger display of the time selection duration that was more in my field of view. this, pretty much, accomplishes that. would be great to get the window just a little smaller, though.

i use the default theme and not only is the duration at the bottom, it's tiny and has start/end displayed alongside the duration which, for me, makes it difficult to get a quick assessment of time.

thanks and please make this better. i'm no coder.
babag

Last edited by babag; 09-13-2019 at 11:31 AM.
babag is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.