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: WSH Panel Mod script discussion/help (Read 1404509 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #1075
...
@Falstaff, are you using the official WSH panel mod to do that playlist viewer or does it require a further modded version?


not the official one, because it still not provide the required API to do it, which are :

GetAnItem(index);
> Get a metadb handle of any item in the active playlist determined by it's position.

SetFocusedItem(index);
> Set the currently focused item in the active playlist.

SetSelectionSingle(index,selected);
> Set a track either selected or not. The selected parameter should be either true or false.

ClearSelection();
> Clear selection on the active playlist.

I hope T.P.Wang will add these features in the official one ASAP !

WSH Panel Mod script discussion/help

Reply #1076
So the rating works only for selected tracks? Is there a way to make it rate songs that are playing now?


you talk about my wsh playlist viewer? no, live rating always works, regardless of the status of the rated line (playing, selected, normal), check the video more accurately, i show that point

No i was talking about the original rating script from marc2003.

WSH Panel Mod script discussion/help

Reply #1077
add this function to the panel


Thank you. It's so simple I feel really dumb. I guess I should have read docs for WHS Panel Mod more carefully.

I have found a way to do it with on_metadb_changed() as in your rating panel but your solution is more appropriate.
Decalicatan Decalicatan

WSH Panel Mod script discussion/help

Reply #1078
No i was talking about the original rating script from marc2003.


add

Code: [Select]
selection_mode = 1;


along with the other variables near the top of the script. it will now stick with the playing track while playing but follow the selection when playback is stopped.

@Falstaff, ah right, i was just wondering. i'm far too lazy to attempt this myself.

WSH Panel Mod script discussion/help

Reply #1079
version 1.4.4 seem no longer support function gethwnd and CreateGlass?
So anyone show me other way to create aero glass?

WSH Panel Mod script discussion/help

Reply #1080
version 1.4.4 seem no longer support function gethwnd and CreateGlass?
So anyone show me other way to create aero glass?


it never supports these functions, maybe you have to use a non official version of WSH panel mod which provide these ones.

WSH Panel Mod script discussion/help

Reply #1081
I want to add a imagebutton to panel stack splitter to sort elplaylist by artist, which command can i use in COMMAND argument of $imagebutton function?

WSH Panel Mod script discussion/help

Reply #1082
wrong thread. what has any of that got to do with WSH panel mod? 

but to point you in the right direction, look at using CONTEXT, not COMMAND. it's all in the readme.

WSH Panel Mod script discussion/help

Reply #1083
i've spent bloody hours trying to make scrollbars for panels and it's almost working perfectly.... but my dilemma is that i'm using the height of the content to base my "grabber" size on. but now i'm trying to make a playlist and the grabber gets really small. i can't change the size artificially because it then messes up the maths need to calculate when to stop/start scrolling when dragging. i'm guessing i've approached this from entirely the wrong angle. i know other people have posted snippets before but they are too complex for me to implement in my script. any ideas on what i should have done.... 

WSH Panel Mod script discussion/help

Reply #1084
I have written a "Viewport" object with a vertical scrollbar (no horizontal scrollbar so far), based on my first scrollbar attempt (that was not an object).  The scrollbar is used to scroll a bitmap that is higher than the viewport.

I have exactly the same problem: when the bitmap is really big, the scrollbar's grabber becomes very small.  But there are also arrows in the top and bottom edges of the scrollbar, and the user cam also click on the "empty space" between the arrows and the grabber to scroll by a page at a time.  The keyboard and mouse wheel and drag can also be used to scroll the bitmap, so I haven't tried to solve the "grabber too small" issue.

I have used the viewport object in several panels (based on your Last.fm panels), but I have also modified completely the way they work, and they need a "global" panel to be notified of metadb or preferences changes.  I can't give them here as examples of my Viewport object, because they will not work alone.  I'll try to write a simple example when I'll have some time...

WSH Panel Mod script discussion/help

Reply #1085
i suppose i shouldn't really concern myself too much. it's highly unlikely this script will ever see the light of day anyway. i'm really happy with the way it works for normal panels - it's only with 1000+ tracks in a playlist that i have a problem.



edit: if anybody else uses the theme manager, i made this snippet to easily find the part and state id...

Code: [Select]
var test = window.CreateThemeManager("scrollbar");
var size = 30;

function on_paint(gr) {
    for(state = 0; state < 20; state++) {
        for(part = 0; part < 20; part++) {
            try {
                test.SetPartAndStateId(part, state);
                test.DrawThemeBackground(gr, state * size, part * size, size, size);
            } catch(e) {
            }
        }
    }
}


just change "scrollbar" to anything from this page: http://msdn.microsoft.com/en-us/library/wi...v=vs.85%29.aspx

now i can get the ID for what i want from this grid view.


WSH Panel Mod script discussion/help

Reply #1086

I made a WSH graphical browser.
The scroll bar is simple but effective enough.
mad messy misanthropist morbid mused

WSH Panel Mod script discussion/help

Reply #1087
@ marc2003, how can i change the font to your simple biography panel? i would like to switch to arial 8pt.

WSH Panel Mod script discussion/help

Reply #1088
anywhere at the top of the script before on_item_focus_change();

Code: [Select]
normal_font = gdi.Font("Arial", 8);


to change the font of the stats display, use

Code: [Select]
list_font = .....


and for the artist header at the top..

Code: [Select]
title_font = gdi.font("super font", 16, 1);


add the 1 if you want to make it bold.

WSH Panel Mod script discussion/help

Reply #1089
Thank you

WSH Panel Mod script discussion/help

Reply #1090
how do i use on_metadb_changed() with a handle list? i've looked at the callback and preprocessor docs and i can't make any sense of it at all. 

WSH Panel Mod script discussion/help

Reply #1091
Marc, I've found a solution for the problem of the scrollbar grabber too small.  It is extremely simple, and I have had to add only 3 lines of code.

I'll try top explain my method with a vertical scrollbar example:
Code: [Select]
---- y1: top of the scrollbar
Up button
---- y2: top of the area containing the grabber (The height of that area is in the variable "ah")

---- y3: top of the grabber

The grabber (Its height is in the variable "gh".  It should be minimum 16.)

---- y4: bottom of the grabber


---- y5: bottom of the area containing the grabber
Down button
---- y6: bottom of the scrollbar

I suppose that, like me, you know the height of the portion of the scrollbar that is between the up and down buttons and that contains the grabber (ah, or y5-y2) and the height of the grabber (gh or y4-y3).  gh is computed relatively to ah, to the height of the window (or viewport in my case) and to the total height of the data to display.  The problem happens when the latter is too large relatively to the height of the window.

In my method, it's always the top border of the grabber (at y3) that determines the position of the data to display.
So, if y3 == y2, the first line of the data is shown on top of the display.
Similarly, if y4 == y5, the bottom line is shown on the bottom of the window.  In this case, y3 = y5 - gh.

What I do to solve the problem is this:
When gh is computed, there can be two cases:
1: its height >= 16, and in that case, there is no problem.
2: its height is < 16.  It is too small, so we must enlarge it.  I force it to 16.  But of course, if you move the grabber to the very bottom of the scrollbar, it will be drawn partially over the down button.  To avoid that, it is sufficient to shrink the area containing the grabber (ah).
Code: [Select]
        if (gh < 16) {
            ah -= 16 - gh;
            gh = 16;
        }

Now, if you move the grabber to the bottom, it will stop just where it should, and all computations based on the position of the top of the grabber and the height of the area are still correct.

The thing to understand is that the height of the area in which the grabber can move does not have to be the height of the area containing the grabber.  It can be smaller by a few pixels, and the grabber larger by that same number of pixels.

(In fact, there are still some problems to solve.  For example, if the total height of the scrollbar is less than the height of the two buttons + 16 + some space to move the grabber, you have to draw the small grabber, or remove it completely and keep only the up and down arrows.  But that's cosmetic stuff, simple enough to solve.)

If your method is similar than mine, you should be able to fix your code easily.  Good luck!

WSH Panel Mod script discussion/help

Reply #1092
thanks for that. it's always something simple.

edit: oops appearances can be deceiving - i might still have a problem. false alarm - scrolling works perfectly even with 100,000 items - it's my mouse click code that is broken. 

WSH Panel Mod script discussion/help

Reply #1093
Well, I had also some things somewhat broken, but it's perfect now.  :-)

BTW, I have another problem.  My viewport object is defined in an include file, and it is supposed to be easily reusable in any WSH panel. But it is not easy to handle the callbacks.  For example, the scrollbar must be notified of mouse clicks and moves.  But if, for any reason (for example if there are buttons in the panel), the panel needs also that information, the main code must also define the on_mouse_...() functions.  So, the viewport object cannot steal them for its own use.

Currently, the object has on_mouse methods, and it is the responsibility of the main code to call them.  The object's method returns false when it has used the event (for example, when the user has clicked on the scrollbar), so it is relatively easy to handle the remaining events in the WSH panel.  But I'm not satisfied by that method, mainly because it is necessary to define the callbacks needed by the scrollbar in the main code, even if it doesn't need that callbacks for its own use, just to pass them to the main code.

I've tried to do the opposite: define the callback functions in the include, then pass the events to the object, and if they have not been used, call a function with a similar but somewhat different name in the main code (with try/catch so that the code will not fail if the function is not defined).  But I don't like that method either, as it is necessary to define the callback functions if the include, and they cannot be methods of the object.  Furthermore, it is necessary to define the callbacks in the main code with different names than the official ones.  Also, it is difficult to define several viewports in the same panel.

I wonder if there is a better method.  As far as I know, there is no way to receive the same callback info in the object and in the main code, without having to call one from the other.  Right?

Is it possible to define the same callback twice?  I could for example define the callbacks in the include, and they will be overwritten later if the main code redefine them (and in that case, of course, they will need to call the corresponding object methods).  So, if the main code doesn't need a callback, it will not need to define it.  But I don't know if it's possible.

How did you solve that problem?  Do you write a single callback function where you do the stuff necessary to handle the events necessary for the scrollbar as well as any other events your panel may need?

(I hope I am clear enough.  English is not my native language, and here in Belgium, it is late!)

 

WSH Panel Mod script discussion/help

Reply #1094
Quote
Currently, the object has on_mouse methods, and it is the responsibility of the main code to call them. The object's method returns false when it has used the event (for example, when the user has clicked on the scrollbar), so it is relatively easy to handle the remaining events in the WSH panel. But I'm not satisfied by that method, mainly because it is necessary to define the callbacks needed by the scrollbar in the main code, even if it doesn't need that callbacks for its own use, just to pass them to the main code.


i use true like this...

Code: [Select]
function on_mouse_lbtn_up(x, y) {
    switch(true) {
        case obj1.trace(x, y):
            obj1.click(x, y);
            break;
        case obj2.trace(x, y):
            obj2.click(x, y);
            break;
        case ..... //neither of those objects was clicked so let's check something else....
    }
}


Quote
I've tried to do the opposite: define the callback functions in the include, then pass the events to the object, and if they have not been used, call a function with a similar but somewhat different name in the main code (with try/catch so that the code will not fail if the function is not defined).


i don't like this idea at all. i definitely prefer the proper callbacks in the panels themselves. i think it makes maintenance easier and gives you more flexibility to make changes.

as for duplicating functions, that's certainly possible as i discovered by mistake. if you declare them multiple times, only the last one gets called.
Code: [Select]
function test(a, b) {
    return a + b;
}

function test(a, b) {
    return a * b;
}

fb.trace(test(5, 5)); //displays 25 in the console


i can't say i'm keen on this idea either but i'm not particularly fussy. so long as stuff works, there is no impact on performance and it doesn't crash - that's good enough.



WSH Panel Mod script discussion/help

Reply #1096
i use true like this...
I see.  But your method implies that the code to handle the scrollbar and the code to handle the other things is in the same function.  I really want to keep the viewport/scrollbar as independent as possible.  So, I prefer this:
Code: [Select]
        if ( ! viewportobj.on_mouse_lbtn_up(x, y) ) {
                // main script stuff here...
                obj2.click(x, y);
        }
Of course, I can use switch/case too.

as for duplicating functions, that's certainly possible as i discovered by mistake. if you declare them multiple times, only the last one gets called.
[...]
i can't say i'm keen on this idea either but i'm not particularly fussy. so long as stuff works, there is no impact on performance and it doesn't crash - that's good enough.
That's great to know.  I suspected something like that.  (I could have written the test myself BTW!)

I think I will adopt that method, and add the callbacks necessary for the toolbar in the include.  If the main code doesn't need a callback, it will not need to define it, as it will already be defined in the include.  Otherwise, the callback code can be copied from the include to the main script and modified to suit the panel's needs.  That will keep the main script easier to maintain and read.

Thanks!

WSH Panel Mod script discussion/help

Reply #1097
as for duplicating functions, that's certainly possible as i discovered by mistake. if you declare them multiple times, only the last one gets called.
Code: [Select]
...

i can't say i'm keen on this idea either but i'm not particularly fussy. so long as stuff works, there is no impact on performance and it doesn't crash - that's good enough.

You might consider using the prototypal inheritance capabilities of JS for such cases:

http://javascript.crockford.com/prototypal.html
http://www.ruzee.com/blog/2008/12/javascri...es-and-closures

WSH Panel Mod script discussion/help

Reply #1098
thanks for the links. now let's see if i can i understand them. 

I really want to keep the viewport/scrollbar as independent as possible.


my scrollbar is quite separate from my content. in on_paint, the position of the grabber is determined by the position in my array of items of where i want to start looping. if i have 100 items but only room for 10 rows and i want to display the last 10, i'll be starting at 90.

Code: [Select]
sbh = wh - 34; //scrollable height
gh = Math.floor(sbh * (rows / items)); //grabber height
gy = Math.floor((sbh / items) * offset[plman.ActivePlaylist]); y-cordinate of grabber. i'll add 17 when drawing to account for the up arrow


but if the scrollbar is being dragged, i need to reverse that and set the offset based on the position of the grabber. it's only a few lines in each case so i haven't even bothered making it reusable.