提交 e5e78f72 编写于 作者: B Benjamin Pasero

grid - add proper split actions to title

上级 fd187e94
......@@ -23,7 +23,9 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { CLOSE_EDITOR_COMMAND_ID, NAVIGATE_IN_GROUP_ONE_PREFIX, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, NAVIGATE_IN_GROUP_THREE_PREFIX, NAVIGATE_IN_GROUP_TWO_PREFIX } from 'vs/workbench/browser/parts/editor/editorCommands';
import { INextEditorGroupsService, Direction as SplitDirection, INextEditorGroup, CopyKind } from 'vs/workbench/services/editor/common/nextEditorGroupsService';
// TODo@grid this action should be removed in favour of the split vertical/horizontal actions
export class SplitEditorAction extends Action {
public static readonly ID = 'workbench.action.splitEditor';
......@@ -107,6 +109,64 @@ export class SplitEditorAction extends Action {
}
}
export class BaseSplitEditorGroupAction extends Action {
constructor(
id: string,
label: string,
clazz: string,
private direction: SplitDirection,
private nextEditorGroupsService: INextEditorGroupsService
) {
super(id, label, clazz);
}
public run(context?: IEditorIdentifier): TPromise<any> {
let group: INextEditorGroup;
if (context && context.group) {
group = this.nextEditorGroupsService.getGroup(context.group.id);
}
if (!group) {
group = this.nextEditorGroupsService.activeGroup;
}
const copyKind = group.activeEditor instanceof EditorInput && group.activeEditor.supportsSplitEditor() ? CopyKind.EDITOR : void 0;
this.nextEditorGroupsService.addGroup(group, this.direction, copyKind);
return TPromise.as(true);
}
}
export class SplitEditorGroupVerticalAction extends BaseSplitEditorGroupAction {
public static readonly ID = 'workbench.action.splitEditorGroupVertical';
public static readonly LABEL = nls.localize('splitEditorGroupVertical', "Split Editor Group Vertically");
constructor(
id: string,
label: string,
@INextEditorGroupsService nextEditorGroupsService: INextEditorGroupsService
) {
super(id, label, 'split-editor-vertical-action', SplitDirection.DOWN, nextEditorGroupsService);
}
}
export class SplitEditorGroupHorizontalAction extends BaseSplitEditorGroupAction {
public static readonly ID = 'workbench.action.splitEditorGroupHorizontal';
public static readonly LABEL = nls.localize('splitEditorGroupHorizontal', "Split Editor Group Horizontally");
constructor(
id: string,
label: string,
@INextEditorGroupsService nextEditorGroupsService: INextEditorGroupsService
) {
super(id, label, 'split-editor-horizontal-action', SplitDirection.RIGHT, nextEditorGroupsService);
}
}
export class JoinTwoGroupsAction extends Action {
public static readonly ID = 'workbench.action.joinTwoGroups';
......
......@@ -86,20 +86,20 @@
/** TODO@grid revisit the split editor action (vertical-layout/horizontal-layout does not exist anymore) */
.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-right-action {
background: url('split-editor-vertical.svg') center center no-repeat;
.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-horizontal-action {
background: url('split-editor-horizontal.svg') center center no-repeat;
}
.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-right-action,
.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-right-action {
background: url('split-editor-vertical-inverse.svg') center center no-repeat;
.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-horizontal-action,
.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-horizontal-action {
background: url('split-editor-horizontal-inverse.svg') center center no-repeat;
}
.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-down-action {
background: url('split-editor-horizontal.svg') center center no-repeat;
.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-vertical-action {
background: url('split-editor-vertical.svg') center center no-repeat;
}
.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-down-action,
.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-down-action {
background: url('split-editor-horizontal-inverse.svg') center center no-repeat;
.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-vertical-action,
.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-vertical-action {
background: url('split-editor-vertical-inverse.svg') center center no-repeat;
}
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><style>.icon-canvas-transparent{opacity:0;fill:#2d2d30}.icon-vs-out{fill:#2d2d30}.icon-vs-bg{fill:#c5c5c5}.icon-vs-fg{fill:#2b282e}</style><path class="icon-canvas-transparent" d="M16 16H0V0h16v16z" id="canvas"/><path class="icon-vs-out" d="M16 15H0V1h16v14z" id="outline" style="display: none;"/><path class="icon-vs-bg" d="M1 2v12h14V2H1zm13 11H2v-3h12v3zm0-5H2V5h12v3z" id="iconBg"/><g id="iconFg" style="display: none;"><path class="icon-vs-fg" d="M14 8H2V5h12v3zm0 2H2v3h12v-3z"/></g></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 -1 16 16" enable-background="new 0 -1 16 16"><path fill="#C5C5C5" d="M1 1v12h14v-12h-14zm1 3h4.999v8h-4.999v-8zm12 8h-5.001v-8h5.001v8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><style>.icon-canvas-transparent{opacity:0;fill:#f6f6f6}.icon-vs-out{fill:#f6f6f6}.icon-vs-bg{fill:#424242}.icon-vs-fg{fill:#f0eff1}</style><path class="icon-canvas-transparent" d="M16 16H0V0h16v16z" id="canvas"/><path class="icon-vs-out" d="M16 15H0V1h16v14z" id="outline" style="display: none;"/><path class="icon-vs-bg" d="M1 2v12h14V2H1zm13 11H2v-3h12v3zm0-5H2V5h12v3z" id="iconBg"/><g id="iconFg" style="display: none;"><path class="icon-vs-fg" d="M14 8H2V5h12v3zm0 2H2v3h12v-3z"/></g></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 -1 16 16" enable-background="new 0 -1 16 16"><path fill="#656565" d="M1 1v12h14v-12h-14zm1 3h4.999v8h-4.999v-8zm12 8h-5.001v-8h5.001v8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 -1 16 16" enable-background="new 0 -1 16 16"><path fill="#C5C5C5" d="M1 1v12h14v-12h-14zm1 3h4.999v8h-4.999v-8zm12 8h-5.001v-8h5.001v8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><style>.icon-canvas-transparent{opacity:0;fill:#2d2d30}.icon-vs-out{fill:#2d2d30}.icon-vs-bg{fill:#c5c5c5}.icon-vs-fg{fill:#2b282e}</style><path class="icon-canvas-transparent" d="M16 16H0V0h16v16z" id="canvas"/><path class="icon-vs-out" d="M16 15H0V1h16v14z" id="outline" style="display: none;"/><path class="icon-vs-bg" d="M1 2v12h14V2H1zm13 11H2v-3h12v3zm0-5H2V5h12v3z" id="iconBg"/><g id="iconFg" style="display: none;"><path class="icon-vs-fg" d="M14 8H2V5h12v3zm0 2H2v3h12v-3z"/></g></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 -1 16 16" enable-background="new 0 -1 16 16"><path fill="#656565" d="M1 1v12h14v-12h-14zm1 3h4.999v8h-4.999v-8zm12 8h-5.001v-8h5.001v8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><style>.icon-canvas-transparent{opacity:0;fill:#f6f6f6}.icon-vs-out{fill:#f6f6f6}.icon-vs-bg{fill:#424242}.icon-vs-fg{fill:#f0eff1}</style><path class="icon-canvas-transparent" d="M16 16H0V0h16v16z" id="canvas"/><path class="icon-vs-out" d="M16 15H0V1h16v14z" id="outline" style="display: none;"/><path class="icon-vs-bg" d="M1 2v12h14V2H1zm13 11H2v-3h12v3zm0-5H2V5h12v3z" id="iconBg"/><g id="iconFg" style="display: none;"><path class="icon-vs-fg" d="M14 8H2V5h12v3zm0 2H2v3h12v-3z"/></g></svg>
\ No newline at end of file
......@@ -24,7 +24,7 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { SplitEditorAction, CloseOneEditorAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { CloseOneEditorAction, SplitEditorGroupVerticalAction, SplitEditorGroupHorizontalAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { createActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IMenuService, MenuId, IMenu, ExecuteCommandAction } from 'vs/platform/actions/common/actions';
......@@ -35,7 +35,7 @@ import { isDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { Dimension } from 'vs/base/browser/dom';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { INextEditorGroupsService, Direction, INextEditorGroup } from 'vs/workbench/services/editor/common/nextEditorGroupsService';
import { INextEditorGroupsService, INextEditorGroup } from 'vs/workbench/services/editor/common/nextEditorGroupsService';
import { IEditorInput } from 'vs/platform/editor/common/editor';
export interface IToolbarActions {
......@@ -60,7 +60,6 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre
protected stacks: IEditorStacksModel;
protected closeOneEditorAction: CloseOneEditorAction;
protected splitEditorAction: SplitEditorAction;
private currentPrimaryEditorActionIds: string[] = [];
private currentSecondaryEditorActionIds: string[] = [];
......@@ -74,6 +73,9 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre
private resourceContext: ResourceContextKey;
private disposeOnEditorActions: IDisposable[] = [];
private splitEditorGroupVerticalAction: SplitEditorGroupVerticalAction;
private splitEditorGroupHorizontalAction: SplitEditorGroupHorizontalAction;
private contextMenu: IMenu;
constructor(
......@@ -167,7 +169,8 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre
protected initActions(services: IInstantiationService): void {
this.closeOneEditorAction = services.createInstance(CloseOneEditorAction, CloseOneEditorAction.ID, CloseOneEditorAction.LABEL);
this.splitEditorAction = services.createInstance(SplitEditorAction, SplitEditorAction.ID, SplitEditorAction.LABEL);
this.splitEditorGroupHorizontalAction = services.createInstance(SplitEditorGroupHorizontalAction, SplitEditorGroupHorizontalAction.ID, SplitEditorGroupHorizontalAction.LABEL);
this.splitEditorGroupVerticalAction = services.createInstance(SplitEditorGroupVerticalAction, SplitEditorGroupVerticalAction.ID, SplitEditorGroupVerticalAction.LABEL);
}
protected createEditorActionsToolBar(container: HTMLElement): void {
......@@ -276,22 +279,9 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre
// Primary actions only for the active group
if (isActive) {
primaryEditorActions = prepareActions(editorActions.primary);
if (editor instanceof EditorInput && editor.supportsSplitEditor()) {
// TODO@grid temporary actions to play with
// primaryEditorActions.push(this.splitEditorAction);
primaryEditorActions.push(new Action('split.right', 'Split Right', 'split-editor-right-action', true, () => {
this.nextEditorGroupsService.addGroup(this.nextEditorGroupsService.activeGroup, Direction.RIGHT, { copyEditor: true });
return TPromise.as(true);
}));
primaryEditorActions.push(new Action('split.down', 'Split Down', 'split-editor-down-action', true, () => {
this.nextEditorGroupsService.addGroup(this.nextEditorGroupsService.activeGroup, Direction.DOWN, { copyEditor: true });
return TPromise.as(true);
}));
}
primaryEditorActions.push(this.splitEditorGroupHorizontalAction);
primaryEditorActions.push(this.splitEditorGroupVerticalAction);
}
secondaryEditorActions = prepareActions(editorActions.secondary);
......@@ -415,7 +405,8 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre
// Actions
[
this.splitEditorAction,
this.splitEditorGroupHorizontalAction,
this.splitEditorGroupVerticalAction,
this.closeOneEditorAction
].forEach((action) => {
action.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册