Author Topic: User interface for project glob feature  (Read 21611 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
User interface for project glob feature
« on: August 17, 2018, 05:51:03 am »
Hi,
i implemented a user interface and scripting interface for the project glob api, that was introduced 7 years ago, but never used over UI:
http://forums.codeblocks.org/index.php/topic,16958.0.html

i think this is a nice feature specially if you use a custom make file.. .

The implementation is currently here https://github.com/bluehazzard/codeblocks_sf/tree/test/UnitsGlob/ui/1
i will provide a patch and a ticket on SF as soon as someone shows interest....

Attached is a screenshot of the UI

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: User interface for project glob feature
« Reply #1 on: August 17, 2018, 10:20:19 am »
What is this control? It looks ugly. Also you need to provide an edit button.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: User interface for project glob feature
« Reply #2 on: August 17, 2018, 11:56:25 am »
yes it is ugly... It is a wxGrid controll. I tried to use a wxListCtrl, but there you can not edit the second column. I did not wanted to add a second dialog, where you input the parameter and hit ok. With this control you can in place edit everything. Fast and easy...

Quote
Also you need to provide an edit button.
I will try to add an "search" button in the first column that opens the path control (that one used by the project search paths)... As far as i can see this is also more easily made with the wxGrid control then the wxListCtrl. A other possibility would be wxPropGrid, but i am annoyed by the different implementations in wx2.8 and wx3.0....

More suggestions welcome

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: User interface for project glob feature
« Reply #3 on: August 17, 2018, 01:28:28 pm »
It is common for C::B's UI to open secondary dialogs where stuff is edited. I don't know why this bothers you.

wxPG isn't that different in wx28 and 3x from the calling code. The wx3.x is just more buggy. :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: User interface for project glob feature
« Reply #4 on: August 17, 2018, 02:58:38 pm »
Quote
It is common for C::B's UI to open secondary dialogs where stuff is edited.
and i hate it... If you want to change one letter in 3 libraries (to add a debug "d" for example) you have to click 12 times  3x(select entry, open dialog, activate, close dialog), instead of 3 times (select entry and set cursor at correct position at the same time)... Quick copy and paste? Naaa forget it... you have open a dialog to get the value... Don't put design over usability, we have this crap everywhere in the new web and programing....


[Edit:] i have found wxDataViewCtrl  (http://docs.wxwidgets.org/trunk/classwx_data_view_ctrl.html) and will have a look into it. It look like the control we need
[Edit2:] This control is only available wx>2.9 ;(
« Last Edit: August 17, 2018, 03:21:57 pm by BlueHazzard »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: User interface for project glob feature
« Reply #5 on: August 17, 2018, 05:43:13 pm »
I doubt it would be common to want to change all entries. What would be this situation?
And consistency is a good thing. It surprises users less.

wxDVC seems like the control with the most bugs and it is also ugly.

p.s. For the libs UI you can probably make a UI based on wxTextCtrl, but editable wxListCtrl would also work. I think this was possible to have editable wxListCtrls in wx. If you're interested to test it I'd be happy to review such patch.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: User interface for project glob feature
« Reply #6 on: August 17, 2018, 06:52:44 pm »
Ok, i looked a bit into it:

*) wxListCtrl can not be changed, that other columns but the first can be edited (https://forums.wxwidgets.org/viewtopic.php?t=39593) The supposed way is to use the wxDataViewCtrl
*) in wx2.8 wxDataViewCtrl is implemented only rudimentary. You have to add a Data provider class ecc... It differs from the wx2.9 implementation. There is a nice interface to add columns and manage them with less code http://docs.wxwidgets.org/trunk/classwx_data_view_list_ctrl.html This class does not exist in wx2.8

Quote
I doubt it would be common to want to change all entries. What would be this situation?
I gave you an example:
Changing from release to debug libraries or for example wx2.8 to wx30.
Copy and paste many paths from one project to a other over a text file... From a make file to codeblocks...
I don't know, i had so many situations where a lot editing had to be done... Editing the cbp file directly is also no real alternative because of the xml file format...
I had this problems for the library setting and i see that coming for this settings, so i wanted to mitigate this with a ui where every field is editable in place...

So what is to do?
1) If we use the  wxDataViewCtrl  i am not really willing to implement it in wx2.8. So this UI would be only for cb wx3.0 and past (it is better as now, because now is no ui for no wx version)
2) Pimp the wxGrid so that it looks better? ( kicad uses this control a lot, so we could look if they have some nice changes)
3) Use property grid.
4) Use wxListCtrl and make a separate dialog for editing (not my favorite.... Adding a other dialog... Not being able to edit in place...)
[EDIT:]
5) Using wxListCtrl  but make the whole dialog bigger so there is a wxTextCtrl for every column. You select the entry in the ListCtrl on the left and the values from the textCtrls get updated on the right... Something like this http://wxdsgn.sourceforge.net/images/tutorials/Multicolumn_table_using_virtual_wxListCtrl_Tutorial.files/image046.jpg
« Last Edit: August 17, 2018, 06:56:59 pm by BlueHazzard »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: User interface for project glob feature
« Reply #7 on: August 17, 2018, 07:13:17 pm »
Quote
I doubt it would be common to want to change all entries. What would be this situation?
I gave you an example:
Changing from release to debug libraries or for example wx2.8 to wx30.
Copy and paste many paths from one project to a other over a text file... From a make file to codeblocks...
I don't know, i had so many situations where a lot editing had to be done... Editing the cbp file directly is also no real alternative because of the xml file format...
I had this problems for the library setting and i see that coming for this settings, so i wanted to mitigate this with a ui where every field is editable in place...
I was talking about the glob feature. Changing libraries in bulk is more common I agree.

So what is to do?
1) If we use the  wxDataViewCtrl  i am not really willing to implement it in wx2.8. So this UI would be only for cb wx3.0 and past (it is better as now, because now is no ui for no wx version)
2) Pimp the wxGrid so that it looks better? ( kicad uses this control a lot, so we could look if they have some nice changes)
3) Use property grid.
4) Use wxListCtrl and make a separate dialog for editing (not my favorite.... Adding a other dialog... Not being able to edit in place...)
[EDIT:]
5) Using wxListCtrl  but make the whole dialog bigger so there is a wxTextCtrl for every column. You select the entry in the ListCtrl on the left and the values from the textCtrls get updated on the right... Something like this http://wxdsgn.sourceforge.net/images/tutorials/Multicolumn_table_using_virtual_wxListCtrl_Tutorial.files/image046.jpg
1. I don't think wxDVC it is an option until we're at 3.2. wxDVS is something that is always active on the wx's issue tracker.
2. I doubt this would work. If we use wxGrid we should accept that it will be ugly and a bit hard to use. Keep in mind that many people don't know that the last row of the watches window is editable and they are confused.
3. Could probably work, but you'll have max 3 columns and only the second is easily editable. Editing the label is annoying and hard to get right if I remember correctly.
5. It is one or two clicks better than 4, but the UI will be confusing, so I don't think this is a good option.

So, I guess you have to choose between 2 and 4...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: User interface for project glob feature
« Reply #8 on: August 20, 2018, 12:55:29 pm »
How about this?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: User interface for project glob feature
« Reply #9 on: August 20, 2018, 01:56:30 pm »
I really like a GUI front end is being made for it.

Wrt wx28 and wx3.x, do we still want to support wx28 ?
On our windows nightlies we have switched, and let's hope by the next release we will have a more stable wx so that one will be wx3 too.
And on most linux distros by default it is already wx3x

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: User interface for project glob feature
« Reply #10 on: August 26, 2018, 10:38:03 pm »
@bluehazzard: Looks good.

@killerbot: I'm still using wx28 on my works centos 6. I'm in a process of switching to wx3.x there.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: User interface for project glob feature
« Reply #11 on: August 26, 2018, 11:53:14 pm »
Ok, i posted a ticket with a patch

https://sourceforge.net/p/codeblocks/tickets/729/

i can not test it on linux at the moment, but it should work.

(Can we work on reducing the amount of project files? this is so a pain in the a** to keep in sync all this project files)

Missing are the makefiles....

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: User interface for project glob feature
« Reply #12 on: August 28, 2018, 09:11:49 pm »
Here are some comments on the patch (starting from the top of the file to the bottom):

1. Mismatch between the comment and the name of AddGlob (glob vs globs).
2. The plugin version should be increased because of the addition of AddGlob
3. Get/SetGlobs should be added to the script bindings. Can we have tests for these 3?
4. dlgEditProjectGlob should be EditProjectGlobDlg for consistency
4.1. StaticText1, StaticText2 shouldn't be members
4.2. The click handle methods should have better names, using the names created by wxsmith is rarely a good idea
4.3. filenames should be lower case and if you need more clarity you can use underscores. This prevents nasty case sensitivity problems in different oses.
4.4. The case for variables should be consistent.
4.5. The custom var logic needs better documentation.
4.6. We don't use underscores for variables, use camelCase.
4.7. Prefer empty instead of IsEmpty and ==wxEmptyString
4.8. the cbMessageBox condition at the end of OnbtnBrowseClick is more complicated than it could be - the two blocks are almost the same
4.9. We align to the open bracket when long lines are truncated.
5. dlgManageGlobs should be ManageGlobsDlg
5.1. same for filenames all lowercase please
5.2. Duplicating Manager::Get()->GetProjectManager()->GetActiveProject() wastes resources and makes code harder to read
5.3. It is better to use wxString::Format when there is a string which will be translated instead of using operator+, different languages have different word order.
5.4. Start all columns with capital letter?
5.5. Again do not use underscores in variable names
5.6. Prefer using std::vector instead of wxArray*
5.7. Are you sure OnbtnDeleteClick works correctly when deleting multiple items? I'm pretty sure you need to iterate items backwards.
5.8. Repeated calls to prj->GetGlobs()[i\] aren't good idea - store them in variables
6. Do not pass nullptr when creating dialogs. It leads to really bad problems on linux.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: User interface for project glob feature
« Reply #13 on: August 29, 2018, 12:04:23 am »
ok, i will work this list down...
Quote
1. Mismatch between the comment and the name of AddGlob (glob vs globs).
Can you point out the line in the patch?
I think AddGlob is the singular (add one glob entry), and SetGlobs is plural (edit multiple globs)?

Quote
3. Get/SetGlobs should be added to the script bindings. Can we have tests for these 3?
Not really... there is no independent  read back possibility from script bindings, to check the success... If i remember correctly i have not implemented any test for all project functions, because it was not possible to create a project from the script binding and get a independent result from the function (compare a pre made project file for example) ... Testing project binding should not be topic for this patch... If there is need we should create a new topic/ticket

Quote
4.2. The click handle methods should have better names, using the names created by wxsmith is rarely a good idea
suggestions? I think OnbtnBrowseClick nicely verbose :
Code
"On"        --- On (obviously english adverb)
"btn"       --- Button
"Browse"    --- Button name
"Click"     --- on what? --> on click
"btnBrowse" --- also Variable name of button...

Quote
4.3. filenames should be lower case and if you need more clarity you can use underscores. This prevents nasty case sensitivity problems in different oses.
I have not found any camel case / upper case filename in the patch?

Quote
5.3. It is better to use wxString::Format when there is a string which will be translated instead of using operator+, different languages have different word order.
Doesn't this add unicode problems? Or how do i printf a wxString with unicode support?

Quote
5.8. Repeated calls to prj->GetGlobs()[i\] aren't good idea - store them in variables
isn't this optimized out? Isn't a copy slower?

Quote
6. Do not pass nullptr when creating dialogs. It leads to really bad problems on linux.
what instead?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: User interface for project glob feature
« Reply #14 on: August 29, 2018, 12:36:27 am »
Can you point out the line in the patch?
This one: "@param glob the globs to add to the project."

Not really... there is no independent  read back possibility from script bindings, to check the success... If i remember correctly i have not implemented any test for all project functions, because it was not possible to create a project from the script binding and get a independent result from the function (compare a pre made project file for example) ... Testing project binding should not be topic for this patch... If there is need we should create a new topic/ticket
Ok, not testing, but what about setglobs and getglobs support in scripting?

suggestions? I think OnbtnBrowseClick nicely verbose :
OnBrowseClick is obvious and clear, IMO. If you want to stick btn or button you should make it CamelCase. Nobody cares if the variable for the button has the same name as the method name.

I have not found any camel case / upper case filename in the patch?
There you go:
+#include "dlgEditProjectGlob.h"
+#include "dlgManageGlobs.h"
+#include "dlgEditProjectGlob.h"

It seems only the includes are broken.

Doesn't this add unicode problems? Or how do i printf a wxString with unicode support?
No. Use .wx_str() when calling wxString::Format, you can also use the short F function.

Quote
5.8. Repeated calls to prj->GetGlobs()[i\] aren't good idea - store them in variables
isn't this optimized out? Isn't a copy slower?
How calling an unknown method from a dll could be optimized away? But I don't really care too much for optimizations, copy pasting shows the laziness of the writer of the code and it is hard to read because it is more text and you should verify that the function call doesn't return different value every time it is called.

Quote
6. Do not pass nullptr when creating dialogs. It leads to really bad problems on linux.
what instead?
Either a parent dialog or the main frame or the app window (these two can be accessed from the manager class).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]