Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize toolbar on OSX #23614

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

oneeyeman1
Copy link
Contributor

This is an attempt to introduce the toolbar customization functionality into the library.

However, I have couple of questions:

  1. Should this functionality be turned on based on the style/flag?
  2. According to the Apple documentation it is recommended to store the new toolbar configuration in the user preferences, so that it can be read it from on the next restart. Should this be turned on by some flag?
  3. I don't know if there should be any unit test for this, but I'd like to demonstrate it in the sample? What's the best way to do that? I'm thinking to turn off some buttons and show the customization dialog that will allow to drop the tool on the toolbar. Which one would you recommend?

Please review and give me your thoughts. Only OSX implementation is here - it is supported natively by OS.

MSW will follow and then GTK.

On OSX it is available with the right click and context menu selection.
On MSW it will be available thru the double click.
On GTK I'm thinking to follow OSX way as the GtkToolbar have a "context-menu" signal. And in GTK4 it probably can be done the same way on the GtkBox.

(This PR is not ready to be applied, unless you want it to get some testing on OSX first).

Thank you.

@vadz
Copy link
Contributor

vadz commented Jun 6, 2023

I have 2 comments about this:

  1. Please test your PRs in your own fork of wxWidgets when they haven't even reached compilable state yet, it's annoying to have to wait until CI builds for this PR finish before being able to run any other ones. In the meanwhile at least switch this one to the "Draft" state until it's really finished.
  2. Adding bool available parameter is not the right way to do whatever you want to do. Please don't do this, you should be able to add some wxToolBarTool::MarkAsAvailable() or whatever instead.

@vadz vadz added the work needed Too useful to close, but can't be applied in current state label Jun 6, 2023
Fix GTK bujild
@oneeyeman1 oneeyeman1 marked this pull request as draft June 6, 2023 20:30
@oneeyeman1
Copy link
Contributor Author

@vadz,

I have 2 comments about this:

  1. Please test your PRs in your own fork of wxWidgets when they haven't even reached compilable state yet, it's annoying to have to wait until CI builds for this PR finish before being able to run any other ones. In the meanwhile at least switch this one to the "Draft" state until it's really finished.

I don't have clang installed anywhere but on OSX, so I can't test it under this compiler.
But thank you for pointing out the "draft" switch. Now marked.

How do I unmark it from that? Should I just click on the "work-needed" link?

  1. Adding bool available parameter is not the right way to do whatever you want to do. Please don't do this, you should be able to add some wxToolBarTool::MarkAsAvailable() or whatever instead.

OK, thx.
Will do that. Probably name it "MarkAvailable()".
Let me know if the name is not up to coding standard.

Thx as always.

@oneeyeman1 oneeyeman1 marked this pull request as ready for review January 12, 2024 17:32
@oneeyeman1
Copy link
Contributor Author

@vadz,
I think it is now ready.

It would be nice if Stefan also could take a look.

Thx.

Copy link
Contributor

@vadz vadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check if this can be made to work elsewhere. Providing at least a generic implementation would be a good way to ensure we can do it, as long as this is only supported under Mac I'm not sure if we can use such API.

Comment on lines +49 to +50
void MarkAvailable(bool available) { m_available = available; }
bool IsAvailable() const { return m_available; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to add functions that only make sense for toolbar tools to base wxControl class. You will have to change the code to use them in wxToolBatTool only.

@@ -724,6 +724,7 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_RCLICKED, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_DROPDOWN, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_ENTER, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TB_CUSTOMIZE, wxCommandEvent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just TB is really not clear enough without any context.

Suggested change
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TB_CUSTOMIZE, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOLBAR_CUSTOMIZE, wxCommandEvent);

virtual wxToolBarToolBase *CreateTool(wxControl *control,
const wxString& label) override;

void *GetMacToolbar() { return m_macToolbar; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prevailing convention is to use OSX prefix, i.e.

Suggested change
void *GetMacToolbar() { return m_macToolbar; };
void *OSXGetToolbar() { return m_macToolbar; };

@@ -89,9 +89,11 @@ class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase
wxObject *clientData = nullptr,
const wxString& shortHelp = wxEmptyString,
const wxString& longHelp = wxEmptyString) override;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to avoid whitespace-only changes (even if you make them accidentally, nothing prevents you from looking at the diff and removing them afterwards).

@@ -314,7 +319,7 @@ class WXDLLIMPEXP_CORE wxToolBarBase : public wxControl
const wxString& shortHelp = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL)
{
return AddTool(toolid, label, bitmap, wxBitmapBundle(), kind, shortHelp);
return AddTool(toolid, label, bitmap, wxBitmapBundle(), kind, shortHelp, wxEmptyString, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

@@ -159,6 +159,19 @@ class wxToolBarToolBase : public wxObject

void SetDropdownMenu(wxMenu *menu);
wxMenu *GetDropdownMenu() const;

/**
Mark the tool to be not visible.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty misleading for a function called like this. You should say it may be used to mark the tool as being not currently visible if @c available is @false or something like that.

bool IsAvailable() const;

/**
Calling this function with the parameter set to false will not add the tool to the toolbar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Calling this function with the parameter set to false will not add the tool to the toolbar
Calling this function with the parameter set to false prevents the tool from being added to the toolbar.

@@ -470,6 +470,7 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar)
combo->Append("combobox with extremely, extremely, extremely, extremely long label");
combo->Append("in a");
combo->Append("toolbar");
combo->MarkAvailable( false );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create another initially unavailable control instead of hiding this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is not changed at all...

Comment on lines +288 to +290
Process a @c wxEVT_TB_CUSTOMIZE event. Under MSW and OSX
it will display native customization dialogs. On GTK it will
be generic.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be true, there is no implementation at all for MSW and just a stub for GTK. This is not necessarily a problem, but the documentation shouldn't like and you should check that the API you propose is at least in principle implementable under the other platforms.

@oneeyeman1
Copy link
Contributor Author

@vadz ,

We need to check if this can be made to work elsewhere. Providing at least a generic implementation would be a good way to ensure we can do it, as long as this is only supported under Mac I'm not sure if we can use such API.

On MSW it is possible to customize toolbar.

GTK does not support that and apparently the devs there are objecting to make it work.

And of course generic implementation we can do whatever we want,
We already have an API to do customization in the generic way..

@oneeyeman1
Copy link
Contributor Author

Also, I started with OSX, because I am not very familiar with OSX.

I will follow you review and apply where appropriate.

However, I'd like to ask you - if this will become mergeable will it be easier to do the MSW here or merge it and then change MSW?

Let me know.

Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work needed Too useful to close, but can't be applied in current state
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants