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 143269 times) previous topic - next topic
0 Members and 4 Guests are viewing this topic.

Re: JScript Panel

Reply #801
gr.DrawImage(utils.LoadImage("o:\\1.jpg"),0,0,200,200,0,0,0,200);
A picture with zero size will invalidate all drawings.

Not sure what you mean?? If the image is not valid, utils.LoadImage should return null which should cause a script error.

If you unsure about an image existing or being valid then you should check it something like this...

Code: [Select]
var image = utils.LoadImage("o:\\1.jpg");

function on_paint(gr) {
    if (image) {
        gr.DrawImage(image,0,0,200,200,0,0,0,200);
    }
}

Image is valid.
gr.DrawImage(......, srcW, srcH);
When srcW or srcH equals 0, the script does not crash, but all drawings fail and the whole panel turn black.
By comparison, foo_jscript_panel3 and foo_jscript_panel perform differently. You can try it yourself.

Re: JScript Panel

Reply #802
Well the previous behaviour of silently ignoring idiotic bad arguments is just as bad as displaying a black panel so the next version will correctly throw script errors so everyone knows not to be so stupid. Thanks for reporting.

Re: JScript Panel

Reply #803
Well the previous behaviour of silently ignoring idiotic bad arguments is just as bad as displaying a black panel so the next version will correctly throw script errors so everyone knows not to be so stupid. Thanks for reporting.

I think 0 is a perfectly normal value, which is inevitable in many cases.
I remember there was a similar problem in Spider Monkey Panel. When you draw a rectangle, it crashes if the width or height is equal to 0. It's ridiculous. (Now it must have been repaired.)
In a natural process of change, the emergence of a natural number is not allowed.

Re: JScript Panel

Reply #804
Width or height of 0 is not normal in drawing, though. If either dimension is 0, the object is effectively not being drawn.

Re: JScript Panel

Reply #805
Width or height of 0 is not normal in drawing, though. If either dimension is 0, the object is effectively not being drawn.

As you said, a size of 0 means nothing is painted. (JScript Panel 2).
This is exactly what I want.

Re: JScript Panel

Reply #806
Then don't call the function? You do know you can conditionally not call something.

Re: JScript Panel

Reply #807
I've been setting a bad example in my own scripts by not checking the src width/height before drawing but the only way that could happen was if they were calculated from the panel width/height which would have to be zero and therefore not visible. Default UI won't even let you resize that low but I guess it's possible with Columns/Panel Stack Splitter.

Setting these args as zero when the panel has proper dimensions and is visible is just really stupid. If calling the function succeeded, what exactly do you expect to see??

I really hate doing it but I've updated the function to silently bail if the src w/h are bad,

https://github.com/marc2k3/jscript-panel/releases

edit: the difference in behaviour between v3 and previous versions is because I'm using Direct2D instead of Gdiplus. Gdiplus was generally very tolerant of bad args everywhere but it seems more care is needed now. I already have special conditions in place where drawing text isn't even attempted if the width/height are less than 12px. I discovered this quite early on in my testing!

Re: JScript Panel

Reply #808
gr.DrawRectangle(50, 50, 100, 100, 1, 0xffffffff);
Is my method wrong? I can't draw a line with a pixel width.
The minimum width is 2 pixels and the color is not correct.

Re: JScript Panel

Reply #809
Well I'm passing the args untouched to the windows APIs so not really sure what is going on there. You could try adding or subtracting 0.5 from the x and y values and see if that makes any difference??


Re: JScript Panel

Reply #810
Possibly relevant is the strokeWidth documentation here...

https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawrectangle(constd2d1_rect_f__id2d1brush_float_id2d1strokestyle)

Quote
The width of the stroke, in device-independent pixels. The value must be greater than or equal to 0.0f. If this parameter isn't specified, it defaults to 1.0f. The stroke is centered on the line.

Re: JScript Panel

Reply #811
on_mouse_mbtn_down
This callback function doesn't seem to work. (foo_jscript_panel3)

Re: JScript Panel

Reply #812
function on_mouse_leave() {
    console.log("on_mouse_leave");
}
function on_mouse_mbtn_down(x, y, mask) {
    console.log("on_mouse_mbtn_down" + "(" + x + ',' + y + ',' + mask + ")");
}
When I click the middle button, the console displays "on_mouse_leave".

Re: JScript Panel

Reply #813
Cannot reproduce that here. Your snippet works as expected.

Also the code for mouse handling is identical to JSP2 and this is the bit of code for mapping windows messages (WM_SOMETHING) in to which callback to call.

https://github.com/marc2k3/foo_jscript_panel/blob/5180a353c4d84525a0204ef18e6f86817170d4bf/src/Panel/CallbackID.h#L153

Nothing has changed.

Re: JScript Panel

Reply #814
Cannot reproduce that here. Your snippet works as expected.

Also the code for mouse handling is identical to JSP2 and this is the bit of code for mapping windows messages (WM_SOMETHING) in to which callback to call.

https://github.com/marc2k3/foo_jscript_panel/blob/5180a353c4d84525a0204ef18e6f86817170d4bf/src/Panel/CallbackID.h#L153

Nothing has changed.

It's my problem here. Everything's fine again.
I'm a little confused about what happened, but it doesn't matter.

Re: JScript Panel

Reply #815
v3.0.2 fixes a crash with the GoTo dialog in the Configuration Window.

https://github.com/marc2k3/jscript-panel/releases

A few samples have had had their rectangles tweaked as per a few posts up where you need to add 0.5 to the x/y co-ords if the line width is 1.

Re: JScript Panel

Reply #816
https://github.com/marc2k3/jscript-panel/releases

v3.0.3 fixes a JSplaylist state/mood column alignment bug.

edit: not mentioned in the changelog but JS Smooth Playlist Manager referenced a non existing file. While completely harmless, it did spam the console on startup. Existing users can select the updated script from the samples menu or delete this line manually from the preprocessor section at the top of the script....

Code: [Select]
// @import "%fb2k_component_path%samples\smooth\filterbox.js"

Re: JScript Panel

Reply #817
This should be the final release in the v2 series of JScript Panel (v2.8.8 )

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

I'll probably nuke the github repo soon but I'll make sure the download remains available.

Re: JScript Panel

Reply #818
I am using JS Smooth Browser (artists) together with JS Playlist (albums). Within JSP2, Smooth Browser had the nice feature that single-click on an artist gave the artists album selection in JS Playlist. Seems to be gone with JSP3 Smooth Browser (on my side), double-click selects (as in JSP2) the artists albums but directly plays the album. Any chance to enable this single-click feature as well in JSP3 JSSB, or am I missing something?

Re: JScript Panel

Reply #819
Yeah removing that was intentional and was mentioned in the changelog for v3...

https://marc2k3.github.io/jscript-panel/docs/changes/#sample-changes

Selfishly, I always hated that functionality and made it do what I use by default. I was too lazy to make options but I guess that's something to consider in future.

 

Re: JScript Panel

Reply #820
I'm not doing a component release just now but I've updated one file which you can download and test. Single click still only highlights but double click can be configured not to play...

https://raw.githubusercontent.com/marc2k3/jscript-panel/main/component/samples/smooth/jssb.js


Re: JScript Panel

Reply #821
Hello Marc, thanks very much, works perfect!! (as always)

Re: JScript Panel

Reply #822
Hi there, I've got an error when I customized my columns. - Unable to get property 'label' of undefined or null reference Line: 1131, Col: 5. Any ideas?

         
Quote
// Create TextBoxes
        var txtbox_value = p.list.groupby[listBoxCurrentId].label;
         this.elements.push(new oTextBox(1, txtbox_x, Math.ceil(cSettings.topBarHeight + rh * 4.5), ww - txtbox_x - 20 - this.scrollbarWidth, cHeaderBar.height, "Label", txtbox_value, "settings_textboxes_action", this.id));
         txtbox_value = p.list.groupby[listBoxCurrentId].tf;
         this.elements.push(new oTextBox(2, txtbox_x, Math.ceil(cSettings.topBarHeight + rh * 6.5), ww - txtbox_x - 20 - this.scrollbarWidth, cHeaderBar.height, "Title Format (enter 'null' for nothing)", txtbox_value, "settings_textboxes_action", this.id));
         txtbox_value = p.list.groupby[listBoxCurrentId].extraRows;
         this.elements.push(new oTextBox(3, txtbox_x, Math.ceil(cSettings.topBarHeight + rh * 8.75), 30, cHeaderBar.height, "Extra Rows To Add", txtbox_value, "settings_textboxes_action", this.id));

Re: JScript Panel

Reply #823
I can't reproduce the bug but from the error, it looks like adding/removing group presets was the issue rather than columns??

Anyway, I'll try and make it more robust for the next release.

If the error is preventing the script from even loading, right click the panel>Properties. Change the value of JSPLAYLIST.GROUPS.Pattern Index to 0.