About Monkey 2 › Forums › Monkey 2 Programming Help › MojoX – Splitting views
This topic contains 0 replies, has 1 voice, and was last updated by
cocon 1 year, 1 month ago.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
March 4, 2018 at 12:39 pm #13854Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#Import "<std>"#Import "<mojo>"#Import "<mojox>"Using std..Using mojo..Using mojox..Class MyWindow Extends WindowField gridView : GridViewField views : Label[]Field viewIndex : IntMethod New()Super.New( "Add Grid Views",640,480,WindowFlags.Resizable )gridView = New GridView(10, 1)ContentView = gridViewEndMethod OnKeyEvent( event:KeyEvent ) OverrideSelect event.TypeCase EventType.KeyDownSelect event.KeyCase Key.Key1RemoveViewFromGrid()Case Key.Key2AddViewToGrid()EndEndEndMethod AddViewToGrid()' validationIf views = Nullviews = New Label[100]viewIndex = 0EndIf viewIndex = views.Length Then Return' construct labelLocal view := New Labelview.Layout = "fill"view.Text = viewIndexview.TextGravity = New Vec2f( .5 )' set a random styleLocal style := view.Style.Copy()style.BackgroundColor = New Color(Rnd(), Rnd(), Rnd())view.Style = style' update guigridView.AddView(view, viewIndex, 0)' update indexingviews[viewIndex] = viewviewIndex += 1EndMethod RemoveViewFromGrid()' validationIf views = Null Then ReturnIf viewIndex = 0 Then Return' update guigridView.RemoveView(views[viewIndex-1])' update indexingviews[viewIndex] = NullviewIndex -= 1EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()End
This is an attempt to figure out a way of splitting the contents of a mojox container dynamically. Other ideas that perhaps would be taken into consideration:
- Have the ability to use gutters so each region size would be set by the user.
- Use an horizontal bar so user would be able to scroll.
- Perhaps try alternative ways of adding or removing views so the number is not fixed to 100.
-
AuthorPosts
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.