in need of some GUI suggestions.

BlitzMax Forums/MaxGUI Module/in need of some GUI suggestions.

Jesse(Posted 2011) [#1]
I do't have much experience with Max GUI stuff so I am trying to get the hang of it while crating a project. Some of its functionallity is really obvious but other is way over my head.

this is the Problem
I am trying to create( mostly just convert the one I have to using the GUI) a tile map editor with two window inbeded in the main window, I guess you can call them panels(I don't know). the left window panel will be the map editor itself and the right panel will be where I choose the tiles. I can create the left panel easy by assigning it a canvas. what I am having problems is with the right one. I don't know If I have to have a canvas to display the tiles for selection or can I just put them in a panel with out having to create a new canvas element. I originally did it with two canvas but had problem accessing the correct information from each. maybe it was just that my logic was wrong or is there a better way of tackling that problem. I appreciate any suggestions and or code samples.

Thanks in advance.


jsp(Posted 2011) [#2]
Two canvasses are ok, I would say, but if it's not needed it does make it may more complicated.
Depending of the tiles, changing a lot, perhaps animated = canvas, if they are more static a panel is easier.
You can add also tiles to a ListBox or a Treeview if they are not tooo big, which would give some more flexibility.
Do you have a screenshot? Or if you like send your editor to my mail address I will have a look.


Jesse(Posted 2011) [#3]
sorry jsp I don't have anything yet. mostly because I have been trashing every Idea I have tried.
this is the editor I am trying to convert:
http://www.mediafire.com/?3nd3t05utuh2a1z
I am not interested in creating different windows like in that demo. but I would like to have two or maybe even three panels. one for the map, one for tiles and one for the object creation through tiles combinations. if you are still in need to see the source code for the editor(which is a bit more advanced than this demo) let me know and I will email it to you. I warn you, I think only I understand it.


JoshK(Posted 2011) [#4]
You don't have to create a new graphics context every time the window changes size. To make it so the NSOpenGLContext resizes when your window changes size, you must do the following:
1) Make your OpenGL view class derived from NSOpenGLView, not NSView.

2) Add these methods to your OpenGL view class:
- (void)update
{
    if ([glcontext view] == self) {
        [glcontext update];
    }
}

- (void) _surfaceNeedsUpdate:(NSNotification*)notification
{
    [self update];
}


Last edited 2011


Jesse(Posted 2011) [#5]
thanks Josh! I had not even considered that possible problem yet. I'll keep that in mind.


jsp(Posted 2011) [#6]
Looking at the old editor I would go with two canvasses (or one big - all things integrated). You have several tiles which go together as a big tile, this can easily selected in a canvas, but not in a panel nor a listbox. Although in the old editor there I don't see how to select several tiles in one go in the tiles section.
May put a splitter between both to better share the space and make the window resizable.
The old editor updates all the time the graphics, but at least in the sprite.png I chose there was no animation, that consumes more power than needed. If there is no animation needed I would use a fully event based update without timer (updates only when needed).
When using more then one canvas don't forget to use also GLShareContexts() and initialize and flip every Canvas on it's own.


Jesse(Posted 2011) [#7]

Although in the old editor there I don't see how to select several tiles in one go in the tiles section.


sorry, not documented at all. I am not sure any more how it is in windows but in the Mac version I have to hold down the shift and press the mouse button and drag the mouse to select the tiles. I am almost sure it's the same way.


May put a splitter between both to better share the space and make the window resizable.


I tried to use a splitter with a tabber for the tiles and tile objects but for some reason I couldn't get the right pane to work with canvas. I tried to attach a canvas to the pane window but gave me an error when executing. Do I need to attach a panel to the pane than a canvas to the panel? I kind of guess that it wasn't possible from your previous post. Excuse me if I misinterpreted.

I guess if I can't figure it out, I will have to integrate the whole thing into one big canvas which I don't like because I want to be able to use a slider to be able to see the large number of tiles and a tabber to be able to switch between tiles and tile groups.


When using more then one canvas don't forget to use also GLShareContexts() and initialize and flip every Canvas on it's own.


yea, I read about it doing search for possible samples that would help me figure it out.

Thanks for taking your time to help me

Last edited 2011


skn3(Posted 2011) [#8]
I would highly recomend not using glsharecontexts as you will have compatibility issue on certain computers. I highly recommend creating two copies of each image you use on the canvas or tile canvas. Eg each canvas gadget uses a unique copy of the image. This doubles the memory usage but ensures it will be compatible. Glsharecontexts uses a method to share video memory (images) across two canvas. As far as i am aware, it create a third hidden "canvas" (context) and all images belong to it. The canvas in your app will request to share graphics from this hidden context. When two canvas try to use the same image at the same time there can be issues. As you can imagine, certain graphics cards don't like this and you will get visual corruption!

I wrote a module for my current project which acts as a cache system for images. It will duplicate images for you or share context based on the current mode you have set. It seems to work well!

http://www.blitzbasic.com/codearcs/codearcs.php?code=2897

Last edited 2011


shinkiro1(Posted 2011) [#9]
Hey,

I tested your app and thought about how you could integrate that into a maxgui app. Here is what I came up with:



Two canvases as said, are ok. For the menu use the native menu (via CreateMenu). All the other windows you had before in your editor can be implemented as Tool Windows (look at the style flags of CreateWindow) because you don't need their functionality all the time (I think so ^^).


Jesse(Posted 2011) [#10]
@ skn3[ac]

Thanks for the heads up. I will implement the double canvas with duplicate tiles.

@Shinkiro1

looks awesome! I don't think I could have figured it out any better myself. Thanks.


All the other windows you had before in your editor can be implemented as Tool Windows (look at the style flags of CreateWindow) because you don't need their functionality all the time (I think so ^^).



thanks I had all that figured out already.
one question though. would both of the canvas be attached to the main window or would I need to attach each to a separate panel? I am guessing directly to the window.

I will give it a try and post progress.


shinkiro1(Posted 2011) [#11]
Using panels will give you more flexibility. I would use 2 panels: left and right, so if you later change your mind about Gadget position you just have to change the position of the panel.


Jesse(Posted 2011) [#12]
thanks shinkiro for your suggestions. I haven't worked on it much because I have been busy doing other things but lately I started messing with it again. So far this is what I have:

this is just a rough draft to see how I am going to integrate everything and to get an idea how maxGUI works.

I do have one problem I am trying to implement the slider. but I don't like the way it works.
I want it to be able to slide the map while I am moving the the thumb on the slider but the event handler only sends an event after I release the button. I tried to add "EVENT_MOUSEMOVE" SetGadgetAction but still doesn't work. Is there any way to do that? Or am I stuck with the limited way of managing the slider?


by the way these are the images if anybody want's to test it put them in "\gfx" subfolder.
save as "tiles2.png"


save as "icons.png"



Last edited 2011


Jesse(Posted 2011) [#13]
Ok, I decided to do a search and found out that the solution is to use hooks. Great!