Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: JScript Panel (Read 291877 times) previous topic - next topic
0 Members and 14 Guests are viewing this topic.

Re: JScript Panel

Reply #575
I'm not changing the behaviour of JSPlaylist. Before dragging, you can middle click the panel which opens the playlist manager. When that's open you can drag to the header section which offers to create a new playlist.

I've updated JS Smooth playlist so it behaves like older versions. Use the jssp.js link above.

 

Re: JScript Panel

Reply #576
https://github.com/marc2k3/foo_jscript_panel/releases

## v2.6.2.1
- Fix drag/drop bug introduced when fixing callback bug in `v2.6.2`.

## v2.6.2
- Fix bug where callbacks that receive multiple args may not have received them in the correct order causing buggy behaviour in certain scripts.
- Fix various JS Smooth script issues.


Re: JScript Panel

Reply #578
https://github.com/marc2k3/foo_jscript_panel/releases

## v2.6.2.2
- Add `spectrogram seekbar` & `track info + spectrogram seekbar + buttons` samples.
- `JS Smooth Playlist` now displays dynamic artist/title info from radio streams.
- `JS Smooth Browser/Playlist` now correctly caches files as `jpg`. Previously they were saved as `png` with a `jpg` extension. Existing users may consider deleting their existing `js_smooth_cache` folder.

track info + spectrogram seekbar + buttons looks like this...


Re: JScript Panel

Reply #579
I'm trying to update Tedgo's Darkone Mod from 2016 to the latest Jscript DLL. I already updated his original V4 but his 2016 Mod is a little more finicky. This line here (from Global Buttons)  comes up with a type mismatch error...
Quote
   this.draw = function(gr) {
      gr.FillSolidRect(this.left, this.top, this.w, this.h, this.col);
      gr.DrawRect(this.left, this.top, this.w, this.h, 1, 0xFF000000);
   }

I know it's because it doesn't like the FillSolidRectangle being lumped in with "draw".  Any chance you could steer me in the right direction? I have the whole code below.

Thanks!

(BTW, thanks for those above mentioned updates)


Quote
// DarkOne4Mod - Drawbutton Object
// Code by tedGo, based on a sample by T.P. Wang

var ButtonStates = {normal: 0, hover: 1, down: 2, hide: 3};
var Buttons = {};
var g_down = false;

// ----- CREATE DRAWBUTTON OBJECT --------------------------------------
var g_tooltip;

function Button(x, y, w, h, btn_col, func, tiptext) {
   this.left = x;
   this.top = y;
   this.w = w;
   this.h = h;
   this.right = x + w;
   this.bottom = y + h;
   this.func = func;
   this.tiptext = tiptext;
   this.state = ButtonStates.normal;
   this.col_normal = btn_col && btn_col.normal ? btn_col.normal : null;
   this.col_hover = btn_col && btn_col.hover ? btn_col.hover : this.col_normal;
   this.col_down = btn_col && btn_col.down ? btn_col.down : this.col_hover;
   this.col = this.col_normal;

   this.traceMouse = function(x, y) {
      if (this.state == ButtonStates.hide) return false;

      var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);

      if (b)
         g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
      else
         this.changeState(ButtonStates.normal);
      return b;
   }

   this.changeState = function(newstate) {
      newstate != this.state && window.RepaintRect(this.left, this.top, this.w, this.h);
      this.state = newstate;
      switch (this.state) {
         case ButtonStates.normal:
            this.col = this.col_normal;
            break;

         case ButtonStates.hover:
            this.col = this.col_hover;
            break;

         case ButtonStates.down:
            this.col = this.col_down;
            break;

         default:
            this.col = null;
      }
   }

   this.changePos = function(x, y, w, h) {
      this.left = x;
      this.top = y;
      this.w = w;
      this.h = h;
      this.right = x + w;
      this.bottom = y + h;
   }

   this.draw = function(gr) {
      gr.FillSolidRect(this.left, this.top, this.w, this.h, this.col);
      gr.DrawRect(this.left, this.top, this.w, this.h, 1, 0xFF000000);
   }

   this.repaint = function() {
      window.RepaintRect(this.left, this.top, this.w, this.h);
   }

   this.onClick = function() {
      this.func && this.func();
   }

   this.onMouseIn = function() {
      g_tooltip = window.CreateTooltip();
      g_tooltip.Text = this.tiptext;
      g_tooltip.Activate();
   }

   this.onMouseOut = function() {
      g_tooltip.Deactivate();
      g_tooltip.Dispose();
   }
}

function buttonsDraw(gr) {
   for (var i in Buttons) {
      Buttons.draw(gr);
   }
}

function buttonsTraceMouse(x, y) {
   var btn = null;
   for (var i in Buttons) {
      if (Buttons.traceMouse(x, y) && !btn)
         btn = Buttons;
   }
   return btn;
}


Re: JScript Panel

Reply #580
Code: [Select]
this.col_normal = btn_col && btn_col.normal ? btn_col.normal : null;

That looks suspect to me. A fallback for a colour should never be null. Any function expecting a colour argument would fail if you pass that to it.

There doesn't seem to be anything wrong with the rectangle code- it looks valid enough but that depends on the values of the args passed to it.

You can easily check all the values belonging to this like um.... this...

Code: [Select]
fb.ShowPopupMessage(JSON.stringify(this, null, 4));

If any of the top,left.width,height or colour args look suspect, now you know.

And of course g_tooltip should be created once outside the scope of any functions/objects and never disposed.

Re: JScript Panel

Reply #581
Thanks! I seem to have it working now. You're correct (of course) about the Fill line. That was not the culprit.


Re: JScript Panel

Reply #583
Works for me....



but of course I probably wasn't explicit enough about the need for sox and ffmpeg. I kind of assumed anyone who was going to use it had used previous versions I'd posted as standalone scripts.

These paths in the script need to point at valid files which you need to download and extract yourself.

Code: [Select]
var sox_exe = fb.ProfilePath + "sox\\sox.exe";
var ffmpeg_exe = fb.ProfilePath + "sox\\ffmpeg.exe";

I'll add some notes for the next version.

edit: links added here... https://github.com/marc2k3/foo_jscript_panel/commit/744e01658e1a398723a8d574057ce4e30029fdd5


Re: JScript Panel

Reply #585
https://github.com/marc2k3/foo_jscript_panel/releases

## v2.6.2.3
- The `JS Smooth Browser` filter box now supports proper `Media Library` queries.
- The filter box has been removed from `JS Smooth Playlist` as it was functionally useless. It's not possible to select/play from a filtered playlist without modifying playlist content which is beyond the scope of what any playlist viewer should do.
- `JS Smooth Playlist Manager` now has some new features added such as the ability to restore/purge deleted playlists, edit/remove playlist locks that belong to `JScript Panel` and playlists can be sorted by name. All options are available on the right click menu although may be hidden if the filter is active.

Re: JScript Panel

Reply #586
@Marc: thanks very much for your continuos great work on the 'smooth' samples!
A feature wish from my side for the JS Smooth Browser (jssb) would be to add at the 'columns' selection additional to 'Album' and 'Artist' (+ 'Genre' at the SMP version) the choice 'Album Artist'.

Re: JScript Panel

Reply #587
You might be better off using Library Tree for SMP in album art grid mode, That has more options than you can shake a stick at.

I just noticed that artist mode sorting in the latest version of JS Smooth Browser is utterly borked so I'll try and get a fix out sharpish. edit: nope, it's ok. I was testing something that was borked.

Re: JScript Panel

Reply #588
Thanks for the hint! Tried LIbrary Tree (for Album Artist) with jsplaylist-mod (which I definitely want to use as it got great features+look), which corresponds not as good as jssb/jsplaylist-mod, but its ok.
Old jssb script allowed straightforward own modification to get Artist->Album Artist, however for the new script I did not manage so far...

Re: JScript Panel

Reply #589
I'm testing jssb album artist support at the moment. Most of the code is utterly baffling to me and it's really hard to pick apart.... but I have fixed a lot of bugs in the last few days. The next release should be much better.

As for JSplaylist, people might not like the changes. I've really taken a machete to it and stripped out huge chunks.  :))

Re: JScript Panel

Reply #590
Great, thanks very much in advance, looking forward to both the album artist and the machete updates  :) .
I am currently mostly on SMP, so I would go back to JSP as I'd assume you are currently updating the JSP versions.


Re: JScript Panel

Reply #592
I've have a new beta version for testing. For existing users, all included samples are broken until reloaded from the `Samples` menu in the config window. You have been warned.

https://github.com/marc2k3/foo_jscript_panel/releases

edit: while messing around with Br3tt's scripts I did find a gnarly bug which I should remind people not to do. Do not build menus/use TrackPopupMenu inside a timer. This blocks timer execution across all panels and the same would happen if you spawned modal dialogs such as the ColourPicker so don't do that either!!

Re: JScript Panel

Reply #593
Quote
The MeasureStringInfo interface and associated gr.MeasureString method have been removed.
How replace it?

Re: JScript Panel

Reply #594
For a single line of text, you have the .Height property of whatever font you're using and you can use gr.CalcTextWidth("some _text", my_font) to determine the width.

For multiple lines of text, I'd really recommend using GdiDrawText over DrawString and then you'll get accurate results using gr.EstimateLineWrap. I can help if you have some code that needs updating.

Re: JScript Panel

Reply #595
Code: [Select]
function calc_lines(ctab) {
var i, j;
var padx = 0;
g_tab_length = 0;
for (i = 0; i < ctab.length; i++) {
// calc sentence #lines to display / window.width
if (ctab[i].type !== null) {
var tmp_img = gdi.CreateImage(ww - (H_PADDING * 2) - padx, 100);
var gp = tmp_img.GetGraphics();
var lineh = gp.MeasureString(ctab[i].text, g_font, 0, 0, ww - (H_PADDING * 2) - padx, wh).Height;
ctab[i].total_lines = (lineh / LINE_HEIGHT) > Math.floor(lineh / LINE_HEIGHT) ? Math.floor(lineh / LINE_HEIGHT) + 1 : Math.floor(lineh / LINE_HEIGHT);
ctab[i].ante_lines = 0;
for (j = 0; j < i; j++) {
ctab[i].ante_lines += ctab[j].total_lines;
}
CollectGarbage();
}
g_tab_length += ctab[i].total_lines;
}
return ctab;
}


Re: JScript Panel

Reply #596
I'm really confused as to what's going on there but maybe these lines...

Code: [Select]
			var lineh = gp.MeasureString(ctab[i].text, g_font, 0, 0, ww - (H_PADDING * 2) - padx, wh).Height;
ctab[i].total_lines = (lineh / LINE_HEIGHT) > Math.floor(lineh / LINE_HEIGHT) ? Math.floor(lineh / LINE_HEIGHT) + 1 : Math.floor(lineh / LINE_HEIGHT);

can be replaced with...

Code: [Select]
ctab[i].total_lines = gr.EstimateLineWrap(ctab[i].text, g_font, ww - (H_PADDING * 2) - padx).toArray().length / 2;

Re: JScript Panel

Reply #597
I can to mantain MovePlaylistSelection (word instruction) or simply replace it with MovePlaylistSelectionV2?
ty.


Re: JScript Panel

Reply #599
I'm really confused as to what's going on there but maybe these lines...

Code: [Select]
			var lineh = gp.MeasureString(ctab[i].text, g_font, 0, 0, ww - (H_PADDING * 2) - padx, wh).Height;
ctab[i].total_lines = (lineh / LINE_HEIGHT) > Math.floor(lineh / LINE_HEIGHT) ? Math.floor(lineh / LINE_HEIGHT) + 1 : Math.floor(lineh / LINE_HEIGHT);

can be replaced with...

Code: [Select]
ctab[i].total_lines = gr.EstimateLineWrap(ctab[i].text, g_font, ww - (H_PADDING * 2) - padx).toArray().length / 2;

I get error:
'gr' not is defined

not solve trying to add:
var _bmp = gdi.CreateImage(1, 1);
var _gr = _bmp.GetGraphics();

or

@import "%fb2k_component_path%samples\js\helpers.js"