PresetBrowser LAF Scrollbar
-
Is it possible to style the scrollbar inside the preset browser or is there a specific LAF for scrollbars?
thanks in advance!
-
@oskarsh
drawScrollbar
;) -
@oskarsh oh these icons look super clean! I have to learn how to replace my text. Is this made with the
drawDialogButton
?
-
@d-healey thanks David looks much better know!
@Straticah yes for the buttons I use
drawDialogButton
it looks something like thislaf.registerFunction("drawDialogButton", function(g, obj){ var WIDTH = 20; var PADDING = 2; var a = obj.area; var pa = [ (a[2] / 2 - WIDTH / 2) + PADDING, (a[3] / 2 - WIDTH / 2) , WIDTH, a[3] - PADDING * 2 ]; if (obj.text == 'Add') { g.drawPath(Paths.icons['add'], pa, 3); return; } if (obj.text == 'Rename') { g.fillPath(Paths.icons['edit'], pa); return; } if (obj.text == 'Delete') { g.drawPath(Paths.icons['delete'], pa, 2); return; }
-
@oskarsh Here's a shortcut.
var editButtons = ["Add", "Rename", "Delete"]; if (editButtons.contains(obj.text)) { var icons = ["add", "edit", "trash"]; var path = Paths.icons[icons[editButtons.indexOf(obj.text)]]; g.drawPath(paths, pa, 3); }
-
@oskarsh said in PresetBrowser LAF Scrollbar:
@d-healey thanks David looks much better know!
oh this looks amazing can you share how you used the drawScrollbar ? Havent tried myself and i am fairly new and a complete noob but i will try when i get home :)
-
@Straticah Almost all look and feel functions are the same. Use
Console.print(trace(obj));
within the function to see what data it provides. Once you know one you pretty much know all (there are some exceptions). -
@d-healey oh i did not know that, might have a look!
-
@d-healey the hero we need! Makes this code much cleaner. Thanks a lot!
@Straticah there is a small exception for the scrollbars you useobj.handle
for the actual handle area instead of the usualobj.area
.const SCROLLBAR_PADDING = 5; laf.registerFunction('drawScrollbar', function(g, obj) { var a = obj.handle; var pa = [ a[0] + SCROLLBAR_PADDING, a[1] + SCROLLBAR_PADDING, a[2] - SCROLLBAR_PADDING * 2, a[3] - SCROLLBAR_PADDING * 2, ]; g.setColour(Colours.grey); g.fillRoundedRectangle(pa, 5); });
-
@oskarsh works nicely, thanks! Have added some hover and down entries
HiseSnipp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Pn6N9uIVUcGpr2leVnx+ArkpwDO
-
@DanH thats cool, thanks :) Just noticed its my browser template you are using lol :D
-
@Straticah yea I loaded that snippet earlier and it was still open on my laptop so started playing around with the scroll bars too!
-
@DanH i see :) maybe i have a template soon that is so good that ppl actually use it :D currently trying to get svg knobs into the text areas of the buttons.
do you know how this would work? I guess i would have to replace my styling with a draw svg or something. have to find it in docs i think i have seen it the other day.var editButtons = ["Add", "Rename", "Delete"]; if (editButtons.contains(obj.text)) { var icons = ["add", "edit", "trash"]; var path = Paths.icons[icons[editButtons.indexOf(obj.text)]]; g.drawPath(paths, pa, 3); }
i got this from this thread but have no idea how i implement the icon source
laf.registerFunction("createPresetBrowserIcons", function(id) { if (id == "favorite_on") return myFavoriteOnPath; if (id == "favorite_off") return myFavoriteOffPath; if (id == "searchIcon") return mySearchIconPath; });
and this from the docs, @d-healey do you have a video how to draw svg icons for the preset browser?
-
@Straticah I don't have a video about it, but it's exactly the same as drawing them in a panel's paint routine.
-
@d-healey i got it working thanks to your video :) i replaced the star and the search bar icon. I cand find how to size them tho.
// Search and Fav Icons browserLaf.registerFunction("createPresetBrowserIcons", function(id) { if (id == "favorite_on") { return; g.fillPath(ICON_NO_4_path, [0, 2, 2, 2]); } if (id == "favorite_off") return ICON_NO_5_path; if (id == "searchIcon") return ICON_NO_6_path; });
-
@Straticah you can size them by using the area parameter. See this example
var SIZE = 20; var a = obj.area; if (obj.text == 'Add') { g.drawPath(Paths.icons['add'], [a[0], a[1], SIZE, SIZE); return; }
this will place the icon left aligned with a fixed
SIZE
of 20. It's not recommended to just return them without specifying their bounds -
@oskarsh i see, so the sizing of the favourite star icons and the search icon works the same way? I thought there might be a difference since the fav icon on top is not the same size like the one in front the presets :) I attached a screenshot below.
-
@Straticah In the interface designer look in the floating tile's data property. You can change the search bar and favorite icon bounds there.
-
@d-healey oooh nice! tx
-
@d-healey there is no bounds for the search icon tho is there?
{ "ShowSaveButton": true, "ShowExpansionsAsColumn": false, "ShowFolderButton": true, "ShowNotes": true, "ShowEditButtons": true, "EditButtonOffset": 10, "ShowAddButton": true, "ShowRenameButton": true, "ShowDeleteButton": true, "ShowFavoriteIcon": true, "ButtonsInsideBorder": false, "NumColumns": 2, "ColumnWidthRatio": [ 0.3333333333333333, 0.3333333333333333, 0.3333333333333333 ], "ListAreaOffset": [ 0, 0, 0, 0 ], "ColumnRowPadding": [ 0, 0, 0, 0 ], "SearchBarBounds": [], "MoreButtonBounds": [], "SaveButtonBounds": [], "FavoriteButtonBounds": [ 75, 6, 28, 28 ] }