forked from Shinonome/dots-hyprland
sideleft: expand button
This commit is contained in:
@@ -6,7 +6,12 @@ import { NavigationIndicator } from './cairo_navigationindicator.js';
|
|||||||
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||||
import { DoubleRevealer } from '../.widgethacks/advancedrevealers.js';
|
import { DoubleRevealer } from '../.widgethacks/advancedrevealers.js';
|
||||||
|
|
||||||
export const TabContainer = ({ icons, names, children, className = '', setup = () => { }, ...rest }) => {
|
export const TabContainer = ({
|
||||||
|
icons, names, children,
|
||||||
|
className = '', setup = () => { },
|
||||||
|
extraTabStripWidgets = [],
|
||||||
|
...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);
|
||||||
@@ -52,10 +57,17 @@ export const TabContainer = ({ icons, names, children, className = '', setup = (
|
|||||||
onScrollUp: () => mainBox.prevTab(),
|
onScrollUp: () => mainBox.prevTab(),
|
||||||
onScrollDown: () => mainBox.nextTab(),
|
onScrollDown: () => mainBox.nextTab(),
|
||||||
child: Box({
|
child: Box({
|
||||||
vertical: true,
|
className: 'spacing-h-5',
|
||||||
children: [
|
children: [
|
||||||
tabs,
|
Box({
|
||||||
tabIndicatorLine
|
vertical: true,
|
||||||
|
hexpand: true,
|
||||||
|
children: [
|
||||||
|
tabs,
|
||||||
|
tabIndicatorLine
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
...extraTabStripWidgets,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
})]
|
})]
|
||||||
|
|||||||
@@ -28,37 +28,56 @@ const SIDEBARTABS = {
|
|||||||
}
|
}
|
||||||
const CONTENTS = userOptions.sidebar.pages.order.map((tabName) => SIDEBARTABS[tabName])
|
const CONTENTS = userOptions.sidebar.pages.order.map((tabName) => SIDEBARTABS[tabName])
|
||||||
|
|
||||||
const pinButton = Button({
|
// const pinButton = Button({
|
||||||
|
// attribute: {
|
||||||
|
// 'enabled': false,
|
||||||
|
// 'toggle': (self) => {
|
||||||
|
// self.attribute.enabled = !self.attribute.enabled;
|
||||||
|
// self.toggleClassName('sidebar-controlbtn-enabled', self.attribute.enabled);
|
||||||
|
|
||||||
|
// const sideleftWindow = App.getWindow('sideleft');
|
||||||
|
// const sideleftContent = sideleftWindow.get_children()[0].get_children()[0].get_children()[1];
|
||||||
|
|
||||||
|
// sideleftContent.toggleClassName('sidebar-pinned', self.attribute.enabled);
|
||||||
|
|
||||||
|
// if (self.attribute.enabled) {
|
||||||
|
// sideleftWindow.exclusivity = 'exclusive';
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// sideleftWindow.exclusivity = 'normal';
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// vpack: 'start',
|
||||||
|
// className: 'sidebar-controlbtn',
|
||||||
|
// child: MaterialIcon('push_pin', 'larger'),
|
||||||
|
// tooltipText: `Pin sidebar (${userOptions.keybinds.sidebar.pin})`,
|
||||||
|
// onClicked: (self) => self.attribute.toggle(self),
|
||||||
|
// setup: (self) => {
|
||||||
|
// setupCursorHover(self);
|
||||||
|
// self.hook(App, (self, currentName, visible) => {
|
||||||
|
// if (currentName === 'sideleft' && visible) self.grab_focus();
|
||||||
|
// })
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
|
||||||
|
const expandButton = Button({
|
||||||
attribute: {
|
attribute: {
|
||||||
'enabled': false,
|
'enabled': false,
|
||||||
'toggle': (self) => {
|
'toggle': (self) => {
|
||||||
self.attribute.enabled = !self.attribute.enabled;
|
self.attribute.enabled = !self.attribute.enabled;
|
||||||
self.toggleClassName('sidebar-pin-enabled', self.attribute.enabled);
|
self.toggleClassName('sidebar-controlbtn-enabled', self.attribute.enabled);
|
||||||
|
|
||||||
const sideleftWindow = App.getWindow('sideleft');
|
widgetContent.toggleClassName('sidebar-left-expanded', self.attribute.enabled);
|
||||||
const sideleftContent = sideleftWindow.get_children()[0].get_children()[0].get_children()[1];
|
widgetContent.toggleClassName('sidebar-left', !self.attribute.enabled);
|
||||||
|
|
||||||
sideleftContent.toggleClassName('sidebar-pinned', self.attribute.enabled);
|
|
||||||
|
|
||||||
if (self.attribute.enabled) {
|
|
||||||
sideleftWindow.exclusivity = 'on-demad';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sideleftWindow.exclusivity = 'normal';
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
vpack: 'start',
|
vpack: 'start',
|
||||||
className: 'sidebar-pin',
|
className: 'sidebar-controlbtn',
|
||||||
child: MaterialIcon('push_pin', 'larger'),
|
child: MaterialIcon('expand_content', 'larger'),
|
||||||
tooltipText: 'Pin sidebar (Ctrl+P)',
|
tooltipText: `Expand sidebar (${userOptions.keybinds.sidebar.expand})`,
|
||||||
onClicked: (self) => self.attribute.toggle(self),
|
onClicked: (self) => self.attribute.toggle(self),
|
||||||
setup: (self) => {
|
setup: setupCursorHover,
|
||||||
setupCursorHover(self);
|
|
||||||
self.hook(App, (self, currentName, visible) => {
|
|
||||||
if (currentName === 'sideleft' && visible) self.grab_focus();
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const widgetContent = TabContainer({
|
export const widgetContent = TabContainer({
|
||||||
@@ -66,56 +85,64 @@ export const widgetContent = TabContainer({
|
|||||||
names: CONTENTS.map((item) => item.friendlyName),
|
names: CONTENTS.map((item) => item.friendlyName),
|
||||||
children: CONTENTS.map((item) => item.content),
|
children: CONTENTS.map((item) => item.content),
|
||||||
className: 'sidebar-left spacing-v-10',
|
className: 'sidebar-left spacing-v-10',
|
||||||
setup: (self) => self.hook(App, (self, currentName, visible) => {
|
// setup: (self) => self.hook(App, (self, currentName, visible) => {
|
||||||
if (currentName === 'sideleft')
|
// if (currentName === 'sideleft')
|
||||||
self.toggleClassName('sidebar-pinned', pinButton.attribute.enabled && visible);
|
// self.toggleClassName('sidebar-pinned', pinButton.attribute.enabled && visible);
|
||||||
}),
|
// }),
|
||||||
|
extraTabStripWidgets: [
|
||||||
|
// pinButton,
|
||||||
|
expandButton,
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
export default () => Box({
|
export default () => {
|
||||||
// vertical: true,
|
return Box({
|
||||||
vexpand: true,
|
// vertical: true,
|
||||||
css: 'min-width: 2px;',
|
vexpand: true,
|
||||||
children: [
|
css: 'min-width: 2px;',
|
||||||
widgetContent,
|
children: [
|
||||||
],
|
widgetContent,
|
||||||
setup: (self) => self
|
],
|
||||||
.on('key-press-event', (widget, event) => { // Handle keybinds
|
setup: (self) => self
|
||||||
if (checkKeybind(event, userOptions.keybinds.sidebar.pin))
|
.on('key-press-event', (widget, event) => { // Handle keybinds
|
||||||
pinButton.attribute.toggle(pinButton);
|
if (checkKeybind(event, userOptions.keybinds.sidebar.cycleTab))
|
||||||
else if (checkKeybind(event, userOptions.keybinds.sidebar.cycleTab))
|
widgetContent.cycleTab();
|
||||||
widgetContent.cycleTab();
|
else if (checkKeybind(event, userOptions.keybinds.sidebar.nextTab))
|
||||||
else if (checkKeybind(event, userOptions.keybinds.sidebar.nextTab))
|
widgetContent.nextTab();
|
||||||
widgetContent.nextTab();
|
else if (checkKeybind(event, userOptions.keybinds.sidebar.prevTab))
|
||||||
else if (checkKeybind(event, userOptions.keybinds.sidebar.prevTab))
|
widgetContent.prevTab();
|
||||||
widgetContent.prevTab();
|
else if (checkKeybind(event, userOptions.keybinds.sidebar.expand))
|
||||||
|
expandButton.attribute.toggle(expandButton);
|
||||||
|
// if (checkKeybind(event, userOptions.keybinds.sidebar.pin))
|
||||||
|
// pinButton.attribute.toggle(pinButton);
|
||||||
|
|
||||||
if (widgetContent.attribute.names[widgetContent.attribute.shown.value] == 'APIs') { // If api tab is focused
|
if (widgetContent.attribute.names[widgetContent.attribute.shown.value] == 'APIs') { // If api tab is focused
|
||||||
// Focus entry when typing
|
// Focus entry when typing
|
||||||
if ((
|
if ((
|
||||||
!(event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK) &&
|
!(event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK) &&
|
||||||
event.get_keyval()[1] >= 32 && event.get_keyval()[1] <= 126 &&
|
event.get_keyval()[1] >= 32 && event.get_keyval()[1] <= 126 &&
|
||||||
widget != chatEntry && event.get_keyval()[1] != Gdk.KEY_space)
|
widget != chatEntry && event.get_keyval()[1] != Gdk.KEY_space)
|
||||||
||
|
||
|
||||||
((event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK) &&
|
((event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK) &&
|
||||||
event.get_keyval()[1] === Gdk.KEY_v)
|
event.get_keyval()[1] === Gdk.KEY_v)
|
||||||
) {
|
) {
|
||||||
chatEntry.grab_focus();
|
chatEntry.grab_focus();
|
||||||
const buffer = chatEntry.get_buffer();
|
const buffer = chatEntry.get_buffer();
|
||||||
buffer.set_text(buffer.text + String.fromCharCode(event.get_keyval()[1]), -1);
|
buffer.set_text(buffer.text + String.fromCharCode(event.get_keyval()[1]), -1);
|
||||||
buffer.place_cursor(buffer.get_iter_at_offset(-1));
|
buffer.place_cursor(buffer.get_iter_at_offset(-1));
|
||||||
|
}
|
||||||
|
// Switch API type
|
||||||
|
else if (checkKeybind(event, userOptions.keybinds.sidebar.apis.nextTab)) {
|
||||||
|
const toSwitchTab = widgetContent.attribute.children[widgetContent.attribute.shown.value];
|
||||||
|
toSwitchTab.nextTab();
|
||||||
|
}
|
||||||
|
else if (checkKeybind(event, userOptions.keybinds.sidebar.apis.prevTab)) {
|
||||||
|
const toSwitchTab = widgetContent.attribute.children[widgetContent.attribute.shown.value];
|
||||||
|
toSwitchTab.prevTab();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Switch API type
|
|
||||||
else if (checkKeybind(event, userOptions.keybinds.sidebar.apis.nextTab)) {
|
|
||||||
const toSwitchTab = widgetContent.attribute.children[widgetContent.attribute.shown.value];
|
|
||||||
toSwitchTab.nextTab();
|
|
||||||
}
|
|
||||||
else if (checkKeybind(event, userOptions.keybinds.sidebar.apis.prevTab)) {
|
|
||||||
const toSwitchTab = widgetContent.attribute.children[widgetContent.attribute.shown.value];
|
|
||||||
toSwitchTab.prevTab();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
,
|
,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ $sidebar_chat_textboxareaColor: mix($onSurfaceVariant, $surfaceVariant, 40%);
|
|||||||
padding: 1.023rem;
|
padding: 1.023rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-left-expanded {
|
||||||
|
@include menu_decel;
|
||||||
|
@include elevation-border;
|
||||||
|
@include elevation2;
|
||||||
|
border-radius: $rounding_large - $elevation_margin + 0.068rem;
|
||||||
|
min-width: 54.545rem;
|
||||||
|
background-color: $background;
|
||||||
|
padding: 1.023rem;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-group {
|
.sidebar-group {
|
||||||
@include normal-rounding;
|
@include normal-rounding;
|
||||||
@include group-padding;
|
@include group-padding;
|
||||||
@@ -826,7 +836,7 @@ $skeleton-accent: mix($secondary, $onSecondary, 50%);
|
|||||||
background-color: $activecolor;
|
background-color: $activecolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-pin {
|
.sidebar-controlbtn {
|
||||||
@include small-rounding;
|
@include small-rounding;
|
||||||
@include element_decel;
|
@include element_decel;
|
||||||
min-height: 2.386rem;
|
min-height: 2.386rem;
|
||||||
@@ -834,16 +844,16 @@ $skeleton-accent: mix($secondary, $onSecondary, 50%);
|
|||||||
color: $onSurface;
|
color: $onSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-pin:hover,
|
.sidebar-controlbtn:hover,
|
||||||
.sidebar-pin:focus {
|
.sidebar-controlbtn:focus {
|
||||||
background-color: $hovercolor;
|
background-color: $hovercolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-pin:active {
|
.sidebar-controlbtn:active {
|
||||||
background-color: $activecolor;
|
background-color: $activecolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-pin-enabled {
|
.sidebar-controlbtn-enabled {
|
||||||
background-color: $primary;
|
background-color: $primary;
|
||||||
|
|
||||||
label {
|
label {
|
||||||
@@ -851,12 +861,12 @@ $skeleton-accent: mix($secondary, $onSecondary, 50%);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-pin-enabled:hover,
|
.sidebar-controlbtn-enabled:hover,
|
||||||
.sidebar-pin-enabled:focus {
|
.sidebar-controlbtn-enabled:focus {
|
||||||
background-color: mix($primary, $hovercolor, 70%);
|
background-color: mix($primary, $hovercolor, 70%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-pin-enabled:active {
|
.sidebar-controlbtn-enabled:active {
|
||||||
background-color: mix($primary, $hovercolor, 40%);
|
background-color: mix($primary, $hovercolor, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user