Code::Blocks Forums
Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: dmoore on June 30, 2007, 06:12:59 am
-
This is probably the last distraction that The Don wants to see so close to a feature freeze :), but in celebration of software freedom and the release of the GPLv3 I thought I'd demonstrate "Editor Freedom" in Code::Blocks. :lol: After some minor hackery, I setup CB to allow a right click on an editor's notebook tab, offering you the freedom to detach it from the restrictive clutches of the wxFlatNotebook.
EDIT: low color image attached. (sorry -- 128kb file size limit was binding and I haven't sorted out external hosting) (Thanks pecan)
(http://img120.imageshack.us/img120/1607/freetheeditorssmlmx6.png) (http://img120.imageshack.us/my.php?image=freetheeditorshg2.png)
(click to see full size)
before anyone explodes in either joy or anger, this is just a proof of concept, and I'm merely posting for entertainment value. So far you can drag and edit in individual windows once detached. I need to sort out (a) reattaching editors to the notebook when you close the window or click on the tab, (b) keeping track of which windows are detached and which editor is active (whichever has the focus) and (c) making sure that dockables get closed properly when you shut down, but this all seems do-able...
[attachment deleted by admin]
-
It looks vewy nice :D
-
Amazing! I'm looking forward to this!
You can also just post your images to
http://www.imageshack.us/index.php
ImageShack® - Hosting
then post the link here. Use the last url ("Direct link to image") from the imageshack page and post them to the forum between <img></img> tokens where <> is actually a [] pair.
Great work Damien
Example:
dmoore's detached/floating/docked CodeBlock editors
(http://img523.imageshack.us/img523/3577/185cr4.png)
-
done -- thanks for the tip pecan.
-
You did this by replacing wxFNB by wxAUINoteBook (or whatever it is called)?
Looks cool :)
-
no (but that would be another way to do it). wxFlatnoteBook still owns each editor, but I'm setting it up to "orphan" children to CB dockables. This seemed the cleanest way of doing things without breaking EditorManager, but this certainly won't be a satisfactory solution to everyone.
-
Wow, nice proof of concept :)
wxAuiNotebook seems to support detaching by simple drag and drop (see aui sample), see wxAUI_NB_TAB_SPLIT.
Replacing wxFNB by wxAuiNotebook would be an thing to think about in the future.
-
got a link to the aui sample? (preferably a binary) -- kirix no longer appear to host it.
I'm probably going to continue with this approach for a little bit, just to get an idea of what can and can't be done. (as brooks says, "plan to throw one away -- you will anyway"). I imagine we'll never please everyone until it's possible to dock a scintilla editor as the third item in the class browser drop down :lol:
EDIT: apparently wxAUI_NB_TAB_SPLIT only lets you split the notebook frame into parts. my approach would compliment this - you can actually detach editors from the notebook entirely and have them float or dock them into the main cb frame.
-
got a link to the aui sample? (preferably a binary) -- kirix no longer appear to host it.
Sources are in wxwidgets source dir/samples/aui
EDIT: apparently wxAUI_NB_TAB_SPLIT only lets you split the notebook frame into parts. my approach would compliment this - you can actually detach editors from the notebook entirely and have them float or dock them into the main cb frame.
You are right.
I would like too see your approach for the "Management" and the "Messages" tabs also :D
-
I'd be much happier if the messages pane had detachable-reattachable windows. This way we could put the stacktrace and other thingies inside it.
-
When you use wxAUINotebook that is also a possibility... but wxAUINotebook is a 2.8 thing and doesn't have customizable tabs layout
-
for lack of a better name, I'm working on TearawayNotebook. It's derived from wxFlatNotebook, but necessarily required some hacks to wxFlatNotebook to get control of page display routines.
Anyway, anywhere you can use wxFlatNotebook you should be able to simply substitute TearawayNotebook and have the option to turn notebook pages into dockable windows. Closing the dockable window returns them to the notebook that owns them. I'm working on a tab icon to indicate a detached state for detached pages. The biggest hurdle will be coming up with a way of making the detached pages part of the persistent CB layout.
i'll put up a patch/win32 build soon (next few days)
NB: Is it just me or do undocked dockable windows always show a focused state? (I'm currently on linux). If so, it's a little bit annoying because I want to give the user visual indication of where their window is if they click on a detached tab.
-
NB: Is it just me or do undocked dockable windows always show a focused state? (I'm currently on linux). If so, it's a little bit annoying because I want to give the user visual indication of where their window is if they click on a detached tab.
For me on XpSp2, undocked dockable windows have the always-on-top attribute, but they do lose focus to other windows.
Here, the OpenFilesList undocked window is always-on-top of everything else, but the editor has focus as you can see by the current line bar.
(http://img167.imageshack.us/img167/2489/191zz7.png)
-
@Pecan: the "always on top" flag also works on linux, but they always show a focused state. maybe a wxAUI bug?
Anyway...
I'm attaching what I've done for now in patch form. A win32 build of Rev 4207 with patch applied (but without contrib plugins) can be found here: http://www.savefile.com/files/859819. Unfortunately, it is not as elaborate as planned because CBs dockable event handlers aren't fully fleshed out.
How to use the build: (after downloading and extracting the files or building the patched source and starting CB) :
1. You should be able to right click on any editor or message tab and select "detach" (except for the start page - it behaves strangely)
2. the editor/message log will move to a floating dockable (you will have to move the dockable window each time as I have not written any persistent placement code yet - I suspect I will need to use a dockable window registry to do this). The tab will remain in place (this is due to point 5 below)
3. The editor/message page of the notebook will now be empty if you click on that tab (but the detached window will be focused).
4. In the editor, I've used a broken file link to indicate the detached state of the file (my attempt at artwork was uninspired, so I reverted to one of the standard icons). There is no indication of the detached state in the message log (could maybe use a greyed out text/icon for the message tab and a greyed out text for the editor tab?)
5. To reattach the editor/message window into its notebook right click on the tab and select "reattach" (unfortunately, getting the editor to reattach upon clicking the close check box turned out to be non-trivial, as is any kind of dragging and dropping, but hopefully we'll get to this eventually)
If anyone plans to apply the patch I suggest doing so over a fresh checkout of code::blocks... I've tried to keep ugly hacks to a minimum but this is still at a very experimental stage, so a few hacks were necessary :), especially to wxFlatNotebook. The only substantive changes to flatnotebook that needed to be made is to declare TearawayNotebook a friend in wxPageContainer, to make the Add/Remove/Delete/DeleteAll/SetSelection methods of wxFlatNotebook virtual and to make private members of wxFlatNotebook protected.
[attachment deleted by admin]
-
another screenshot:
(http://img152.imageshack.us/img152/9804/edfreevq1.gif)
-
oh yeah, please report stability issues. even though I have tested on win32 and linux there are sure to be some problems.
-
like crashes if you leave undetached editors/logs open when you shut down CB :)
-
I wish I could apply the patch first...
patching file src/include/wxFlatNotebook/include/wx/wxFlatNotebook/wxFlatNotebook.h
Hunk #1 FAILED at 1.
patch: **** malformed patch at line 488:
I don't really feel like patching manually :(
-
might be line endings. try opening in your favorite editor, saving and closing (even try something like the dos editor "edit").
also did you use switch -p0 (its what i have to use on the patch utility in win32)(sorry: didn't read closely enough)
-
Ran it thru dos2unix and things got better, but it still failed trying to patch wxFlatNotebook.h
patching file src/include/wxFlatNotebook/include/wx/wxFlatNotebook/wxFlatNotebook.h
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 128.
Hunk #3 FAILED at 138.
Hunk #4 FAILED at 179.
Hunk #5 FAILED at 215.
Hunk #6 FAILED at 360.
Hunk #7 FAILED at 545.
Hunk #8 FAILED at 695.
8 out of 8 hunks FAILED -- saving rejects to file src/include/wxFlatNotebook/include/wx/wxFlatNotebook/wxFlatNotebook.h.rej
I'm trying to patch it manually after all :P
[edit]
I ran that .h thru dos2unix and it got even better, but still fails in some places.
[/edit]
-
if it's only that file, it shouldn't take long at all
-
have to run. hope you have some success with it!
-
I'll have to continue fighting with autotools now because some files need some includes that aren't addressed by Makefile.am.
-
Now that you have opened Pandora's box... allow me to ask why we don't really try to replace wxFlatNotebook with wxAUINotebook. Just for consideration.
wxFlatNotebook has served us well in the past, true. It is themable to a certain extend, true. However, it does have a few smaller issues too, and we compile and link an extra library when we already compile and link another library that has similar (or better?) functionality built-in.
I don't know how mature the wxAUI notebook/tearoff code is, but I guess there's enough review now with it being in the mainstream package.
What I would love to see, too, would be to have some control (no matter which) own editors and that's it. The application should not know whether an editor is shown in a tab or in a tear-off window. Why should it know, anyway?
Also, remember how much code was necessary (and how many problems occurred and had to be fixed) to implement split-view editors. Would it not be nice if the application just created two editors, told the AUI window manager to stack them, and then told one window to forward events to the other? No keeping track of anything, you would not even know that you have split view enabled. Or what about having 4 or 5 views of the same file open? Even that should be possible without a lot of hassle.
OK, to be honest I could not imagine having 5 views of the same file open, but I don't use split view anyway (confuses me big time). Still, would it not be cool if it just worked?
-
I vote for wxAuiNotebook. The only problem is that it is not in the wx2.6 :(
-
By coincidence, I was checking out AuiNotebook in 2.8 just earlier.
It does all wxFNB does and even some things more. Of course, to be used in the context of C::B I 'd have to test it extensively but seems like it 'd be doable.
The only thing that wxFNB does which AUI does not, is that with AUI the tabs are always at the top of the notebook while wxFNB allows you to put them at the bottom. I don't know how crucial this is for people, I 'm just mentioning it.
And, of course, to use AUI we 'd need to jump to 2.8 and drop 2.6. I have no problem with that but it remains to be seen if the other devs would be ok with such a move.
-
And, of course, to use AUI we 'd need to jump to 2.8 and drop 2.6. I have no problem with that but it remains to be seen if the other devs would be ok with such a move.
I've no problem with such move. Most (I think all) of the wx-2.8 related issues are resolved now. :)
Already wxSmith is compilable with wx-2.8 only, as posted by Lieven (http://forums.codeblocks.org/index.php/topic,6339.0.html). So wx-2.6 port remains broken after certain rev of wxSmith.
Only problem is some of the Linux distros are still lacking wx-2.8 package which could be a problem for us if we switch to wx-2.8 completely. :)
-
Not only Linux distros have this problem, BSD's only have 2.6 packages and ports. (I think all of the BSD's, but FreeBSD could be an exception...)
But it is fine with me to move toward 2.8. We can look for a solution to move the tabs (feature request?) ;)
-
What I would love to see, too, would be to have some control (no matter which) own editors and that's it. The application should not know whether an editor is shown in a tab or in a tear-off window. Why should it know, anyway?
Yes, this is the simplest approach and what I tried to achieve with the TearawayNotebook. The only stuff outside of the notebook at the moment is the context menu (and that's becase of the way wxFlatNotebook handles menus). However, if you want state information about window positions to be stored persistently the application is going to have to know at least something about state of the windows, no?
As a user I have no objections to the switch, although i'm not sure that wxAUINotebook will give you all that much more than the latest version of wxFlatNotebook for free?
Also, remember how much code was necessary (and how many problems occurred and had to be fixed) to implement split-view editors. Would it not be nice if the application just created two editors, told the AUI window manager to stack them, and then told one window to forward events to the other? No keeping track of anything, you would not even know that you have split view enabled. Or what about having 4 or 5 views of the same file open? Even that should be possible without a lot of hassle.
OK, to be honest I could not imagine having 5 views of the same file open, but I don't use split view anyway (confuses me big time). Still, would it not be cool if it just worked?
all nice :) but I don't see how you could avoid writing a bunch of new code to get it :lol:
-
I would just like to say that I really like mixing where the tabs are located. (i.e. top/bottom) The new version of wxFlatNotebook is really good and comes with a configuration dialog now and even more styles. I vote for sticking with wxFlatNotebook.
-
However, if you want state information about window positions to be stored persistently the application is going to have to know at least something about state of the windows, no?
Not having looked at it, I would assume this is saved with all of wxAUI's state when you call the serialize/unserialize functions. That's the "normal" behaviour I would expect, anyway. It is not my problem where a window is, or what it's attached to, or how to save/restore that state. wxAUI has to know and nobody else. We should just need to tell wxAUI: "give us a serialized representation of your state" :)
all nice :) but I don't see how you could avoid writing a bunch of new code to get it :lol:
Well, for the simple case of only two views, the idea would be to just create a second editor, and tell AUI to place one on top, and the other on bottom. Each editor would need a "sibling pointer" obtained by Clone() and freed by Release(), so we're taking advantage of wxWidgets' ref-counting and avoid illegal pointers.
The one editor that has the focus forwards all Scintilla edit events to its sibling. If the user gives focus to the other one, that one will forward events. Thus, you would have two editors that are always in sync. Now, on save, reset the sibling to "not modified", and you should have everything you need... in principle.
Does not seem so terribly complicated as an idea.
I've no problem with such move. Most (I think all) of the wx-2.8 related issues are resolved now.
And since the project files were changed to link against the 2.8 library, building for 2.6 is a PITA anyway 8)
But seriously, I don't think it's a major issue if wx 2.8 is not available on some platforms, it is only a matter of time. The tab-placement feature missing in AUI is probably only temporary, too. It should be a no-timer to implement placement on bottom, they just haven't done it to date.
-
The tab-placement feature missing in AUI is probably only temporary, too. It should be a no-timer to implement placement on bottom, they just haven't done it to date.
agreed - there are already styles defined for moving the tabs to the sides and bottom, just not yet implemented.
We should just need to tell wxAUI: "give us a serialized representation of your state" :)
This is the bigger problem with wxAUINotebook. It is self contained. It does not participate in the Save/LoadPerspective() of the wxAUIManager. I think it has it's own wxAUIManager within itself, but it does not even save/load its own perspective.
So, it will be easy to tear tabs and dock them within the bounds of the wxAUINotebook, however, I don't think you'll be able to dock them to other parts of Code::Blocks, nor will you be able to save/restore where they are - without workarounds, anyway.
Maybe this is acceptable, maybe not. Just food for thought.
-
It is not my problem where a window is, or what it's attached to, or how to save/restore that state. wxAUI has to know and nobody else. We should just need to tell wxAUI: "give us a serialized representation of your state" :)
two complications:
1. as far as I can tell wxAUINotebook doesn't support the concept of detaching pages from the notebook entirely and letting them float. you can move pages from one notebook to another or divide up the notebook, but I don't think that either of these options is satisfactory for notebooks like the message manager. Thus, if you want fully detachable pages I think some coding of either a sub-classed notebook or message manager to spawn new dockable windows (or even dockable notebooks) is unavoidable. I'm not talking about a lot of coding, though...
2. the serialized state has to be synchronized with the initialization of windows. e.g. plugins must register their dockables with cb before their state is loaded. If we want a detached build messages log to persist between sessions, we will need to register its dockable somewhere so that on restart it gets initialized in a dockable... (I'm also not sure that the current implementation of wxAUI_NB_TAB_EXTERNAL_MOVE in wxAUINotebook saves any state information about tabs moved to new notebooks (e.g. a message manager notebook page moved to the project notebook))
Well, for the simple case of only two views, the idea would be to just create a second editor, and tell AUI to place one on top, and the other on bottom. Each editor would need a "sibling pointer" obtained by Clone() and freed by Release(), so we're taking advantage of wxWidgets' ref-counting and avoid illegal pointers.
The one editor that has the focus forwards all Scintilla edit events to its sibling. If the user gives focus to the other one, that one will forward events. Thus, you would have two editors that are always in sync. Now, on save, reset the sibling to "not modified", and you should have everything you need... in principle.
Does not seem so terribly complicated as an idea.
sounds good to me :) (my only point was that wxAUI doesn't do this for you, it just helps a little - but probably no more than wxFlatNotebook)
-
1. as far as I can tell wxAUINotebook doesn't support the concept of detaching pages from the notebook entirely and letting them float. you can move pages from one notebook to another or divide up the notebook, but I don't think that either of these options is satisfactory for notebooks like the message manager. Thus, if you want fully detachable pages I think some coding of either a sub-classed notebook or message manager to spawn new dockable windows (or even dockable notebooks) is unavoidable. I'm not talking about a lot of coding, though...
Strange I thought it was possible to detach the pages. But when trying to do so (in a program which uses AUINotebook) it doesn't work. You can move them between other notebooks...
-
How about we define a new notebook class cbNotebook that offers a core set of features to the main CB app and plugins? These features would include the usual add/remove/select page, and some persitency code to allow users to define the ordering of their notebook pages in static books that would get called when the CB layout is saved/loaded. Then we can drop-in wxFlatNotebook, wxAUINotebook or any other notebook we feel like for cbNotebook's implementation and not have to worry about breaking the main app.
In addition to detachable pages that I've been working on, cbNotebook could also offer features like a proper z-order (nothing is more frustrating than closing a file and having its neighbor selected instead of the last selected file), draggable tabs etc all of which would be invisible to the sdk user.
-
How about we define a new notebook class cbNotebook that offers a core set of features to the main CB app and plugins? These features would include the usual add/remove/select page, and some persitency code to allow users to define the ordering of their notebook pages in static books that would get called when the CB layout is saved/loaded. Then we can drop-in wxFlatNotebook, wxAUINotebook or any other notebook we feel like for cbNotebook's implementation and not have to worry about breaking the main app.
I think writing a notebook control from scratch is a waste of time and resources.
I think we should extend wxAuiNotebook (which nearly already supports all the features we need) to fit our needs, since it already comes with wxWidgets.
wxAuiNotebook would be a perfect candidate for the open files notebook, since it allows splitting of tabs (here: open files) in a very intuitive way (I think being able to dock the main tabs to the/into the other panes ("Messages", "Management"...) is unintuitive and confusing).
Anyway the other notebooks ("Messages", "Management"...) really need a "detach" feature, since splitting the tabs isn't enough here.
In addition to detachable pages that I've been working on, cbNotebook could also offer features like a proper z-order (nothing is more frustrating than closing a file and having its neighbor selected instead of the last selected file), draggable tabs etc all of which would be invisible to the sdk user.
Hm, never realized this. Never saw an application which implemented that behavior.
-
I think writing a notebook control from scratch is a waste of time and resources.
If you read my post more carefully I didn't say anything about writing a notebook from scratch :). As you say we would drop in wxAuiNotebook or wxFlatnotebook to provide the core of the implementation.
I think we should extend wxAuiNotebook (which nearly already supports all the features we need) to fit our needs, since it already comes with wxWidgets.
I don't have a strong preference either way, but I agree it will be easier to maintain one external GUI dependency instead of two
wxAuiNotebook would be a perfect candidate for the open files notebook, since it allows splitting of tabs (here: open files) in a very intuitive way
i still need to see it in action. I can also see wanting to detach files from the notebook altogether
(I think being able to dock the main tabs to the/into the other panes ("Messages", "Management"...) is unintuitive and confusing).
i can't imagine using it either. but more generally people might want to create their own notebooks and collect tabs in them as they see fit.
Anyway the other notebooks ("Messages", "Management"...) really need a "detach" feature, since splitting the tabs isn't enough here.
I've implemented this as a right click menu option (well, at least for messages, I'm in the process of adding the default right click menu option to detach pages to my tearawaynotebook class to handle the management notebook).
-
i still need to see it in action.
Do you mean wxAuiNotebook? There is a sample in wx_src_dir/samples/aui.
-
I was just being lazy about building the sample (because I had to rebuild wx). anyway, I've done it now. very impressive tab splitting and, obviously, the notebooks are more consistent with wxAUI theming. I think upgrading to wxAuiNotebook makes sense, but I still think wrapping it in a cbNotebook class is agood idea from a maintainability/extensibility viewpoint.
-
Thanks for the proof of concept. I was starting to look through the code in my free time to make the editors movable.
Thanks
Zarnce
-
no problem - it is a feature whose absence was annoying me too. you can see the buggy patch in all its glory via my cbilplugin project's svn http://developer.berlios.de/svn/?group_id=7745
(the latest win32 build is also available there) the file is under trunk/CBExperimental/edfree-win32.patch. (I'll commit a patch with fewer bugs later tonight)
-
Hi sorry about using an old thread.
I have written some code for wxAUI that does "auto notebooks". In these, a notebook is created by docking 2 more more items together. You can rip them out and dock them back in somewere else - say next to each other. You can also drag out some of your code windows and dock them together on, say, a second monitor.
See: http://gamemosaic.com/auimod/index.html (http://gamemosaic.com/auimod/index.html) for some changes and a windows executable demo.
Let me know if you find this interesting.
Huge
-
Looks like that is exactly what we need :P.
This wxAUI mod would make all the tabs we have (Projects, Symbols, Resources, Code::Blocks, Search Results, ... even Open files list and all the plugin panes) fully user customizable and we wouldn't have to hardcode their locations anymore.
For the file-tabs we could use wxAuiNotebook cause of its splitting-ability.