level editor quad-view control? (C#)

Started by
5 comments, last by Acid-Chris 13 years, 10 months ago
I'm writing a level editor in C# for a game my team is working on and I want to know how the typical quad-view control is implemented in commercial editors such as 3DSMax and other high-profile modelling / level editing packages.

At the moment I'm using the three SplitContainer approach, with two vertical containers nested inside the panels of a parent container. This works, however resizing the bottom two panels horizontally does not affect the top two panels. I'm very new to C#, and I imagine I can write some code to automatically resize the top two panels when the bottom ones are resized, but this feels a bit clunky.

I would have thought that by now Microsoft would have a generic control which implements the behaviour I'm looking for, as it seems to be fairly common.

Any suggestions?
Advertisement
There is no equivalent control in the .net framework "out of the box". The need for such a control is, as far as I see, somewhat limited to 3D modeling apps. In addition, other modeling packages such as Blender implement viewport splitting as an equivalent of a binary tree so as to allow arbitrary splits (but no synchronization between different sides of a split, like MAX).

However, if you understand how the one-way splitter works, it is relatively easy to create a splitter that works in two directions like the viewports in MAX.

The one-way split is implemented conceptually as follows:


  • There are two containers, one for both sides of the splitter
  • There is an area of greater than zero width between the containers, the split line
  • When the user grabs the split line, the mouse is captured and the drag start point is stored
  • While the user drags the split line, the containers on both sides are resized and the split line moved according to the difference of the current point and the drag start point
  • When the user releases the drag, the mouse capture is released


In two-way split, the split line would become a "split cross" but otherwise the logic would be exactly same.

Niko Suni

Alternatively you can probable write event handles for the events of one split pane and then manually update the other.
Thanks for your replies.

Quote:Original post by Dave
Alternatively you can probable write event handles for the events of one split pane and then manually update the other.

Sounds easy enough, but being new to C# I've no idea exactly which events I need to handle in order to cover all the bases. I've created a user control that will handle all of that stuff, but I've read that by inheriting from UserControl you also inherit 40 events, which is quite overwhelming for a C# newbie! Which events in particular should I be concerned about handling? *just names will do, I can handle the rest with MSDN)
The SplitContainer control exposes two events related to the split line movement:

-SplitterMoving, which is fired continuously while the user drags the split line
-SplitterMoved, which is fired when the user leaves from the drag operation

For easiest results, I wouldn't inherit from the control; instead, just lay out the existing SplitContainer control instances as you want them and handle only the exact events of those instances that you need to handle. This way, you only need to write a few lines of code (on the order of 4 to 8 statements).

If you're adventurous and have time to spare, it is a good excercise to try to implement your own split container as per my instructions in my previous reply. It is really not that difficult, if you know the basics of containers and drag/dropping.

Niko Suni

Quote:Original post by Nik02
The SplitContainer control exposes two events related to the split line movement:

-SplitterMoving, which is fired continuously while the user drags the split line
-SplitterMoved, which is fired when the user leaves from the drag operation

For easiest results, I wouldn't inherit from the control; instead, just lay out the existing SplitContainer control instances as you want them and handle only the exact events of those instances that you need to handle. This way, you only need to write a few lines of code (on the order of 4 to 8 statements).

If you're adventurous and have time to spare, it is a good excercise to try to implement your own split container as per my instructions in my previous reply. It is really not that difficult, if you know the basics of containers and drag/dropping.

Thanks for the information! I'll give it a go tomorrow, I have all day :)
Hi,

Mind if i point to an excellent panel addon?
Weifen Luo DockPanel

It's easy to use in your own project, and makes window handling very comfortable. :-)

best regards

This topic is closed to new replies.

Advertisement