Building GUIs With Fusion's UI Manager

User avatar
AndrewHazelden
Fusionator
Posts: 1310
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 2
Location: West Dover, Nova Scotia, Canada
Been thanked: 38 times
Contact:

Re: Building GUIs With Fusion's UI Manager

#181

Post by AndrewHazelden » Mon Feb 11, 2019 8:59 am

pixelstuff wrote:
Mon Feb 11, 2019 8:33 am
I can't seem to find a solution to this and thought maybe its a bug or something else that I have installed that's causing it. The trouble is I don't know how to troubleshoot it.

Hi @pixelstuff.

When things go wrong with UI Manager there isn't a lot of ways to troubleshoot things since all users have to work with, are small fragments of details and scraps of information. :-|

If you want to see scripting functionality and API documentation improved in Resolve 15 and in Fusion Standalone 9 you need to reach out to BMD and let them know its a priority for you. The lack of official *modern* scripting documentation on features like UI Manager, Actions, and Events makes Lua and Python scripting a process of trial and error for end users that make things harder than necessary.

Tags:

User avatar
pixelstuff
Posts: 41
Joined: Sun Jul 15, 2018 11:50 am
Been thanked: 1 time

Re: Building GUIs With Fusion's UI Manager

#182

Post by pixelstuff » Mon Feb 11, 2019 9:47 am

Thanks, I'll contact them directly as its an issue with Fusion 9 and the same happens in Resolve 15, maybe they can track the cause of the problem down :)

User avatar
miaz3
Fusioneer
Posts: 209
Joined: Sat Jan 03, 2015 1:43 am
Location: Angoulême / France
Been thanked: 2 times
Contact:

Re: Building GUIs With Fusion's UI Manager

#183

Post by miaz3 » Fri Mar 01, 2019 12:48 pm

Thanks @PeterLoveday for the tab bar, didn't know !
Thanks @AndrewHazelden i'didnt' know it...i made a func to use uuid...i will integrate it directly into my script :)
  1. function uuid()
  2.     math.randomseed(os.time())
  3.     local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
  4.     return string.gsub(template, '[xy]', function (c)
  5.         local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
  6.         return string.format('%x', v)
  7.     end)
  8. end
Added in 36 minutes 4 seconds:
I thought, we could call (since bmd.scriptapp ()) another module that 'Fusion', ip, timeout, uuid, subtype ?

User avatar
AndrewHazelden
Fusionator
Posts: 1310
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 2
Location: West Dover, Nova Scotia, Canada
Been thanked: 38 times
Contact:

Re: Building GUIs With Fusion's UI Manager

#184

Post by AndrewHazelden » Mon Apr 08, 2019 6:55 am

pixelstuff wrote:
Sun Feb 03, 2019 4:14 am
A problem I'm running into is for some reason the action detection stops(see gif) after a period of time or number of iterations(both time and inputs). Would you have any idea what could possibly be causing this, as I also checked the UI Manager "List input control names" examples in Reactor and it seems to do the same in Win10 and Mac OSX.

The console "time changed" is within the function below.

Code: Select all

ui:AddNotify('Time_Set', comp)

function disp.On.Time_Set(ev)
	print('time changed')
end


There is a possibility that garbage collection in Lua is disposing of the AddNotify action after a while. If you store the pointer returned by the ui:AddNotify() function in a variable it might potentially solve your issue:

Code: Select all

notify = ui:AddNotify('Time_Set', comp)

function disp.On.Time_Set(ev)
	print('time changed')
end

User avatar
pixelstuff
Posts: 41
Joined: Sun Jul 15, 2018 11:50 am
Been thanked: 1 time

Re: Building GUIs With Fusion's UI Manager

#185

Post by pixelstuff » Sun Apr 14, 2019 2:45 pm

thanks @AndrewHazelden BMD confirmed this as a bug, and unfortunately it's still there currently with 16, but hopefully it will be fixed soon.

That makes sense what you have suggested I'll give it a try :)

User avatar
AndrewHazelden
Fusionator
Posts: 1310
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 2
Location: West Dover, Nova Scotia, Canada
Been thanked: 38 times
Contact:

Fuskin Button Toolbar GUI

#186

Post by AndrewHazelden » Fri Aug 16, 2019 10:57 am

The Fuskin Button Toolbar GUI.lua script example has been added to the "UI Manager Lua & Python Examples" atom package in Reactor.

This is a Fusion 16/Resolve 16 compatible script that extracts a series of image resources from the zipped Fuskin file and generates a new UI Manager based toolbar GUI. This script uses the new "ZipFile()" functionality that is only present in Fu16+ Lua scripting.

This script was previously mentioned on the WSL thread "Fetching an image from the .fuskin file via script?" back on 2019-05-06.

Screenshot

FuskinButtonToolbarGUI.png
You do not have the required permissions to view the files attached to this post.

User avatar
AndrewHazelden
Fusionator
Posts: 1310
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 2
Location: West Dover, Nova Scotia, Canada
Been thanked: 38 times
Contact:

Tree Icons Comp Browser

#187

Post by AndrewHazelden » Thu Aug 22, 2019 4:57 pm

Fusion 16 granted a UI Manager centric wish list item "ui:Icon Support in a UI Manager ui:Tree Layout" that I had requested back in 2018. This feature allows for custom PNG icons to be added to a list view, or for a photo-browser like GUI to be made with preview thumbnail images. :banana:

Tree Icons Comp Browser

Tree Icon Comp Browser.png
Here is a Comp Browser demo that has little tiny Fusion icons added next to each comp file in the uiTree view layout.

This script can be used as a Fusion "Comp Browser" window that displays a list of currently open Fusion .comp files, and the rows list summary details about each comp. Double clicking on a row in the Comp Browser ui:Tree view will open the comp file's parent folder in a desktop folder browsing window.

This script requires Fusion Standalone 16 in order to work correctly as the ability to add ui:Icon resources to a ui:Tree was added to the UI Manager library in this version.
Code: [Select all] [Expand/Collapse] [Download] (Tree Icon Comp Browser.lua)
  1. --[[--
  2. ----------------------------------------------------------------------------
  3. Comp Browser for Fusion - v1.0 2019-08-22 8.33 PM
  4. by Andrew Hazelden <andrew@andrewhazelden.com>
  5. www.andrewhazelden.com
  6. -- ----------------------------------------------------------------------------
  7.  
  8. This script is from the Reactor "UI Manager Lua & Python Examples" atom package.
  9.  
  10. It is primarily designed as a code demo for how a ui:Icon PNG image resource can be added to a ui:Tree.
  11.  
  12. This script can be used as a Fusion "Comp Browser" window that displays a list of currently open Fusion .comp files, and the rows list summary details about each comp. Double clicking on a row in the Comp Browser ui:Tree view will open the comp file's parent folder in a desktop folder browsing window.
  13.  
  14. This script requires Fusion Standalone 16 in order to work correctly as the ability to add ui:Icon resources to a ui:Tree was added to the UI Manager library in this version.
  15.  
  16. --]]--
  17.  
  18.  
  19. -- Find out the current directory from a file path
  20. -- Example: print(dirname('/Volumes/Media/image.0000.exr'))
  21. function dirname(filename)
  22.     return filename:match('(.*' .. osSeparator .. ')')
  23. end
  24.  
  25. -- Show the ui:Tree View
  26. function CompBrowser()
  27.     local ui = fu.UIManager
  28.     local disp = bmd.UIDispatcher(ui)
  29.     local width,height = 1920,600
  30.  
  31.     win = disp:AddWindow({
  32.         ID = 'CompBrowserWin',
  33.         TargetID = 'CompBrowserWin',
  34.         WindowTitle = 'Comp Browser',
  35.         Geometry = {0, 100, width, height},
  36.         Spacing = 0,
  37.  
  38.         ui:VGroup{
  39.             ID = 'root',
  40.             ui:Tree{
  41.                 ID = 'Tree',
  42.                 SortingEnabled = true,
  43.                 Events = {
  44.                     ItemDoubleClicked = true,
  45.                     ItemClicked = true,
  46.                 },
  47.             },
  48.         },
  49.     })
  50.  
  51.     -- The window was closed
  52.     function win.On.CompBrowserWin.Close(ev)
  53.         disp:ExitLoop()
  54.     end
  55.  
  56.     -- Add your GUI element based event functions here:
  57.     itm = win:GetItems()
  58.  
  59.     -- Add a header row.
  60.     hdr = itm.Tree:NewItem()
  61.     hdr.Text[0] = 'Comp Name'
  62.     hdr.Text[1] = 'Media Nodes'
  63.     hdr.Text[2] = 'Global Range'
  64.     hdr.Text[3] = 'Render Range'
  65.     hdr.Text[4] = 'Format Name'
  66.     hdr.Text[5] = 'Frame Size'
  67.     hdr.Text[6] = 'Frame Rate'
  68.     hdr.Text[7] = 'HiQ'
  69.     hdr.Text[8] = 'Rendering'
  70.     hdr.Text[9] = 'Filepath'
  71.  
  72.     itm.Tree:SetHeaderItem(hdr)
  73.  
  74.     -- Number of columns in the Tree list
  75.     itm.Tree.ColumnCount = 10
  76.  
  77.     -- Resize the Columns
  78.     itm.Tree.ColumnWidth[0] = 320
  79.     itm.Tree.ColumnWidth[1] = 90
  80.     itm.Tree.ColumnWidth[2] = 90
  81.     itm.Tree.ColumnWidth[3] = 90
  82.     itm.Tree.ColumnWidth[4] = 182
  83.     itm.Tree.ColumnWidth[5] = 100
  84.     itm.Tree.ColumnWidth[6] = 70
  85.     itm.Tree.ColumnWidth[7] = 50
  86.     itm.Tree.ColumnWidth[8] = 65
  87.     itm.Tree.ColumnWidth[9] = 600
  88.  
  89.     -- Change the sorting order of the tree
  90.     itm.Tree:SortByColumn(0, "AscendingOrder")
  91.  
  92.     -- Create a table based upon the open Fusion composites
  93.     local compList = fu:GetCompList()
  94.     for row = 1, table.getn(compList) do
  95.         -- Set cmp to the pointer of the current composite
  96.         cmp = compList[row]
  97.  
  98.         -- Add a new row entry to the list
  99.         itRow = itm.Tree:NewItem();
  100.    
  101.         -- Add an image resource to the cell
  102.         -- Make sure this is excluded from Fusion 9 since the Icon support in a tree view was added in v16.
  103.         if fu:GetVersion() and fu:GetVersion()[1] and fu:GetVersion()[1] >= 16 then
  104.             itRow.Icon[0] = ui:Icon{File = 'Scripts:/Comp/UI Manager/fusion-logo.png'}
  105.         end
  106.        
  107.         -- The Composite Tab name (comp base filename)
  108.         itRow.Text[0] = string.format('%s', tostring(cmp:GetAttrs()['COMPS_Name']))
  109.    
  110.         -- Node count
  111.         -- Should the selected nodes be listed? (Otherwise all loader/saver nodes will be listed from the comp)
  112.         --listOnlySelectedNodes = true
  113.         listOnlySelectedNodes = false
  114.  
  115.         local toollist1 = cmp:GetToolList(listOnlySelectedNodes, 'Loader')
  116.         local toollist2 = cmp:GetToolList(listOnlySelectedNodes, 'Saver')
  117.         local toollist3 = cmp:GetToolList(listOnlySelectedNodes, 'SurfaceFBXMesh')
  118.         local toollist4 = cmp:GetToolList(listOnlySelectedNodes, 'SurfaceAlembicMesh')
  119.  
  120.         -- Scan the comp to check how many media nodes are present
  121.         local totalLoaders = table.getn(toollist1)
  122.         local totalSavers = table.getn(toollist2)
  123.         local totalFBX = table.getn(toollist3)
  124.         local totalAlembic = table.getn(toollist4)
  125.    
  126.         -- Add up how many media nodes are present
  127.         local totalNodes = totalLoaders + totalSavers + totalFBX + totalAlembic
  128.         itRow.Text[1] = tostring(totalNodes)
  129.  
  130.         -- Timeline Frame Range
  131.         itRow.Text[2] = tostring(cmp:GetAttrs().COMPN_GlobalStart) .. '-' .. tostring(cmp:GetAttrs().COMPN_GlobalEnd)
  132.         itRow.Text[3] = tostring(cmp:GetAttrs().COMPN_RenderStart) .. '-' .. tostring(cmp:GetAttrs().COMPN_RenderEnd)
  133.  
  134.         -- Read the comp frame format settings
  135.         local compPrefs = cmp:GetPrefs("Comp.FrameFormat")
  136.  
  137.         -- Format Name
  138.         itRow.Text[4] = tostring(compPrefs.Name)
  139.  
  140.         -- Frame Size
  141.         itRow.Text[5] = tostring(compPrefs.Width) .. 'x' .. tostring(compPrefs.Height) .. ' px'
  142.  
  143.         -- Frame Rate
  144.         itRow.Text[6] = tostring(compPrefs.Rate) .. ' fps'
  145.  
  146.         -- HiQ High Quality Mode
  147.         itRow.Text[7] = tostring(cmp:GetAttrs().COMPB_HiQ)
  148.  
  149.         -- Render Status
  150.         itRow.Text[8] = tostring(cmp:GetAttrs().COMPB_Rendering)
  151.  
  152.         -- The Composite absolute filename
  153.         local filepath = cmp:MapPath(cmp:GetAttrs()['COMPS_FileName'])
  154.         if filepath == '' or not filepath then
  155.             filepath = '<Unsaved>'
  156.         end
  157.         itRow.Text[9] = tostring(filepath)
  158.  
  159.  
  160.         itm.Tree:AddTopLevelItem(itRow)
  161.     end
  162.  
  163.     -- A Tree view row was clicked on
  164.     function win.On.Tree.ItemClicked(ev)
  165.         print('[Single Clicked] ' .. tostring(ev.item.Text[9]))
  166.     end
  167.  
  168.     -- A Tree view row was double clicked on
  169.     function win.On.Tree.ItemDoubleClicked(ev)
  170.         -- Grab the absolute comp filepath
  171.         local compPath = dirname(tostring(ev.item.Text[9] or ''))
  172.         print('[Double Clicked] ' .. tostring(compPath))
  173.  
  174.         -- Open the comp file's parent folder in a desktop folder browsing window
  175.         if bmd.direxists(compPath) == true then
  176.             bmd.openfileexternal('Open', compPath)
  177.         end
  178.     end
  179.  
  180.     -- The app:AddConfig() command will capture the "Control + W" or "Control + F4" hotkeys so they will close the window instead of closing the foreground composite.
  181.     app:AddConfig("CompBrowserWin", {
  182.         Target
  183.         {
  184.             ID = "CompBrowserWin",
  185.         },
  186.  
  187.         Hotkeys
  188.         {
  189.             Target = "CompBrowserWin",
  190.             Defaults = true,
  191.  
  192.             CONTROL_W = "Execute{ cmd = [[ app.UIManager:QueueEvent(obj, 'Close', {}) ]] }",
  193.             CONTROL_F4 = "Execute{ cmd = [[ app.UIManager:QueueEvent(obj, 'Close', {}) ]] }",
  194.         },
  195.     })
  196.  
  197.     win:Show()
  198.     disp:RunLoop()
  199.     win:Hide()
  200. end
  201.  
  202.  
  203. -- Find out the current operating system platform. The platform local variable should be set to either "Windows", "Mac", or "Linux".
  204. local platform = (FuPLATFORM_WINDOWS and 'Windows') or (FuPLATFORM_MAC and 'Mac') or (FuPLATFORM_LINUX and 'Linux')
  205.  
  206. -- Add the platform specific folder slash character
  207. osSeparator = package.config:sub(1,1)
  208.  
  209. -- Show the ui:Tree View
  210. CompBrowser()
  211.  
  212. -- End of the script
  213. print('[Done]')
  214.  

As a quick summary, the ui:Icon resource was added to the ui:Tree item using the following snippet of code:

(The Fusion version check ensures that Fusion 16+ was found to avoid causing errors when the code is run in either Fusion 9, or Resolve 15.)

Code: Select all

		-- Add an image resource to the cell
		-- Make sure this is excluded from Fusion 9 since the Icon support in a tree view was added in v16.
		if fu:GetVersion() and fu:GetVersion()[1] and fu:GetVersion()[1] >= 16 then
			itRow.Icon[0] = ui:Icon{File = 'Scripts:/Comp/UI Manager/fusion-logo.png'}
		end
You do not have the required permissions to view the files attached to this post.