forked from Shinonome/dots-hyprland
ags: add tab scrolling
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
||||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
const { Box, Button, Label, Overlay, Stack } = Widget;
|
const { Box, Button, EventBox, Label, Overlay, Stack } = Widget;
|
||||||
import { MaterialIcon } from './materialicon.js';
|
import { MaterialIcon } from './materialicon.js';
|
||||||
import { NavigationIndicator } from './cairo_navigationindicator.js';
|
import { NavigationIndicator } from './cairo_navigationindicator.js';
|
||||||
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||||
|
|
||||||
export const TabContainer = ({ icons, names, children, className = '', setup = () => {}, ...rest }) => {
|
export const TabContainer = ({ icons, names, children, className = '', setup = () => { }, ...rest }) => {
|
||||||
const shownIndex = Variable(0);
|
const shownIndex = Variable(0);
|
||||||
let previousShownIndex = 0;
|
let previousShownIndex = 0;
|
||||||
const count = Math.min(icons.length, names.length, children.length);
|
const count = Math.min(icons.length, names.length, children.length);
|
||||||
@@ -47,12 +47,19 @@ export const TabContainer = ({ icons, names, children, className = '', setup = (
|
|||||||
})],
|
})],
|
||||||
});
|
});
|
||||||
const tabSection = Box({
|
const tabSection = Box({
|
||||||
vertical: true,
|
homogeneous: true,
|
||||||
hexpand: true,
|
children: [EventBox({
|
||||||
children: [
|
onScrollUp: () => mainBox.prevTab(),
|
||||||
tabs,
|
onScrollDown: () => mainBox.nextTab(),
|
||||||
tabIndicatorLine
|
child: Box({
|
||||||
]
|
vertical: true,
|
||||||
|
hexpand: true,
|
||||||
|
children: [
|
||||||
|
tabs,
|
||||||
|
tabIndicatorLine
|
||||||
|
]
|
||||||
|
})
|
||||||
|
})]
|
||||||
});
|
});
|
||||||
const contentStack = Stack({
|
const contentStack = Stack({
|
||||||
transition: 'slide_left_right',
|
transition: 'slide_left_right',
|
||||||
|
|||||||
@@ -198,27 +198,31 @@ function switchToTab(id) {
|
|||||||
currentApiId = id;
|
currentApiId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiSwitcher = CenterBox({
|
const apiSwitcher = EventBox({
|
||||||
centerWidget: Box({
|
onScrollUp: () => apiWidgets.attribute.prevTab(),
|
||||||
className: 'sidebar-chat-apiswitcher spacing-h-5',
|
onScrollDown: () => apiWidgets.attribute.nextTab(),
|
||||||
hpack: 'center',
|
child: CenterBox({
|
||||||
children: APIS.map((api, id) => Button({
|
centerWidget: Box({
|
||||||
child: api.tabIcon,
|
className: 'sidebar-chat-apiswitcher spacing-h-5',
|
||||||
tooltipText: api.name,
|
hpack: 'center',
|
||||||
setup: setupCursorHover,
|
children: APIS.map((api, id) => Button({
|
||||||
onClicked: () => {
|
child: api.tabIcon,
|
||||||
switchToTab(id);
|
tooltipText: api.name,
|
||||||
}
|
setup: setupCursorHover,
|
||||||
})),
|
onClicked: () => {
|
||||||
}),
|
switchToTab(id);
|
||||||
endWidget: Button({
|
}
|
||||||
hpack: 'end',
|
})),
|
||||||
className: 'txt-subtext txt-norm icon-material',
|
}),
|
||||||
label: 'lightbulb',
|
endWidget: Button({
|
||||||
tooltipText: 'Use PageUp/PageDown to switch between API pages',
|
hpack: 'end',
|
||||||
setup: setupCursorHoverInfo,
|
className: 'txt-subtext txt-norm icon-material',
|
||||||
}),
|
label: 'lightbulb',
|
||||||
})
|
tooltipText: 'Use PageUp/PageDown to switch between API pages',
|
||||||
|
setup: setupCursorHoverInfo,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
const apiWidgets = Widget.Box({
|
const apiWidgets = Widget.Box({
|
||||||
attribute: {
|
attribute: {
|
||||||
|
|||||||
Reference in New Issue
Block a user