Page 1 of 2

First thoughts on scriptkid's layout editor code

Posted: Tue Jan 25, 2005 09:53
by sammydre
I made some notes as I was editing the code. My mission was the implement alignment functionality - so you select a few controls, hit "Align left" and all the windows are moved to the X position of the first window selected.

I've got this working, but had to make a bit of a nasty change. The CSelection class didn't allow me to get at the selected window list as I wanted - because I wanted a reverse iterator, so I could get at the first window selected first. I modified this class to have a "SelectedWindows & getSelectedWindows ()" method. I'm wondering if there was a reason it wasn't implemented this way in the first place, though?

Would be nice to easily get at a resizer for a given window in the CSelection class. This isn't too much of an issue; it was just a thought as I was moving windows about in my alignment code.

An issue I noticed: redrawing problems - sometimes fails to redraw entirely and you have to quit. Also, after you've loaded a layout, it doesn't redraw immediately. Looking at the code, it looks as if it *should* redraw at this point. So I'm not sure why it isn't happening. Haven't looked into debugging this just yet.

I wasn't entirely sure where I should add further functionality - I added menu options for alignment, then added their message handler code in the CCELayoutEditorView class.

I'm thinking that the most useful feature to add right now would be "undo" functionality. I haven't thought about how this should be implemented just yet. Maybe someone else has some thoughts on this.

All in all, seems like a good codebase for further work. Well done on getting it this far!

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Jan 25, 2005 11:54
by scriptkid
Hi,

indeed, the selection uses "push_front". Can't remember why. You can just change it to "push_back" if you want.

The re-draw problem is still a mistery to me as well. It *should* work ;-)

To keep the View maintainable, its maybe an idea to put a class between your handlers and the selection, e.g. a SelectionMover or something like that. We can later also use it to put keyboard moving through, which is an important request.

Thanks for you compliments on the codebase so far :-)

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Jan 25, 2005 19:38
by sammydre
I think changing the CSelection class to allow others to get a reference to the list of selected windows is fine, that way we don't limit any code in the future from going forwards or backwards through the list.

SelectionMover sounds good to me. I'll look into that when I next get some time to code. Hopefully I should have some patches that add my alignment functionality in soon for you. Maybe in a few days time. Then adding the keyboard moving in will be trivial.

Oh, I remembered I had one more question:

I use MSVC 7.0, which has different project files to 6.0. At the moment I just had MSVC convert the existing 6.0 project files to an MSVC 7.0 solution. That is fine until I need to make changes to the project files - add new files or whatever.

I'm not sure how to maintain project files for multiple versions of MSVC. I notice CEGUI has project files for 6.0, 7.0 and 7.1. How does CEGUI keep these files up to date?

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Jan 25, 2005 20:39
by scriptkid
I think changing the CSelection class to allow others to get a reference to the list of selected windows is fine, that way we don't limit any code in the future from going forwards or backwards through the list.


That's fine, but for the moment there already is a WindowIterator, right?

Patching it would be cool! However, you may also update the project yourself. You need to send me your sourceforge loginname then. Just let me know if you'd like that.

The MSVC question is a good one. I think Eddie has more than one version of VS.

Maybe it's best if you just commit new files and i'll make the project changes. I'll see if i can use the VS 7 copy from my work to solve this issue, ok?

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Jan 25, 2005 22:33
by sammydre
That's fine, but for the moment there already is a WindowIterator, right?


Yeah, the problem was that it is a forward iterator not a reverse iterator. Might as well not limit this to just forwards.

Patching it would be cool! However, you may also update the project yourself. You need to send me your sourceforge loginname then. Just let me know if you'd like that.


Ok, I'll message you when I figure out what my username and login was. Been a while since I used it :)

The MSVC question is a good one. I think Eddie has more than one version of VS.

Maybe it's best if you just commit new files and i'll make the project changes. I'll see if i can use the VS 7 copy from my work to solve this issue, ok?


Yeah, ok. If I add any files I'll tell you and you can change the MSVC 6.0 project files. Doesn't sound like the most maintainable way of doing things, though.

Re: First thoughts on scriptkid's layout editor code

Posted: Wed Jan 26, 2005 09:32
by CrazyEddie
I think Eddie has more than one version of VS

Indeed I do. I have VC++ 6.0 and VS.NET 2003 (VC++ 7.1). VS.NET'03 is currently my primary development platform, I usually only use VC++ 6 when someone has been having problems for an extented time (just to check it isn't something I broke). I don't really have access to VC 7.0, though occasionally I have managed to, though that's a decidedly grey area.

I notice CEGUI has project files for 6.0, 7.0 and 7.1. How does CEGUI keep these files up to date?

Everything is done in the VC++ 7.1 'master' version, then the other projects are updated with a text editor afterwards - technical stuff, eh?! ;)

CE.

Re: First thoughts on scriptkid's layout editor code

Posted: Fri Jan 28, 2005 11:28
by TheGilb
Hi there I'm just posting a little thing here about the undo functionality. I am aware of a design pattern called the command pattern which would work well here. The idea is that you make an interface (Command) and derive a subclass for every possible doable action and pop the code to perform the action in an abstract method such as 'exec'. The program keeps a stack of command objects as they get executed. Now when the user clicks undo, the first element on the stack is popped off and its 'unexec' command is executed which contains code to effectively undo the command.

It's a little bit more complex than that, but there it is in a nutshell :) My reference is Design Patterns (GoF)

Re: First thoughts on scriptkid's layout editor code

Posted: Fri Jan 28, 2005 13:09
by scriptkid
Hi,

thanks for the suggestion :-)

I am aware of that pattern too, heck i'm using it at work ATM :-) But i never thought of it with regards to 'undo'ing. You're right, it gets complex soon, especially with deleting or pasting. But i / we will think about it.

Re: First thoughts on scriptkid's layout editor code

Posted: Mon Jan 31, 2005 10:28
by sammydre
scriptkid wrote:

I am aware of that pattern too, heck i'm using it at work ATM :-) But i never thought of it with regards to 'undo'ing. You're right, it gets complex soon, especially with deleting or pasting. But i / we will think about it.


It is the only way I had thought up of doing things. Seems like a fairly logical approach to take.

Well, I finally got around to comitting my code. Have a look. You'll need to add the SelectionMover.cpp code to the project files.

Is there any sort of TODO list or wish list for the layout editor yet?

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Feb 01, 2005 10:02
by scriptkid
Hi!

Thanks for submitting your code. I'll certainly have a look :-)

I have an excel sheet which contains bugs and feature requests.

I'm not sure how it will behave in CVS though, since its binary. But i can check that file in.

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Feb 01, 2005 13:25
by CrazyEddie
scriptkid wrote:
I have an excel sheet... I'm not sure how it will behave in CVS though, since its binary. But i can check that file in.

It should be okay so long as you check it in as a binary file as opposed to text.

CE

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Feb 01, 2005 21:24
by scriptkid
Hi,

i have had a look, but i couldn't compile. It seems that your forgot to commit "selection.h". I'm curious in seeing it work :-)

Now time for a little nagging ;-)

To avoid this compile errors, can you try to make a temporary clean checkout and see if compiles? I think it's possible considering the projects' size.

Which editor did you use, because your files only contain one carriage return, which makes the files pretty unreadable. Can you try to re-commit them?

Thanks so far and keep up the coding! :-)

Re: First thoughts on scriptkid's layout editor code

Posted: Tue Feb 01, 2005 21:31
by scriptkid
Yeah, i wasn't clear enough. I know about the binary addition, but i'm not sure how it deals with differences in binary files.

It's checked in anyhow. In the Docs\Project folder, which can be used to add more project related files, such as design documents.

Re: First thoughts on scriptkid's layout editor code

Posted: Wed Feb 02, 2005 09:24
by CrazyEddie
scriptkid wrote:
Yeah, i wasn't clear enough. I know about the binary addition, but i'm not sure how it deals with differences in binary files.

As I understand things, updates to binary files are not done as diffs, so each time you update the file a new copy is stored in its entirety.

CE.

Re: First thoughts on scriptkid's layout editor code

Posted: Sun Feb 06, 2005 03:23
by sammydre
Yeah sorry, guess I rushed things a bit. That was silly of me! I'll try and fix everything up a bit later today.

Editor? I coded it all in MSVC 7.0. I didn't expect any problems with that.