Forum Replies Created
-
AuthorPosts
-
In general, no.
You can Varptr a struct use a pointer, but this is very unsafe.
Looks good, but what’s the source like? Is it a simple ‘drop replacement’ for the current AudioDocumentView?
I would have quite liked Window to extend or contain DockingView, but it would have meant dragging a significant chunk of mojox into mojo, and would have been extra overhead (albeit very little) for people who only need a plain window (eg: games) so I decided against it.
There are also still a few layout view types missing IMO – a GridView, a FlowView and no doubt more. These will happen over time, but in the meantime you can get away with quite a lot using the DockingView.
August 19, 2016 at 3:06 am in reply to: Ted2 1.0.3 crashes when trying to open a file on W10 and W7 #3201Ok, just pushed a potential fix for this.
The best way to debug ted2 problems is in ted2 – just run src/ted2/ted2.monkey2 in debug mode.
Anything that craps out the c++ compiler is a bug – please post an issue at github.
Another point probably worth making: when a window lays out its content view, all it does is set the content view’s frame to match entire window content rect (checkout the Window.OnLayout method). This means when the actual contentview’s ‘Layout’ mode is applied, it will float within or fill the entire window.
But this isn’t very flexible – in most cases you probably want to use a DockingView as the ‘main’ window/content view. This way, the docking view fills the window (unless you change its Layout!) and you can then add things at the top, left, etc of the dockingview/window.
Here you go…
Monkey123456789101112131415161718192021222324252627282930313233343536#import "<std>"#import "<mojo>"#import "<mojox>"Using std..Using mojo..Using mojox..Class MyWindow Extends WindowMethod New()Super.New( "Button Demo",640,480,WindowFlags.Resizable )Local button:=New PushButton( "Click ME!" )button.Layout="float" 'normal sizebutton.Gravity=New Vec2f( 0,0 ) 'top-leftbutton.MaxSize=New Vec2i( 100,0 )button.Clicked=Lambda()Alert( "Well done sir!" )EndContentView=buttonEndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndNote that mojox is very much oriented towards auto-layout, ie: buttons are really designed to be added to toolbars, dockingviews etc, which are added to other dialogs, dockingviews and so on.
This is why buttons default to ‘fill-x’ layout and not ‘float’…try it with ‘fill-x’ layout to see the difference. Note you can also set TextGravity to Vec2f( .5,.5 ) to center text within a button if you need to in ‘fill-x’ layout.
OK, just pushed the results of this evenings experiments if you want to have a play.
There’s a TextViewKeyEventFilter plugin class in there too. I just did it as an experiment so feel free to go nuts with it.
I also added a Ted2TextView subclass to call the key event filters, so anything that extends this (only Monkey2TextView right now) will get filtered.
Note: I’ve gone for ‘Plugin’ instead of ‘Extension’ because extension still might end up as a keyword, although I suspect not…
Actually, here’s an interesting approach…
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100Class PluginFunction PluginsOfType<T>:T[]() Where T Extends PluginReturn Plugins<T>.Plugins().ToArray()EndProtectedMethod New()AddPlugin( Self )EndMethod AddPlugin<T>( plugin:T ) Where T Extends PluginPlugins<T>.Plugins().Add( plugin )EndPrivateStruct Plugins<T>Global _plugins:Stack<T>Function Plugins:Stack<T>()If Not _plugins _plugins=New Stack<T>Return _pluginsEndEndEndClass Ted2DocumentType Extends PluginFunction CreateDocument:Ted2Document( path:String )Local ext:=ExtractExt( path ).ToLower()Local types:=Plugin.PluginsOfType<Ted2DocumentType>()For Local type:=Eachin typesFor Local ext2:=Eachin type.ExtensionsIf ext=ext2 Return type.OnCreateDocument( path )NextNextReturn NullEndProtectedMethod New()AddPlugin( Self )EndProperty Extensions:String[]()Return _extsSetter( exts:String[] )_exts=extsEndMethod OnCreateDocument:Ted2Document( path:String ) VirtualReturn Null 'should return hex editor!EndPrivateField _exts:String[]EndClass AudioDocumentType Extends Ted2DocumentTypeProtectedMethod New()AddPlugin( Self )Extensions=New String[]( ".wav",".ogg" )EndMethod OnCreateDocument:Ted2Document( path:String ) OverrideReturn New AudioDocument( path )EndPrivateGlobal _instance:=New AudioDocumentTypeEndAs long as your plugin calls ‘AddPlugin’ in it’s ctor, it will automagically appear in it’s Plugin.PluginsOfType() array!
So to get at all Ted2DocumentType plugins, you call Plugin.PluginsOfType<Ted2DocumentType>(), while to get at *all* plugins you call Plugin.PluginsOfType<Plugin>() (theoretically…).
Definitely has the ‘cute’ factor and I *think* it’s useful…?
I’m definitely keen on making ted2 as expanded as possible – this would help keep the ‘core’ mean and clean.
Not sure if an ‘uber’ extension class is necessarily a good idea though, as there could be many ‘kinds’ of extension. One thing that’s definitely going in is a ‘Ted2DocumentType’ class, for example (just experimental!)…
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051Class Ted2DocumentTypeFunction CreateDocument:Ted2Document( path:String )If Not _types Return NullLocal ext:=ExtractExt( path )For Local type:=Eachin _typesFor Local ext2:=Eachin type.ExtensionsIf ext=ext2 Return type.OnCreateDocument( path )NextNextReturn NullEndProtectedMethod New()If Not _types _types=New Stack<Ted2DocumentType>_types.Push( Self )EndProperty Extensions:String[]()Return _extsSetter( exts:String[] )_exts=extsEndMethod OnCreateDocument:Ted2Document( path:String ) VirtualReturn Null 'should return hex editor!EndPrivateGlobal _types:Stack<Ted2DocumentType>Field _exts:String[]EndThen, DocumentManager just calls Ted2DocumentType.Create() instead of it’s current select/case block. Just had a quick hack with an AudioDocumentType class…
Monkey1234567891011121314151617181920Class AudioDocumentType Extends Ted2DocumentTypeProtectedMethod New()Extensions=New String[]( ".wav",".ogg" )EndMethod OnCreateDocument:Ted2Document( path:String ) OverrideReturn New AudioDocument( path )EndPrivateGlobal _instance:=New AudioDocumentTypeEndWith this in place, adding a new document is just a single #import away – which is really one step away from being able to drop in dlls (which I still plan to do eventually).
Ted2DocumentType could also provide the ability for document types to add their own views to the right/bottom tabviews, eg:
Method AddBrowserTab( name:String,view:View ) ‘Add a tab+view to the RHS tabview.
Method AddConsoleTab( name:String,view:View ) ‘Add a tab+view to the BOTTOM tabview.The views passed to these tabs could contain things like editing tools for image apps etc. The IDE would automatically hide/show them as documents became current etc.
There’s also the potential for multiple document types per extension, in which case ‘Open’ would need some kind of ‘Open With’ trickery.
I do think this should be kept separate from stuff like ‘KeyFilter’ extensions though, even if they do work sort of the same. You want ‘DocumentTypes’ and ‘KeyFilters’ in separate lists in the first place, so there’s not much they have in common at all. Perhaps description/version info?
Just brainstorming!
> Perhaps that would be an old OpenGLES version?
No, mx2 uses angle which uses d3d9/d3d11.
Just a did a ‘download zip’ of monkey2-master and rebuild all worked fine.
It looks like an EOL conversion problem to me – but this shouldn’t happen on Mac!
Are you using git to get the project? Can you confirm a zip download/.rebuild instead works?
Not having any such problems here.
Does a plain ‘update modules’ crash? ‘Rebuild documentation’?
If you can get other of these to crash outside of module manager (or not) it should be a clue!
Published – love the little asteroids game too!
Thanks for renaming it too, although I’m probably just be overly paranoid…
-
AuthorPosts