2021-05-24 22:29:49 +02:00
|
|
|
import options from "../../services/options.js";
|
2021-06-05 14:01:21 +02:00
|
|
|
import splitService from "../../services/resizer.js";
|
2022-12-02 16:46:14 +01:00
|
|
|
import CommandButtonWidget from "./command_button.js";
|
2024-08-01 14:18:21 +08:00
|
|
|
import { t } from "../../services/i18n.js";
|
2021-05-22 21:35:25 +02:00
|
|
|
|
2022-12-02 16:46:14 +01:00
|
|
|
export default class LeftPaneToggleWidget extends CommandButtonWidget {
|
2024-11-23 00:07:40 +02:00
|
|
|
constructor(isHorizontalLayout) {
|
2022-12-02 16:46:14 +01:00
|
|
|
super();
|
2021-05-22 21:35:25 +02:00
|
|
|
|
2024-11-30 01:20:47 +02:00
|
|
|
this.class(isHorizontalLayout ? "toggle-button" : "launcher-button");
|
2022-12-11 13:20:37 +01:00
|
|
|
|
2024-11-30 01:23:54 +02:00
|
|
|
this.settings.icon = () => {
|
|
|
|
if (options.get("layoutOrientation") === "horizontal") {
|
|
|
|
return "bx-sidebar";
|
|
|
|
}
|
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
return options.is("leftPaneVisible") ? "bx-chevrons-left" : "bx-chevrons-right";
|
2024-11-30 01:23:54 +02:00
|
|
|
};
|
2021-05-22 21:35:25 +02:00
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
this.settings.title = () => (options.is("leftPaneVisible") ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel"));
|
2021-05-22 21:35:25 +02:00
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
this.settings.command = () => (options.is("leftPaneVisible") ? "hideLeftPane" : "showLeftPane");
|
2024-11-23 00:07:40 +02:00
|
|
|
|
|
|
|
if (isHorizontalLayout) {
|
|
|
|
this.settings.titlePlacement = "bottom";
|
|
|
|
}
|
2022-12-02 16:46:14 +01:00
|
|
|
}
|
2021-05-22 21:35:25 +02:00
|
|
|
|
2022-12-02 16:46:14 +01:00
|
|
|
refreshIcon() {
|
2021-05-22 21:35:25 +02:00
|
|
|
super.refreshIcon();
|
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
splitService.setupLeftPaneResizer(options.is("leftPaneVisible"));
|
2021-05-22 21:35:25 +02:00
|
|
|
}
|
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
entitiesReloadedEvent({ loadResults }) {
|
2021-05-22 21:35:25 +02:00
|
|
|
if (loadResults.isOptionReloaded("leftPaneVisible")) {
|
|
|
|
this.refreshIcon();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|