window
Functions for working with the current JSplitter panel and accessing it's properties.
Functions for working with the current JSplitter panel and accessing it's properties.
DlgCode
Indicates which keys should be processed by the panel.
See https://docs.microsoft.com/en-us/windows/desktop/dlgbox/wm-getdlgcode for more info.
number — See Flags for flags like DLGC_WANTARROWS
window.DlgCode = DLGC_WANTALLKEYS;
DPI: number
Window DPI. This value never changes while foobar2000 is running. If you change DPI settings, you must restart the application.
DrawMode: number = 0
Current graphics rendering mode.
0 (default) - GDI+
1 - Direct2D
IMPORTANT: After switching the rendering mode, all drawing objects created for the other mode will be unavailable for use in the current mode.
Therefore, the developer should create all drawing objects only after changing the mode.
Ideally, the mode change should be made in the VERY first line of the main script to avoid accidentally creating objects of the wrong type.
Also, calling any of d2d.* methods for creating objects like fonts, bitmaps or effects, will cause a script crash until the DrawMode is set to 1 at least once (in this case, the resources required for D2D operation are initialized).
EraseOnRepaint: boolean = true
Set whether the JSplitter panel should be cleared with background color before raising on_paint callback.
Default value: true.
"use strict";
window.DrawMode = 0;
window.EraseOnRepaint = false;
let ww = 0;
let wh = 0;
const alphabet = 'アァカサタナハマヤャラワガザダバパイィキシチニヒミリヰギジヂビピウゥクスツヌフムユュルグズブヅプエェケセテネヘメレヱゲゼデベペオォコソトノホモヨョロヲゴゾドボポヴッンABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%&*';
const fontSize = 16;
const font = gdi.Font("Consolas", fontSize, 1);
const drops = [];
function on_size(width, height) {
ww = width;
wh = height;
if(ww > 0 && wh > 0) {
const columns = Math.floor(ww / fontSize);
drops.length = columns;
for (let i = 0; i < columns; i++) if (isNaN(drops[i])) drops[i] = 0;
}
}
function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, 0x0D000000);
for (let i = 0; i < drops.length; i++) {
const text = alphabet.charAt(Math.floor(Math.random() * alphabet.length));
const x = i * fontSize;
const y = drops[i] * fontSize;
gr.GdiDrawText(text, font, 0xFF00FF00, x, y, fontSize, fontSize * 4 / 3);
if (y > wh && Math.random() > 0.975)
drops[i] = 0;
else
drops[i]++;
}
}
window.SetInterval(() => { window.Repaint(); }, 50);
FoobarWindowHeight: number = 0
Change height of main foobar2000 window
FoobarWindowWidth: number = 0
Change width of main foobar2000 window
FoobarWindowX: number = 0
Change X position of main foobar2000 window
FoobarWindowY: number = 0
Change Y position of main foobar2000 window
HandOnButtons: boolean = false
Switches the mouse cursor for all buttons either to the hand or to the arrow. This property also affects all subsequently created buttons. This property can be changed individually for each button (see ButtonObject class).
Height: number
ID: number
Window handle
InstanceType: number
You need this to determine which GetFontXXX and GetColourXXX methods to use, assuming you want to support both interfaces.
See UIInstanceType
0 - if using Columns UI
1 - if using default UI.
IsTransparent: boolean
Only useful within Panel Stack Splitter (Columns UI component)
Depends on setting inside Spider Monkey Panel Configuration window. You generally use it to determine whether or not to draw a background.
IsVisible: boolean
JsMemoryStats: JsMemoryStats
Get memory statistics for JavaScript engine.
MaxHeight: number
window.MaxHeight, window.MaxWidth, window.MinHeight and window.MinWidth can be used to lock the panel size.
Do not use if panels are contained within Panel Stack Splitter (Columns UI component) or JSplitter itself
MaxWidth: number
See window.MaxHeight.
MemoryLimit: number
Maximum allowed memory usage for the component (in bytes).
If the total memory usage exceeds this value, all panels will fail with OOM error.
Deprecated: use window.JsMemoryStats.TotalMemoryLimit instead.
MinHeight: number
See window.MaxHeight.
MinWidth: number
See window.MaxHeight.
Name: string
Returns the panel name set in window.ShowConfigureV2.
PanelMemoryUsage: number
Memory usage of the current panel (in bytes).
Deprecated: use JsMemoryStats.MemoryUsage instead.
ScriptInfo: ScriptInfo
Information about the panel script.
Tooltip: FbTooltip
Get associated tooltip object.
TotalMemoryUsage: number
Total memory usage of all panels (in bytes).
Deprecated: use window.JsMemoryStats.TotalMemoryUsage instead.
TrackMouseEnterLeaveOnPanels: boolean = false
Enables tracking of the mouse cursor entering/exiting the panel area. By default = false.
The following functions are used to handle events:
on_panel_mouse_enter(name) - cursor entering the panel area, name is the panel name
on_panel_mouse_leave(name) - cursor leaving the panel area, name is the panel name
TrackMouseMoveOnPanels: boolean = false
Enables tracking of the mouse cursor position within the panel area.
By default = false . The following function is used to handle the event:
on_panel_mouse_move(name, x, y, mask): the event of moving the cursor within the panel area, name is the name of the panel, x, y are the coordinates of the point on the panel.
Width: number
ClearInterval(timerID)
See clearInterval.
| Name | Type | Description |
|---|---|---|
timerID | number |
ClearProperties(reload_panel)
Clears all current panel properties set by window.SetProperty, window.SetProperties or window.ImportProperties
| Name | Type | Description |
|---|---|---|
reload_panel = falseoptional | boolean | If true, reloads panel script after clearing |
ClearTimeout(timerID)
See clearTimeout.
| Name | Type | Description |
|---|---|---|
timerID | number |
CreateButton(x, y, images, hover_images)
Creates a button in the splitter. The button will be created in the root of the window and will be placed at the coordinates (x, y). The function is also passed images to set the appearance of the button. The number of states the button can take will depend on the number of images passed to the function. hover_images - button images displayed when the mouse cursor hovers over the button. The function is flexible enough to create different types of buttons
| Name | Type | Description |
|---|---|---|
x | string | |
y | string | |
images | * | // null, string or Array |
hover_images = nulloptional | * | // null, string or Array |
var path = fb.FoobarPath + "themes\\lur\\black\\bio.png";
var hpath = fb.FoobarPath + "themes\\lur\\black\\bio_on.png";
// Creates a regular button with the bio.png image, which changes to bio_on.png when the mouse cursor hovers over the button
var a = window.CreateButton(0, 0, path, hpath);
// Creates a checkbox button. The normal state is bio.png, pressed (checkbox checked) - bio_on.png.
// Note that there are no images for hovering over.
// Usually, checkboxes do not need them, but you can set them if you want.
var b = window.CreateButton(0, 0, [path, hpath], null);
// You can create a button with three (or more) states. They will switch cyclically when pressed.
// The current state of the button can be obtained using the State property of the button (see ButtonObject class).
var c = window.CreateButton(0, 0, [path1, path2, path3], [path1_on, path2_on, path3_on]);
CreatePopupMenu()
CreateThemeManager(class_id)
| Name | Type | Description |
|---|---|---|
class_id | string | https://docs.microsoft.com/en-us/windows/win32/controls/parts-and-states |
CreateTooltip(font_name, font_size_px, font_style)
Note: a single panel can have only a single tooltip object. Creating a new tooltip will replace the previous one.
Deprecated: use window.Tooltip and SetFont instead.
| Name | Type | Description |
|---|---|---|
[font_name='Segoeoptional | string | UI'] |
font_size_px = 12optional | number | |
font_style = 0optional | number | See FontStyle flags |
DefinePanel(name, options)
Setups panel and script information and available features.
Can be called only once, so it's better to define it directly in the panel Configure menu.
Deprecated: use window.DefineScript instead. Panel name can be changed via window.ShowConfigureV2.
| Name | Type | Description |
|---|---|---|
name | string | Script name and panel name |
options = {}optional | object | |
options.author = ''optional | string | Script author |
options.version = ''optional | string | Script version |
options.features = undefinedoptional | object | Additional script features |
options.features.drag_n_drop = falseoptional | boolean | Indicates if drag_n_drop functionality should be enabled |
DefineScript(name, options)
Setup the script information.
Can be called only once for the whole panel.
| Name | Type | Description |
|---|---|---|
name | string | Script name |
options = {}optional | object | |
options.author = ''optional | string | Script author |
options.version = ''optional | string | Script version |
options.features = undefinedoptional | object | Additional script features |
options.features.drag_n_drop = falseoptional | boolean | Indicates if drag_n_drop functionality should be enabled |
options.features.grab_focus = trueoptional | boolean | Indicates if panel should grab mouse focus |
EditScript()
Open the current panel script in the default text editor.
Default text editor can be changed via Edit button on the main tab of window.ShowConfigureV2.
ExportProperties(fileName)
Exports all current panel properties set by window.SetProperty to file
| Name | Type | Description |
|---|---|---|
fileName | string |
boolean — If false, then an error occurred during export
GetButton(id)
Get a button by its ID
| Name | Type | Description |
|---|---|---|
id | number |
GetColourCUI(type, client_guid)
| Name | Type | Description |
|---|---|---|
type | number | See ColourTypeCUI enum |
client_guidoptional | string | Client GUID |
number — returns black colour if the requested one is not available.
GetColourDUI(type)
| Name | Type | Description |
|---|---|---|
type | number | See ColourTypeDUI enum |
number — returns black colour if the requested one is not available.
GetFontCUI(type, client_guid)
Note: see the example in window.GetFontDUI.
| Name | Type | Description |
|---|---|---|
type | number | See FontTypeCUI enum |
client_guidoptional | string | Client GUID |
?GdiFont — returns null if the requested font was not found.
GetFontDUI(type)
| Name | Type | Description |
|---|---|---|
type | number | See FontTypeDUI enum |
?GdiFont — returns null if the requested font was not found.
// To avoid errors when trying to use the font or access its properties, you
// should use code something like this...
let font = window.GetFontDUI(0);
if (!font) {
console.log("Unable to determine your default font. Using Segoe UI instead.");
font = gdi.Font("Segoe UI", 12);
}
GetPanel(caption)
Get an object for accessing the panel by the caption text. The first panel that matches the argument in text will be returned. The panel text is specified in the caption. By default, it has the value of the panel plugin name, but it can be changed either directly in the window title (Show coords -> Click in caption text) or in the Columns UI placer (Use custom title) or in 'Panel list' (right click on JSplitter window)
| Name | Type | Description |
|---|---|---|
caption | string |
GetPanelByIndex(index)
Get an object for accessing the panel by index. the order depends on the position in the window stack: the bottommost window will have index 0.
| Name | Type | Description |
|---|---|---|
index | number |
GetPanelCount()
Get child panels count in JSplitter
numberGetProperties()
Get all current panel properties set by window.SetProperty, window.SetProperties or window.ImportProperties
Map — Map of panel properties
const props = window.GetProperties();
for(const [key, value] of props) console.log(`Key = ${key}, Value = ${value}`);
GetProperty(name, default_val)
Get value of property.
If property does not exist and default_val is not undefined and not null, it will be created with the value of default_val.
Note: leading and trailing whitespace are removed from property name.
| Name | Type | Description |
|---|---|---|
name | string | |
default_valoptional | * |
*ImportProperties(fileName, reload_panel)
Imports panel properties from file and (optionally) reloads the panel script
DOES clear all existing panel properties.
| Name | Type | Description |
|---|---|---|
fileName | string | |
reload_panel = falseoptional | boolean | If true, reloads panel script |
boolean — If false, then an error occurred during import. Also, if an error occurs during import, the panel does not reload.
NotifyOthers(name, info)
This will trigger on_notify_data(name, info) in other panels.
!!! Beware !!!: data passed via info argument must NOT be used or modified in the source panel after invoking this method.
| Name | Type | Description |
|---|---|---|
name | string | |
info | * |
let data = {
// some data
};
window.NotifyOthers('have_some_data', data);
data = null; // stop using the object immediately
// AddSomeAdditionalValues(data); // don't try to modify it, since it will affect the object in the other panel as well
RadioButtons(buttons)
Creates a group of radio buttons. Takes an array of buttons as an argument. Each button must have at least two states, otherwise the function will fail.
| Name | Type | Description |
|---|---|---|
buttons | Array<ButtonObject> |
var a = window.CreateButton(0 , 0, [path, hpath], null);
var b = window.CreateButton(30 ,0 , [path, hpath], null);
var c = window.CreateButton(60 ,0 , [path, hpath], null);
window.RadioButtons([a, b, c]);
// Now when you click on one button (state 1), the other will be switch to state 0 and vice versa.
Reload(clear_properties)
Reloads panel.
| Name | Type | Description |
|---|---|---|
clear_properties = falseoptional | boolean | If true, all panel properties will be cleared before reload |
RemoveButton(button)
Removes a button
| Name | Type | Description |
|---|---|---|
button | ButtonObject |
Repaint(force)
Performance note: don't force the repaint unless it's really necessary - repaint calls might be grouped up when *not forced* which will turn them into a single repaint call, thus reducing the amount of on_paint calls.
| Name | Type | Description |
|---|---|---|
force = falseoptional | boolean | If true, will repaint immediately, otherwise a repaint task will be *scheduled*. |
RepaintRect(x, y, w, h, force)
Repaints a part of the screen.
Use this instead of window.Repaint on frequently updated areas such as time, bitrate, seekbar, etc.
Performance note: see Performance note in window.Repaint.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
w | number | |
h | number | |
force = falseoptional | boolean | If true, will repaint immediately, otherwise a repaint task will be *scheduled*. |
SetCursor(id)
This would usually be used inside the on_mouse_move callback.
Use -1 if you want to hide the cursor.
SetInterval(func, delay)
See setInterval.
| Name | Type | Description |
|---|---|---|
func | function() | |
delay | number |
numberSetProperties(values, reload_panel)
Set panel properties from input map and (optionally) reloads the panel script
Does NOT clear existing properties before setting.
| Name | Type | Description |
|---|---|---|
values | Map | Map of values to set |
reload_panel = falseoptional | reload_panel | If true, reloads panel script after setting |
const values = new Map([["First value", 1], ["Second value", 2], ["Third value", 3]]);
window.SetProperties(values);
SetProperty(name, val)
Set property value.
Property will be removed, if val is undefined or null.
Property values are saved per panel instance and are remembered between foobar2000 restarts.
Note: leading and trailing whitespace are removed from property name.
| Name | Type | Description |
|---|---|---|
name | string | |
valoptional | * |
SetShortcutFilter(enabled, type_only, suppress_children)
Sets panel shortcut filter.
| Name | Type | Description |
|---|---|---|
enabled = trueoptional | boolean | If true filter is enabled. Suppresses player shortcuts depending on the following two parameters |
type_only = trueoptional | boolean | If true suppresses only shortcuts that identified as user input (keyboard_shortcut_manager::is_typing_message from SDK used). If false ALL shortcuts are disabled for panel |
suppress_children = falseoptional | boolean | If true suppresses also shortcuts for all JSplitter's children. Takes into account the parameter type_only only for DUI. For CUI alwas disables ALL shortcuts |
SetTimeout(func, delay)
See setTimeout.
| Name | Type | Description |
|---|---|---|
func | function() | |
delay | number |
numberShowConfigure()
Show configuration window of current panel.
Deprecated: use window.ShowConfigureV2 to configure panel and window.EditScript to edit script.
ShowConfigureV2()
Show configuration window of current panel
ShowProperties()
Show properties window of current panel