persistant pop-up

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Vern, what he's trying to do is to create a sort of multi-tool that has a bunch of icons for other button and tool scripts in its option bar, so you can remove them from the normal toolbar, similar to what Mike himself did for the peak button for the curvature tool, etc. What Mike didn't do is try to consolidate multiple tools into one, but even that should be possible as well, although not straight-forward. Because this multi-tool would have to call each callback function of each tool, it would be much easier if it was auto-generated, which is why Artfa was starting to talk about using php for this task.

Artfa, I appreciate that your more familiar with php, but writing such a script in Lua might be a good way for you to get started with Lua as you woudn't have to worry about the AnimeStudio stuff at the same time, which complicates things as Ver said. What would be really cool is to use WxLua to write a GUI for it so people would have a nice interactive tool consolidation app, so they could effortlessly move tools and buttons from the main toolbar to the multi-tool one. If you do this I would be happy to write the AnimeStudio specific template if you want.

One tricky bit I thought of, though, is that each tool will want to put its own set of options in the options bar, so you'll lose your list of tool icons. Perhaps you could get around this by adding a back button once you've executed the selected tool's DoLayout function. That leads me to another issue... is it possible to manually clear the option toolbar without switching tools?
artfa wrote: "talking at cross purposes"... Ain't words the funniest thing ever invented?
Sure they're only worth 1/1000th of a picture and quieter than actions, but until someone invents a mental telepathy chip, words are often the best tool we've got. :D
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Ah I think I see.

First problem I see is the loss of the standard "shortcuts" from the _tool_list.txt file. You could put in key shortcuts in the script but not be able to use the standard tool switching. Also this "massive tool" (Father Ted reference ;) ) would be enormously complex if all the code is there for all the tools. The only way to move a tool or button out of the current tool bar would be to put ALL the code in the tool itself.

At the end of the day... you would be moving the tools from the tool bar up to the top of another tool... unless I'm missing something... pretty much what we have just... horizontal. ;)

You could try to port some of the code into a utility script. That might make more sense. I plan to try this with my physics script.

-vern
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

You can't draw the tools options unless it is selected. It can be "enabled" though. The widgets at the top are just references to variables with the option to change those values with a checkbox or input box.

The cool thing with AS 6 are IMAGES in those widgets!!! You can create icons to put up there and then reference them in the script. There is a new folder for support images like that. Like the flip points and layer buttons now in the tool options.

I think I get this better now... just group things like vector or bone tools into "one" tool. Don't put ALL the tools in one. Makes sense.

-vern
arfa
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

Post by arfa »

Part of the problem here is my (almost) total lack of familiarity with lua jargon and syntax and the confusion it creates trying to communicate. So, I am sorry about any confusion there.
mental telepathy chip
I'm working on that too 8)
The only way to move a tool or button out of the current tool bar would be to put ALL the code in the tool itself.
I had success moving the whole script into the script/utility folder. I have the flip_layer H&V buttons working.

I have the rb_grid script in the _tool_list as a button so moved that over as well. But...
How to call the dialog box?
I set RB_Grid = {} at the top of ak_butts and then tried:
elseif (msg == self.RB_GRID) then RB_GridDialog:new(moho) in the ak_butts:HandleMessage() -- nothing.
It holds the functionality of flip_layer V (the preceeding HandleMessage() line)
IMAGES in those widgets
Do you mean the first element in the LM.GUI.ImageButton() declaration?
loss of the standard "shortcuts"
Yeah, that would be a drag. Always a trade off :(
What would be really cool is to use WxLua to write a GUI
"Sure" he says with total confidence and absolute ignorance.
If you do this I would be happy to write the AnimeStudio specific template
Very generous of you.

I am on dial-up so that limits me (downloading manuals, examples, tutorials etc.). Even wxLua (at 5.8mb) is a bit of a chore. Realise that we are starting from ground zero here :shock:
I am up for trying this if there is (lots of) guidance and (very) patient hand-holding.

So, where do I begin :?: :?: :?: :?: :?:[/b]
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Hi Artfa,

I agree that you don't have to move all of the code into the tool itself. One thing though, do the LoadPrefs, SavePrefs functions still get called when you move a script to the utility directory? If not, you can move them to a menu folder instead.

With regards to your question about calling a dialog box for RB_Grid, I'm not sure of the exact problem you are having, but you definitely do not want the "RB_Grid = {}" line at the top of ak_butts as that will be blowing away to RB_Grid tool object. If RB_Grid is a button tool, then you'll just want your ak_butts:HandleMessage() function to call RB_Grid:Run(), which should create the RB_GridDialog itself.

Also, I'm not sure that loss of the standard shortcuts is that big a deal as you can always just leave the standard tools in the toolbar and save these extension toolbars for custom tools. If this gets implemented, I fully intend to have a separate toolbar for each scripter and maybe have some for specialized tasks. The good thing about this approach is you can always double up by having tools in more than one toolbar.

For the wxLua stuff, yeah just install it and play around with the samples it comes with and look at their code (). I already had standalone Lua installed when I installed wxLua, but I think it comes with it's own wx specific Lua that you can use to run the examples. Something else you might want to look at is wxGlade (http://wxglade.sourceforge.net/), which lets you build your GUI graphically. It uses Python and wxPython, so that might require a further install unless it comes with its own built in.
arfa
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

Post by arfa »

do the LoadPrefs, SavePrefs functions still get called when you move a script to the utility directory?
No idea. Please remember the lua language/syntax is quite new to me. I have got the flip_layer H&V scripts to work - but they are very simple.
If not, you can move them to a menu folder instead.
Is there any advantage, per se, of menu over utility?
you can always double up by having tools in more than one toolbar
Yes! Excellent idea.
wxLua stuff... play around with the samples it comes with and look at their code
Am doing.

from post at page top:
writing such a script in Lua might be a good way for you to get started with Lua
I agree there is nothing like doing it to learn how to do it. But...
I need to be clear as to what I am aiming at here?
You said:
"write a GUI for *it* so people would have a nice interactive tool consolidation app, so they could effortlessly move tools and buttons from the main toolbar to the multi-tool one."
This sounds great when I read it without thinking.
By *it* are we still talking about a tool button that launches an option bar with a row of tools/buttons on it? Or, is 'it' the GUI to set up the tools; in folders or reformatted or...
I admit I am not 100% clear as to what you are suggesting I produce :wink:

I presumt this GUI will run within AS?

Either way, my first attempts with lua indicate it that it will take a while. Learning a new language is always a bit more than being able to get directions to the nearest cafe :P
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Moving the scripts to a menu folder will allow the script preferences to be managed correctly, as I'm not sure whether it will if it's in the utility directory. The other advantage is that you'll still be able to run your button scripts manually which may be good for debug.

Just to clarify my suggestion, I was proposing you write a standalone application that is run outside of AnimeStudio, as it doesn't make much sense to edit a programs tools while you are running it. The goal of the app would be to build your multi-tool for you as well as automatically moving scripts from the tool directory to the menu directory. This is basically what you've been doing manually, and that might be sufficient for now, but I just think it would be cool, if you could just drag a tool or button from one toolbar to the other and all of the AnimeStudio scripts were automatically updated to achieve this.

I think you'll find that learning a new programming language is a lot like driving someone else's car. It's unfamiliar and awkward at first, but you soon find that there's more the same about it than different and you'll be hooning down the highway, clocking up speeding fines in your friend's name in no time.
arfa
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

Post by arfa »

So, the race is on 8)
basically what you've been doing manually
Not quite. I have had some success but somewhat limited. If I knew the consistent process (manually) then I would have more chance of emulating that auto matically.
Rudiger said:
"I would be happy to write the AnimeStudio specific template"
Where does this figure in the equation?
-~- first attempts at hot wiring this unfamilyiar vehickle may require some specific directions.
moving scripts from the tool directory to the menu directory
This should be pretty straight forward.

Hooooooning?
Ah, brings back memories :twisted:
arfa
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

Post by arfa »

Still poking about.

Here is a trial using the 'nudge' buttons:
http://www.BuddhaMind.info/as/bits/butts_nudge.lua (right-click save)
Image - my 'collective' icon

It seems to have to be set in _tool_list as a tool.
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Hey that's mega cool, arfa! Is there a chance I could merge it into the next version of the nudge tool, including the icon, though?
arfa
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

Post by arfa »

Mr R. -- you are the inspiration here :!: the guiding light :P :P :P

I would be flattered if my first stumbling attempts with Lua were included **anywhere**
The icon is the easy part for me and given freely to all.

Back on the 'main' project...
I am not sure how to include tools - eg. fazek's (which use a utility.lua) or in fact any that don't use the 'run' command. I still have a couple of experiments left to try but am not that optimistic that I am on the right track.

Any suggestions that would lead me on would be appreciated.

I am getting a list of the things I think an auto-option-bar builder might need and will post that by and by.
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

arfa wrote:Mr R. -- you are the inspiration here :!: the guiding light :P :P :P

I would be flattered if my first stumbling attempts with Lua were included **anywhere**
The icon is the easy part for me and given freely to all.

Back on the 'main' project...
I am not sure how to include tools - eg. fazek's (which use a utility.lua) or in fact any that don't use the 'run' command. I still have a couple of experiments left to try but am not that optimistic that I am on the right track.

Any suggestions that would lead me on would be appreciated.

I am getting a list of the things I think an auto-option-bar builder might need and will post that by and by.
Hi arfa,

Thanks for giving your permission to let me use your code and icon. It may seem minor, but the less I have to do add to the next version of the nudge tools, the quicker I can get it out. :)

OK, here's my first try at implementing a tool into your option-bar tool. All I did was add my customized freehand tool to your butts_nudge.lua tool and renamed it to ar_multitool.lua to be a bit more inclusive.
Here's the download link: ak_multitool.lua

A major hurdle I encountered was that I couldn't find a way to remove widgets from an existing dialog layout, so it's currently impossible for tools to share the option bar. The only way I could think of to get around this was to bring up the options for each embedded tool in a floating dialog. It's not ideal, I know, but probably not a deal-breaker. What might be a deal-breaker, though, is I can't figure out a way to get a pop-up dialog box to work from within the floating dialog. I'll have to do some more experimentation with simpler cases to see if it's possible.

Anyway, hopefully this is enough for you to start writing your script to automatically add the relay functions for embedding the tools. If anyone's got an idea how you can embed a pop-up dialog in a modeless dialog please let us know.

** EDIT: Fixed link
Post Reply