gnodet commented on code in PR #24351:
URL: https://github.com/apache/camel/pull/24351#discussion_r3508072680
##########
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:
Good point. I'll move it to a shared constant on `MonitorTab` (or a small
`MouseConstants` utility) so scroll speed is controlled in one place. Will
address in the next push.
##########
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:
Agreed — `setSplitPercent` is identical in both. I'll extract it into the
`DragSplit` helper (which already owns the split logic) so the panels just
delegate to it.
##########
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:
Good catch — that should indeed reference the constant rather than
hard-coding 3 repeated calls. Will fix.
--
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]