davsclaus commented on code in PR #24351:
URL: https://github.com/apache/camel/pull/24351#discussion_r3504782652


##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ConfigurationTab.java:
##########
@@ -44,6 +46,7 @@
 
 class ConfigurationTab implements MonitorTab {
 
+    private static final int MOUSE_SCROLL_LINES = 3;

Review Comment:
   This same `MOUSE_SCROLL_LINES = 3` constant is now declared independently in 
11 files (plus the pre-existing one in `ShellPanel`). Consider defining it once 
— e.g. as a constant on `MonitorTab` — so the scroll speed is configurable in a 
single place.



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ShellPanel.java:
##########
@@ -116,6 +116,22 @@ void cycleHeight() {
         splitIndex = (splitIndex + 1) % SPLIT_PERCENTS.length;
     }
 
+    /**
+     * Sets the panel height to the nearest preset percentage matching the 
given target. Used by mouse drag resize.
+     */
+    void setSplitPercent(int percent) {

Review Comment:
   This `setSplitPercent` method is identical to the one added in `AiPanel`. 
Consider extracting it to a shared helper or base class to avoid the 
duplication.



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java:
##########
@@ -719,6 +735,113 @@ private boolean handleTabKeys(KeyEvent ke) {
         return false;
     }
 
+    private boolean handleMouseEvent(MouseEvent me) {
+        // Panel border drag resize: detect press on the border row, then 
track drag
+        if (panelBorderY >= 0 && lastContentArea != null && 
(shellPanel.isOpen() || aiPanel.isOpen())) {
+            if (me.isPress() && Math.abs(me.y() - panelBorderY) <= 1) {
+                draggingPanelBorder = true;
+                return true;
+            }
+            if (draggingPanelBorder && me.kind() == MouseEventKind.DRAG) {
+                int contentHeight = lastContentArea.height();
+                if (contentHeight > 0) {
+                    int panelHeight = lastContentArea.y() + contentHeight - 
me.y();
+                    int percent = Math.max(10, Math.min(100, panelHeight * 100 
/ contentHeight));
+                    if (shellPanel.isOpen()) {
+                        shellPanel.setSplitPercent(percent);
+                    } else {
+                        aiPanel.setSplitPercent(percent);
+                    }
+                }
+                return true;
+            }
+            if (draggingPanelBorder && me.isRelease()) {
+                draggingPanelBorder = false;
+                return true;
+            }
+        }
+
+        // Tab bar clicks: detect which tab was clicked and switch to it
+        if (me.isClick() && lastTabsArea != null && lastTabLabels != null) {
+            int mx = me.x();
+            int my = me.y();
+            // Tabs render on the second row of the tabs area (y+1)
+            int tabsY = lastTabsArea.height() >= 2 ? lastTabsArea.y() + 1 : 
lastTabsArea.y();
+            if (my == tabsY && mx >= lastTabsArea.x() && mx < lastTabsArea.x() 
+ lastTabsArea.width()) {
+                int clickedTab = findClickedTab(mx - lastTabsArea.x());
+                if (clickedTab >= 0) {
+                    if (isInfraSelected()) {
+                        // Infra mode: map 0→Overview, 1→Log
+                        int realTab = clickedTab == 1 ? TAB_LOG : TAB_OVERVIEW;
+                        tabsState.select(realTab);
+                    } else {
+                        tabRegistry.handleTabKey(clickedTab, ctx, dataService);
+                    }
+                    return true;
+                }
+            }
+        }
+
+        // Mouse events in the content area: delegate to the active tab
+        if (lastContentArea != null) {
+            int mx = me.x();
+            int my = me.y();
+            if (mx >= lastContentArea.x() && mx < lastContentArea.x() + 
lastContentArea.width()
+                    && my >= lastContentArea.y() && my < lastContentArea.y() + 
lastContentArea.height()) {
+                // Popups intercept before the tab
+                if (popupManager.isMorePopupVisible() || 
popupManager.isSwitchPopupVisible()
+                        || filesBrowser.isVisible() || 
actionsPopup.isVisible()) {
+                    return false;
+                }
+                MonitorTab activeTab = tabRegistry.activeTab();
+                if (activeTab != null && activeTab.handleMouseEvent(me, 
lastContentArea)) {
+                    return true;
+                }
+                // Scroll events that the tab did not handle: map to 
navigateUp/Down
+                if (me.kind() == MouseEventKind.SCROLL_UP) {
+                    tabRegistry.navigateUp();
+                    tabRegistry.navigateUp();
+                    tabRegistry.navigateUp();

Review Comment:
   The three repeated `navigateUp()` / `navigateDown()` calls are a magic 
number that should match `MOUSE_SCROLL_LINES`. Consider using a loop:
   ```suggestion
                       for (int i = 0; i < 3; i++) {
                           tabRegistry.navigateUp();
                       }
   ```
   (And similarly for `navigateDown` below.)



-- 
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]

Reply via email to