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


##########
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:
   Done — `MOUSE_SCROLL_LINES` is now a single constant on the `MonitorTab` 
interface. The 9 tab classes that implement `MonitorTab` inherit it; the 3 that 
don't (`AiPanel`, `ShellPanel`, `DiagramSupport`) qualify it as 
`MonitorTab.MOUSE_SCROLL_LINES`. See commit 565b7ce.



##########
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:
   Done — `setSplitPercent` now delegates to `MonitorTab.nearestPresetIndex()`, 
a static utility on the shared interface. Both `ShellPanel` and `AiPanel` use 
it. See commit 565b7ce.



##########
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:
   Done — replaced the repeated calls with a `for (int i = 0; i < 
MonitorTab.MOUSE_SCROLL_LINES; i++)` loop for both `navigateUp()` and 
`navigateDown()`. See commit 565b7ce.



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