nadment commented on code in PR #6267:
URL: https://github.com/apache/hop/pull/6267#discussion_r2651810827
##########
ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java:
##########
@@ -1323,13 +1281,25 @@ protected void addPerspectivesToolbar() {
formData.bottom = new FormAttachment(statusToolbar, 0);
mainHopGuiComposite.setLayoutData(formData);
- perspectivesToolbar = new ToolBar(mainHopGuiComposite, SWT.WRAP |
SWT.RIGHT | SWT.VERTICAL);
- PropsUi.setLook(perspectivesToolbar, Props.WIDGET_STYLE_TOOLBAR);
- FormData fdToolBar = new FormData();
- fdToolBar.left = new FormAttachment(0, 0);
- fdToolBar.top = new FormAttachment(0, 0);
- fdToolBar.bottom = new FormAttachment(100, 0);
- perspectivesToolbar.setLayoutData(fdToolBar);
+ // Create custom sidebar composite instead of ToolBar for better control
+ perspectivesSidebar = new Composite(mainHopGuiComposite, SWT.NONE);
+ PropsUi.setLook(perspectivesSidebar);
+
perspectivesSidebar.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
Review Comment:
System color widget background doesn't work for Windows
##########
ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java:
##########
@@ -594,77 +599,30 @@ private void loadPerspectives() {
ClassLoader classLoader =
pluginRegistry.getClassLoader(perspectivePlugin);
ToolItem item;
- if (EnvironmentUtils.getInstance().isWeb()) {
- item =
- addWebToolbarButton(
- perspectivePlugin.getIds()[0],
- this.perspectivesToolbar,
- perspectivePlugin.getImageFile(),
- tooltip,
- // TODO: check if there is unnecessary refresh
- event -> {
- // Special handling for ExplorerPerspective: if already
active, toggle file
- // explorer panel instead of just activating
- if (perspective instanceof ExplorerPerspective
- && isActivePerspective(perspective)) {
- ((ExplorerPerspective)
perspective).toggleFileExplorerPanel();
- } else {
- // Normal perspective activation
- setActivePerspective(perspective);
- }
- });
- } else {
- item = new ToolItem(this.perspectivesToolbar, SWT.RADIO);
- item.setToolTipText(tooltip);
- item.addListener(
- SWT.Selection,
- event -> {
- // Event is sent first to the unselected tool item and then
the selected item.
- // To avoid unnecessary refresh, only process on the selected
item.
- if (item.getSelection()) {
- // Special handling for ExplorerPerspective: check if
control is already on top
- // (truly active and visible) before toggling
- if (perspective instanceof ExplorerPerspective
- && mainPerspectivesComposite != null
- && !mainPerspectivesComposite.isDisposed()) {
- StackLayout layout = (StackLayout)
mainPerspectivesComposite.getLayout();
- // Only toggle if the perspective control is already on
top (truly active)
- if (layout.topControl == perspective.getControl()) {
- ((ExplorerPerspective)
perspective).toggleFileExplorerPanel();
- return; // Don't call setActivePerspective
- }
- }
- // Normal perspective activation
- setActivePerspective(perspective);
- }
- });
- Image image =
- GuiResource.getInstance()
- .getImage(
- perspectivePlugin.getImageFile(),
- classLoader,
- ConstUi.SMALL_ICON_SIZE,
- ConstUi.SMALL_ICON_SIZE);
- if (image != null) {
- item.setImage(image);
- }
- }
- item.setData(perspective);
-
- // Store reference to ExplorerPerspective ToolItem for dynamic tooltip
updates
- if (perspective instanceof ExplorerPerspective) {
- explorerPerspectiveToolItem = item;
- }
+ int sidebarIconSize = 21;
+ Image image =
+ GuiResource.getInstance()
+ .getImage(
+ perspectivePlugin.getImageFile(),
+ classLoader,
+ sidebarIconSize,
+ sidebarIconSize);
+
+ // Create styled sidebar button with hover, selection, and rounded
corners
+ // This works for both desktop SWT and web/RAP modes
+ createStyledSidebarButton(perspectivesSidebar, image, tooltip,
perspective);
// See if there's a shortcut for the perspective, add it to tooltip...
KeyboardShortcut shortcut =
GuiRegistry.getInstance()
.findKeyboardShortcut(perspectiveClass.getName(), "activate",
Const.isOSX());
if (shortcut != null) {
- item.setToolTipText(item.getToolTipText() + " (" + shortcut + ')');
+ // Update tooltip with shortcut - handled in SidebarButton
constructor
+ // The tooltip was already set when creating the button
Review Comment:
Shortcuts not showing in Windows?
##########
ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java:
##########
@@ -1323,13 +1281,25 @@ protected void addPerspectivesToolbar() {
formData.bottom = new FormAttachment(statusToolbar, 0);
mainHopGuiComposite.setLayoutData(formData);
- perspectivesToolbar = new ToolBar(mainHopGuiComposite, SWT.WRAP |
SWT.RIGHT | SWT.VERTICAL);
- PropsUi.setLook(perspectivesToolbar, Props.WIDGET_STYLE_TOOLBAR);
- FormData fdToolBar = new FormData();
- fdToolBar.left = new FormAttachment(0, 0);
- fdToolBar.top = new FormAttachment(0, 0);
- fdToolBar.bottom = new FormAttachment(100, 0);
- perspectivesToolbar.setLayoutData(fdToolBar);
+ // Create custom sidebar composite instead of ToolBar for better control
+ perspectivesSidebar = new Composite(mainHopGuiComposite, SWT.NONE);
+ PropsUi.setLook(perspectivesSidebar);
+
perspectivesSidebar.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+
+ // Use GridLayout for vertical stacking
+ org.eclipse.swt.layout.GridLayout sidebarLayout =
+ new org.eclipse.swt.layout.GridLayout(1, false);
+ sidebarLayout.marginWidth = 1;
+ sidebarLayout.marginHeight = 2;
+ sidebarLayout.verticalSpacing = 1; // Minimal spacing between buttons
+ perspectivesSidebar.setLayout(sidebarLayout);
+
+ FormData fdSidebar = new FormData();
+ fdSidebar.left = new FormAttachment(0, 0);
+ fdSidebar.top = new FormAttachment(0, 0);
+ fdSidebar.bottom = new FormAttachment(100, 0);
+ fdSidebar.width = 40; // Fixed width for sidebar (80% of 50px)
Review Comment:
Use zoom factor
fdSidebar.width = (int) (40 * PropsUi.getNativeZoomFactor()); // Fixed width
for sidebar (80% of 50px)
##########
ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java:
##########
@@ -1586,14 +1515,245 @@ public void setActivePerspective(IHopPerspective
perspective) {
}
public boolean isActivePerspective(IHopPerspective perspective) {
- if (perspective != null) {
- for (ToolItem item : perspectivesToolbar.getItems()) {
- if (perspective.equals(item.getData())) {
- return item.getSelection();
+ return activePerspective != null && activePerspective.equals(perspective);
+ }
+
+ /** Update the visual selection state of sidebar buttons when perspective
changes. */
+ private void updateSidebarButtonSelection(IHopPerspective activePerspective)
{
+ for (SidebarButton button : sidebarButtons) {
+ button.setSelected(button.perspective.equals(activePerspective));
+ }
+ }
+
+ /**
+ * Create a styled sidebar button with modern appearance. Features rounded
corners, hover effects,
+ * and selection colors.
+ */
+ private void createStyledSidebarButton(
+ Composite parent, Image image, String tooltip, IHopPerspective
perspective) {
+
+ SidebarButton button = new SidebarButton(parent, image, tooltip,
perspective);
+ sidebarButtons.add(button);
+
+ // Set layout data for GridLayout (34px = 80% of 42px)
+ org.eclipse.swt.layout.GridData gd = new org.eclipse.swt.layout.GridData();
+ gd.widthHint = 34;
Review Comment:
Use zoom factor
int size = (int) (34 * PropsUi.getNativeZoomFactor());
// Set layout data for GridLayout (34px = 80% of 42px)
GridData gd = new GridData();
gd.widthHint = size;
gd.heightHint = size;
##########
ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java:
##########
@@ -1586,14 +1515,245 @@ public void setActivePerspective(IHopPerspective
perspective) {
}
public boolean isActivePerspective(IHopPerspective perspective) {
- if (perspective != null) {
- for (ToolItem item : perspectivesToolbar.getItems()) {
- if (perspective.equals(item.getData())) {
- return item.getSelection();
+ return activePerspective != null && activePerspective.equals(perspective);
+ }
+
+ /** Update the visual selection state of sidebar buttons when perspective
changes. */
+ private void updateSidebarButtonSelection(IHopPerspective activePerspective)
{
+ for (SidebarButton button : sidebarButtons) {
+ button.setSelected(button.perspective.equals(activePerspective));
+ }
+ }
+
+ /**
+ * Create a styled sidebar button with modern appearance. Features rounded
corners, hover effects,
+ * and selection colors.
+ */
+ private void createStyledSidebarButton(
+ Composite parent, Image image, String tooltip, IHopPerspective
perspective) {
+
+ SidebarButton button = new SidebarButton(parent, image, tooltip,
perspective);
+ sidebarButtons.add(button);
+
+ // Set layout data for GridLayout (34px = 80% of 42px)
+ org.eclipse.swt.layout.GridData gd = new org.eclipse.swt.layout.GridData();
+ gd.widthHint = 34;
+ gd.heightHint = 34;
+ button.composite.setLayoutData(gd);
+ }
+
+ /** Custom sidebar button class with hover, selection, and rounded corners */
+ private class SidebarButton {
+ Composite composite;
+ Image image;
+ IHopPerspective perspective;
+ boolean isHovered = false;
+ boolean isSelected = false;
+
+ Color selectionBg;
+ Color hoverBg;
+ Color normalBg;
+
+ public SidebarButton(
+ Composite parent, Image image, String tooltip, IHopPerspective
perspective) {
+ this.image = image;
+ this.perspective = perspective;
+
+ // Get colors for light/dark mode
+ PropsUi props = PropsUi.getInstance();
+ boolean isDarkMode = props.isDarkMode();
+
+ selectionBg = new Color(display, 0x4A, 0x9E, 0xFF);
+ if (isDarkMode) {
+ hoverBg = new Color(display, 0x3C, 0x3F, 0x41);
+ } else {
+ // Darker gray for more distinct hover effect
+ hoverBg = new Color(display, 0xD0, 0xD0, 0xD0);
+ }
+ // Use system background color to match the default background
+ normalBg = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
Review Comment:
// Use system background color to match the default background
normalBg = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
selectionBg = new Color(display, 0x4A, 0x9E, 0xFF);
if (isDarkMode) {
hoverBg = new Color(display, 0x3C, 0x3F, 0x41);
// System background doesn't work
if (OsHelper.isWindows()) {
normalBg = GuiResource.getInstance().getColorLightGray();
hoverBg = GuiResource.getInstance().getColorWhite();
}
} else {
// Darker gray for more distinct hover effect
hoverBg = new Color(display, 0xD0, 0xD0, 0xD0);
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]