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 294577 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: JScript Panel

Reply #776
Beta.5 updates utils.LoadSVG to accept a file path or XML text that you might have read/manipulated via script first. Previously, it supported file paths only.

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

Re: JScript Panel

Reply #777
Replacement for:
gb.SetTextRenderingHint(4);
window.GetColourDUI(1);
window.GetColorCUI(3);

Re: JScript Panel

Reply #778
SetTextRenderingHint is not needed because DrawString no longer exists. It's been replaced by WriteText.

https://marc2k3.github.io/jscript-panel/docs/interfaces/IJSGraphics/#writetexttext-font-colour-x-y-w-h-text_alignment-paragraph_alignment-word_wrapping

window.GetColourDUI / window.GetColorCUI have not changed. If you're getting errors from one or the other, it's probably because you haven't replaced window.InstanceType with window.IsDefaultUI.

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

Re: JScript Panel

Reply #779
Hey Mark, I've been rewriting some of my code to use jscript3 and I noticed that the behavior of window.SetCursor is a bit different, were there any changes to this?

For example:

Code: [Select]
if (y < 40) {
    window.SetCursor(32649);
} else {
    window.SetCursor(32512);
}

The hand cursor flickers when I move the mouse and when I click, it changes to the default cursor.

Another example (var "u" are the coordinates of the album art inside the panel):

Code: [Select]
 if (this.isHover != u) {
    if (u) {
        window.SetCursor(32649);
    } else {
        window.SetCursor(32512);
    }
}

This works perfectly fine on jscript 2.8.5, but on v3 the hand cursor appears for a split second and then it changes to the normal cursor.

Thanks for your help!

Re: JScript Panel

Reply #780
That works in Default UI:
Code: [Select]
var dui = window.IsDefaultUI;
Code: [Select]
gr.FillRectangle(0, 0, window.Width, window.Height, dui == 1 ? window.GetColourDUI(1) : window.GetColourCUI(3));


Re: JScript Panel

Reply #782
I see the perils of removing properties now...

InstanceType was a number in JSP v2 and even though it's been removed in JSP v3, it won't throw an error because it's a property. It will be undefined which means if(window.InstanceType) or if(window.InstanceType == 1) won't throw errors but they will never evaluate to true either.

The new window.IsDefaultUI is a boolean property but thanks to JS being what it is....

Code: [Select]
// using Default UI
console.log(window.IsDefaultUI == 1); // true
console.log(window.IsDefaultUI === 1); // false


Re: JScript Panel

Reply #783
Code: [Select]
function on_load_image_done(tid, image, image_path){
if(image){
g_img = image;
g_img2 = g_img.ApplyAlpha(170);
}
}
ApplyAlpha?

Code: [Select]
	var temp_bmp = utils.CreateImage(1, 1),
temp_gr = temp_bmp.GetGraphics();
textheight = temp_gr.CalcTextHeight(g_text, g_font)*g_text.count(/([\r\n]|\. )/g,1)*3;
CalcTextHeight?

Code: [Select]
		var gp = tmp_img.GetGraphics();
ctab[i].total_lines = gp.EstimateLineWrap(ctab[i].text, g_font, ww - (H_PADDING * 2) - padx).toArray().length;
EstimateLineWrap?

 

Re: JScript Panel

Reply #784
Just give it up. This clearly is not for you.

I've written extensive documentation for all new methods with examples. Admittedly I've not lined up each and every replacement but you'd have a good idea what to do if you actually read it all.


Re: JScript Panel

Reply #786
I've just added a section on callback changes which was my fault for not including before.

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

Looks at utils.CreateTextLayout / gr.WriteTextLayout for rendering large chunks of text with multiple lines/getting the height.

Re: JScript Panel

Reply #787
Whilst not entirely complete, here's a side by side diff of the main API differences....

https://gist.github.com/marc2k3/4503b25ca3d551264fff95c3387f2d17/revisions?diff=split

Most of the fb removals have replacements detailed here...

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

Re: JScript Panel

Reply #788
edit: Beta.7 was released then pulled because I didn't test a feature properly. Before anyone says it, yes I'm a twonk.
edit2: Beta.6 has been restored to the releases page


Re: JScript Panel

Reply #790
Can you add a function to control the display of various components on the window, like wsh_panel_mod_plus.

Re: JScript Panel

Reply #791
If you're thinking of  showing/hiding like Panel Stack Splitter then no.

---

Beta.9 has no component changes. I've just updated the thumbs sample with a circular option. This is for the strip only, the main image display is unchanged.

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

edit: also adding a reminder that thumbs supports these additional image types if you have the necessary extensions installed from the windows 10/11 store: webp, heic, avif

Re: JScript Panel

Reply #792
Thanks for the cursor fix! It works fine now.

Is there a way to make WriteText not add end ellipsis when using DWRITE_WORD_WRAPPING_NO_WRAP?

I'm rewriting my search bars and in jscript2 I could play around with no end ellipsis and text alignment to make the text align to the right when the string is longer than the search bar, but in jscript3 it adds ellipsis and it becomes confusing.

I'm not sure if I can explain it properly, but the text is not being pushed to the left when I set it to align right, it does align it but when it becomes bigger than the text box, it just adds ellipsis to the overflowing text.

Pictures and code to make it clear:

JScript2:
Code: [Select]
var inputWidth = gr.CalcTextWidth(this.input, FONT);

if (inputWidth > this.w - this.h - 10) {
    var inputAlign = 0x00000826;
} else {
    var inputAlign = 0x00000824;
}

gr.GdiDrawText(this.input, FONT, this.color, this.x + 10, this.y, this.w - this.h - 10, this.h, inputAlign);

X

Code: [Select]
this.InputWidth = utils.CalcTextWidth(this.Input, "Lato", panel.FontSize, 700);

if (this.InputWidth > this.W - this.H - 10) {
    this.InputAlign = 1;
} else {
    this.InputAlign = 0;
}

gr.WriteText(this.Input, this.Font, this.Color, this.X + 10, this.Y, this.W - this.H - 10, this.H, this.InputAlign, 2, 1);

X

Is CalcTextWidth trimming the input? Because when I write a space character in the search bar, it does not move the cursor to reflect the space character until I write any other character, which wasn't the case in jscript2.

Sorry to bring all this up, if not possible to change, I will implement workarounds to try to maintain previous behaviour.

Thanks!

Re: JScript Panel

Reply #793
These are definitely bugs that need fixing. Thanks for spotting.  8)

WriteText will need another argument to make end ellipsis optional instead of being implied by setting DWRITE_WORD_WRAPPING_NO_WRAP.

The CalcTextWidth not including trailing whitespace is just a straight up bug by me using width instead of widthIncludingTrailingWhitespace from this API...

https://docs.microsoft.com/en-us/windows/win32/api/dwrite/ns-dwrite-dwrite_text_metrics

Re: JScript Panel

Reply #794
Beta.10 should address these issues.

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

End ellipsis are no longer implied by using DWRITE_WORD_WRAPPING_NO_WRAP and the new DWRITE_TRIMMING_GRANULARITY must be used if you want it.


Re: JScript Panel

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



Re: JScript Panel

Reply #799
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);
    }
}