Author Topic: Free the Editors  (Read 28359 times)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Free the Editors
« 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)

(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]
« Last Edit: June 30, 2007, 01:47:37 pm by dmoore »

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Free the Editors
« Reply #1 on: June 30, 2007, 08:32:52 am »
It looks vewy nice :D

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2777
Re: Free the Editors
« Reply #2 on: June 30, 2007, 12:16:27 pm »
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
« Last Edit: June 30, 2007, 12:35:40 pm by Pecan »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Free the Editors
« Reply #3 on: June 30, 2007, 01:48:47 pm »
done -- thanks for the tip pecan.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Free the Editors
« Reply #4 on: June 30, 2007, 01:51:31 pm »
You did this by replacing wxFNB by wxAUINoteBook (or whatever it is called)?
Looks cool :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Free the Editors
« Reply #5 on: June 30, 2007, 01:59:59 pm »
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.

Offline raph

  • Almost regular
  • **
  • Posts: 242
Re: Free the Editors
« Reply #6 on: June 30, 2007, 02:02:10 pm »
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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Free the Editors
« Reply #7 on: June 30, 2007, 02:18:27 pm »
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.
« Last Edit: June 30, 2007, 02:21:44 pm by dmoore »

Offline raph

  • Almost regular
  • **
  • Posts: 242
Re: Free the Editors
« Reply #8 on: June 30, 2007, 02:51:26 pm »
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

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Free the Editors
« Reply #9 on: July 02, 2007, 10:57:37 pm »
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.

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Free the Editors
« Reply #10 on: July 02, 2007, 11:06:08 pm »
When you use wxAUINotebook that is also a possibility... but wxAUINotebook is a 2.8 thing and doesn't have customizable tabs layout
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Free the Editors
« Reply #11 on: July 02, 2007, 11:13:53 pm »
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.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2777
Re: Free the Editors
« Reply #12 on: July 03, 2007, 03:56:27 am »
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.
 
« Last Edit: July 03, 2007, 04:04:09 am by Pecan »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Free the Editors
« Reply #13 on: July 03, 2007, 06:22:27 am »
@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]
« Last Edit: July 03, 2007, 07:02:39 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Free the Editors
« Reply #14 on: July 03, 2007, 06:31:08 am »
another screenshot: