You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, it used some complicated internal datastructures to track
what buttons were available and manually painted them and handled mouse
clicks. This lead to a clunky and hard to extend toolbar.
This commit completely rewrites the toolbar. Now, each button is a
separate component (new ToolbarButton class deriving from JButton), so
painting and handling clicks works out of the box.
In previous commits, Action objects have been made available for each of
the toolbar buttons, that also had icons set already. These new
ToolbarButtons take all of their info from these actions. Most of this
was implemented by JButton already, but copying some properties
(selected, the selected icon and the rollover icon) is added by
ToolbarButton.
Before, buttons would be activated (e.g. giving the upload button a
color while the upload is in progress) by calling methods on the
toolbar. Now, the "selected" state of the Action / JButton is used for
this, which automatically changes the icon to the "selected" icon. This
removes the coupling between the verify/upload/save processes and the
EditorToolbar, leaving them only coupled to the Actions they are run
from. This also allows removing the Editor.toolbar instance variable,
since nobody needs to reference it anymore after it was created.
The `Editor.statusError()` method used to deactivate the run (verify)
button on the toolbar, but it seems there are no code paths that
activate this button and then go through statusError but not through the
regular deactivation, so this call was removed.
Because pressing shift changes the effect of some toolbar buttons, each
ToolbarButton can contain one or two Action objects. When shift is
pressed or released, the active Action object (as kept by JButton) is
exchanged for the other one, updating the effect of the button, the
tooltip and icon (though all related actions now use the same icon).
When one action becomes selected, that action stays active regardless of
the shift button, to provide user feedback (until the action is no
longer selected, then it listens to the shift key again).
By using separate Icon objects and files instead of manually cutting up
a single gif with all icons, it will also be easier to replace the icons
with vector icons later, to support high DPI screens more cleanly.
Define the buttons themselves (e.g. what buttons are present) still
happens in the EditorToolbar class, but it might be good to move these
elsewhere at some point.
References: arduino#4196
0 commit comments