Skip to content

Commit

Permalink
Made it easier to customize view container part.
Browse files Browse the repository at this point in the history
- Template method for the part creation.
- Removed the deprecated API use.
- Fixed indentation in CSS.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
  • Loading branch information
Akos Kitta authored and kittaakos committed Oct 13, 2020
1 parent e33708b commit 8e3da24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/browser/style/view-container.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

:root {
:root {
--theia-view-container-title-height: var(--theia-content-line-height);
--theia-view-container-content-height: calc(100% - var(--theia-view-container-title-height));
}
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/browser/view-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica

const description = this.widgetManager.getDescription(widget);
const partId = description ? JSON.stringify(description) : widget.id;
const newPart = new ViewContainerPart(widget, partId, this.id, this.toolbarRegistry, this.toolbarFactory, options);
const newPart = this.createPart(widget, partId, options);
this.registerPart(newPart);
if (newPart.options && newPart.options.order !== undefined) {
const index = this.getParts().findIndex(part => part.options.order === undefined || part.options.order > newPart.options.order!);
Expand Down Expand Up @@ -289,7 +289,7 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica
}
}),
this.registerDND(newPart),
newPart.onVisibilityChanged(() => {
newPart.onDidChangeVisibility(() => {
this.updateTitle();
this.updateCurrentPart();
}),
Expand All @@ -312,6 +312,10 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica
return toRemoveWidget;
}

protected createPart(widget: Widget, partId: string, options?: ViewContainer.Factory.WidgetOptions | undefined): ViewContainerPart {
return new ViewContainerPart(widget, partId, this.id, this.toolbarRegistry, this.toolbarFactory, options);
}

removeWidget(widget: Widget): boolean {
const disposable = this.toRemoveWidgets.get(widget.id);
if (disposable) {
Expand Down

0 comments on commit 8e3da24

Please sign in to comment.