Author Topic: Suggestions for File Tabs  (Read 5977 times)

Offline Mr. Awesome

  • Multiple posting newcomer
  • *
  • Posts: 20
Suggestions for File Tabs
« on: December 27, 2005, 10:42:10 am »
There are a couple things that I liked about Dev-C++'s environment that are not included in CodeBlocks.  They have to do with the functionality of the file tabs above the general coding workspace.  Here they are:

1.  It should be possible to rearrange the file tabs' order by left-clicking and dragging.

2.  It should be possible to right-click on the tabs and get the same options as right-clicking on the file name in the project management area (i.e. Close, Save, Properties, etc.).

Just a thought.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Suggestions for File Tabs
« Reply #1 on: December 27, 2005, 04:17:43 pm »
There are a couple things that I liked about Dev-C++'s environment that are not included in CodeBlocks.
C::B is undergoing several changes. But I will not be surprised if useful features would be added to the environment in a near future :).

1.  It should be possible to rearrange the file tabs' order by left-clicking and dragging.

IMHO, this could be useful for medium-larger projects. For small projects usually closing and re-opening the files is ok :).

2.  It should be possible to right-click on the tabs and get the same options as right-clicking on the file name in the project management area (i.e. Close, Save, Properties, etc.).

Some options are already available (at least with the latest SVN binary snapshot).

Michael

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Suggestions for File Tabs
« Reply #2 on: December 27, 2005, 04:30:45 pm »
IMHO, this could be useful for medium-larger projects. For small projects usually closing and re-opening the files is ok :).
Above all, it is painful to implement. wxWidgets has no function to rearrange tabs. Therefore, unless you want to write your own subclass, you have to delete the current page and add it again at a different index. This is not only clumsy, but it will likely flicker, too.
Subclassing wxNotebook is of course possible, but in the present situation, we have to deal with many other issues already.

Having said that, it is unlikely that this feature will make it into Code::Blocks any time soon.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5149
Re: Suggestions for File Tabs
« Reply #3 on: December 27, 2005, 04:52:26 pm »
The second request seems feasible. I will have look at it, and maybe I'll post a patch for it, but rearranging tabs, not for me (as far as implementing it, no objections against the feature itself : but as Thomas explained : not soo easy).

Cheers,
Lieven

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5149
Re: Suggestions for File Tabs
« Reply #4 on: December 27, 2005, 04:58:06 pm »
correction :
with the head (svn) version :
1) right click on tab :
 -> (if changed) : save, save all
 -> close
2) right click on the editor (that's where the contents is, the code ,...)
 -> properties (as in the projectmanager)

So it's already been don, no ned fo me to find out.

Though I have a suggestion : an extra tab with file properties  :
 - date modified
 - full path name
 - relative name
 - size
 - ...

I'll take a look at my own suggestion for implementation ;-)

Lieven

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5149
Re: Suggestions for File Tabs
« Reply #5 on: December 27, 2005, 05:01:25 pm »
Rearranging tabs : Firefox has that ability (from version 1.5), so if CB can do it at version 1.1 -->  :P :P :P

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Suggestions for File Tabs
« Reply #6 on: December 27, 2005, 05:25:04 pm »
Heh I don't think we can implement Firefox's XUL engine :roll: Oh well...

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Suggestions for File Tabs
« Reply #7 on: December 27, 2005, 05:50:33 pm »
I have done a fast search about how to rearrange tabs. It seems that in the wxTabControl there are two methods that could be useful, if only the wxTab and company would not have been "deprecated" (these classes are just kept for backward compatibility and now it is adviced to use wxNotebook :roll:).

Quote
wxTabControl::GetRowPosition
int GetRowPosition()

Returns the position of the tab in the layer or row.

Quote
wxTabControl::SetRowPosition
void SetRowPosition(int pos)

Sets the position on the layer (row).

Anyway, it would not be possible with wxNotebook to use the InsertPage method?

Quote
wxNotebook::InsertPage
bool InsertPage(int index, wxNotebookPage* page, const wxString& text, bool select = FALSE, int imageId = -1)

Inserts a new page at the specified position.

For example, if a user wishes to move page X after page Y, page X is inserted at the position of page Y and page Y at the position of page X.

Michael

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Suggestions for File Tabs
« Reply #8 on: December 28, 2005, 10:24:05 am »
Anyway, it would not be possible with wxNotebook to use the InsertPage method?
Certainly that is possible, and it is probably the only possible way. But like all Add()/Insert() methods, this calls the copy operator on your control, which means that
a) it is quite CPU-hungry if the user keeps dragging around tabs in a frenzy
b) you have to delete the original tab, or you will have two identical tabs
c) a + b = flicker
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Suggestions for File Tabs
« Reply #9 on: December 28, 2005, 04:18:13 pm »
Certainly that is possible, and it is probably the only possible way.

Yes, I think so. Anyway, I have found with google some references that were interesting, but when I clicked to the link, the related webpage did not contain the requested info :?. Interesting is that in wxWidgets you can propose to pay someone for a new features or bug fixes.

But like all Add()/Insert() methods, this calls the copy operator on your control, which means that
a) it is quite CPU-hungry if the user keeps dragging around tabs in a frenzy

Yes, if a user would like to move several tabs, this could lead to high CPU consume and reduces the responsiveness of C::B.

b) you have to delete the original tab, or you will have two identical tabs

Hmmm. I thought that if you insert a page where another page exists already, the old page would be automatically deleted. If this is not the case, then special care should be given to indexes manipulation.

c) a + b = flicker

And flicker is bad and should be avoided. I just wonder if the "double buffering" technique used with e.g., images could not be used here too.

Michael

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Suggestions for File Tabs
« Reply #10 on: December 28, 2005, 04:58:52 pm »
Interesting is that [...] pay for bug fixes.
Wow, they must be rich. Wish I had one Euro for every bug.

Quote
Yes, if a user would like to move several tabs, this could lead to
Even if the user only moves one tab. As long as the user keeps moving the mouse, the tab must be deleted and re-inserted every time it moves one position up or down.
Alternatively, you could show a little marker like they do it in Firefox, but that is quite lame, to be honest. It looks like "hey sorry, we can't afford to do it in real time". In fact, when I first used that feature, I did not even see this little blue arrow. I kept moving the mouse and wondered why the tab did not move...

Quote
Hmmm. I thought that if you insert a page where another page exists already, the old page would be automatically deleted.
My fault because I used wrong terminology. You do not have ownership of the page or the contained child (editor in this case), so you must not delete it.

But: You still have to get rid of the page somehow, or else the user will see two pages. For this, you can call the notebook's RemovePage() or DeletePage() functions. In the former case, the child window is not touched (It is not specified who owns the object afterwards. So maybe you could re-add it, supposed you have kept a pointer to it, but who knows...), and in the latter case, it is deleted along with the page (which would be quite bad).
What really happens if you do something like noteBook->Insert(GetPage(someIndex)->GetChild(), someOtherIndex); noteBook->Remove(someIndex); is rather obscure... I seriously doubt it will work, and I would not want to work with such code -- you are juggling with objects that you don't necessarily own and whose allocation state you don't control (or even know).

All in all, this smells of a lot of problems (for a rather small advantage).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Suggestions for File Tabs
« Reply #11 on: December 28, 2005, 05:00:32 pm »
maybe we should in this discussion take notice of Yiannis' thoughts about introducing wxIFM.
if wxIFM would be a short-term aim it could be that all the file-tabs-ordering is less important issue.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Suggestions for File Tabs
« Reply #12 on: December 28, 2005, 07:23:29 pm »
maybe we should in this discussion take notice of Yiannis' thoughts about introducing wxIFM.
if wxIFM would be a short-term aim it could be that all the file-tabs-ordering is less important issue.

Yes, wxIFM...I still remeber the cool demo :). May be it will allow to easier re-arrange tabs. Anyway, as I have told before, a quick&dirty technique is to close and re-opening the files to have them ordered as you wish.

Yesterday, I have also found this Implementation of a custom notebook. The interesting point was this:

Quote
//-----------------------------------------------------------------------------
// wxGtkMuleNotebookPage
//-----------------------------------------------------------------------------

// VZ: this is rather ugly as we keep the pages themselves in an array (it
//     allows us to have quite a few functions implemented in the base class)
//     but the page data is kept in a separate list, so we must maintain them
//     in sync manually... of course, the list had been there before the base
//     class which explains it but it still would be nice to do something
//     about this one day

Despite the manually sync (which IMHO could be handle by a map or another STL container), it could be possible to rearrange tabs easier (may be).

Michael

Offline adam

  • Single posting newcomer
  • *
  • Posts: 7
Re: Suggestions for File Tabs
« Reply #13 on: January 12, 2006, 09:13:47 am »
Well a slighty easier thing to implement first would maybe be a "gravity" that would make sure all tabs slide as far left as possible. This way if a tab is picked up it gets replaced by a smaller gap tab. This would cause all tabs to the right to slide to the gap tab. Then just check if the mouse is over half of the next tab move that tab onto the other side of the gap tab. Then when the user drops the tab they picked up it would just expand and replace the gap tab. Sounds simple enough, but since I have no experience with wxWidgets at all I would know where to start.