Skip to content

Commit

Permalink
replace list type filter and tree type label controller with list type
Browse files Browse the repository at this point in the history
navigation and tree find. use proper FindInput widget
  • Loading branch information
joaomoreno committed Jul 16, 2022
1 parent 7839742 commit 01b57e3
Show file tree
Hide file tree
Showing 29 changed files with 631 additions and 572 deletions.
48 changes: 43 additions & 5 deletions src/vs/base/browser/ui/findinput/findInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as dom from 'vs/base/browser/dom';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import { IToggleStyles } from 'vs/base/browser/ui/toggle/toggle';
import { IToggleStyles, Toggle } from 'vs/base/browser/ui/toggle/toggle';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import { CaseSensitiveToggle, RegexToggle, WholeWordsToggle } from 'vs/base/browser/ui/findinput/findInputToggles';
import { HistoryInputBox, IInputBoxStyles, IInputValidator, IMessage as InputBoxMessage } from 'vs/base/browser/ui/inputbox/inputBox';
Expand All @@ -31,6 +31,7 @@ export interface IFindInputOptions extends IFindInputStyles {
readonly appendWholeWordsLabel?: string;
readonly appendRegexLabel?: string;
readonly history?: string[];
readonly additionalToggles?: Toggle[];
readonly showHistoryHint?: () => boolean;
}

Expand Down Expand Up @@ -74,6 +75,7 @@ export class FindInput extends Widget {
protected regex: RegexToggle;
protected wholeWords: WholeWordsToggle;
protected caseSensitive: CaseSensitiveToggle;
protected additionalToggles: Toggle[] = [];
public domNode: HTMLElement;
public inputBox: HistoryInputBox;

Expand Down Expand Up @@ -209,10 +211,6 @@ export class FindInput extends Widget {
this._onCaseSensitiveKeyDown.fire(e);
}));

if (this._showOptionButtons) {
this.inputBox.paddingRight = this.caseSensitive.width() + this.wholeWords.width() + this.regex.width();
}

// Arrow-Key support to navigate between options
const indexes = [this.caseSensitive.domNode, this.wholeWords.domNode, this.regex.domNode];
this.onkeydown(this.domNode, (event: IKeyboardEvent) => {
Expand Down Expand Up @@ -250,6 +248,34 @@ export class FindInput extends Widget {
this.controls.appendChild(this.wholeWords.domNode);
this.controls.appendChild(this.regex.domNode);

if (!this._showOptionButtons) {
this.caseSensitive.domNode.style.display = 'none';
this.wholeWords.domNode.style.display = 'none';
this.regex.domNode.style.display = 'none';
}

for (const toggle of options?.additionalToggles ?? []) {
this._register(toggle);
this.controls.appendChild(toggle.domNode);

this._register(toggle.onChange(viaKeyboard => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard && this.fixFocusOnOptionClickEnabled) {
this.inputBox.focus();
}
}));

this.additionalToggles.push(toggle);
}

if (this.additionalToggles.length > 0) {
this.controls.style.display = 'block';
}

this.inputBox.paddingRight =
(this._showOptionButtons ? this.caseSensitive.width() + this.wholeWords.width() + this.regex.width() : 0)
+ this.additionalToggles.reduce((r, t) => r + t.width(), 0);

this.domNode.appendChild(this.controls);

parent?.appendChild(this.domNode);
Expand Down Expand Up @@ -282,6 +308,10 @@ export class FindInput extends Widget {
this.regex.enable();
this.wholeWords.enable();
this.caseSensitive.enable();

for (const toggle of this.additionalToggles) {
toggle.enable();
}
}

public disable(): void {
Expand All @@ -290,6 +320,10 @@ export class FindInput extends Widget {
this.regex.disable();
this.wholeWords.disable();
this.caseSensitive.disable();

for (const toggle of this.additionalToggles) {
toggle.disable();
}
}

public setFocusInputOnOptionClick(value: boolean): void {
Expand Down Expand Up @@ -356,6 +390,10 @@ export class FindInput extends Widget {
this.wholeWords.style(toggleStyles);
this.caseSensitive.style(toggleStyles);

for (const toggle of this.additionalToggles) {
toggle.style(toggleStyles);
}

const inputBoxStyles: IInputBoxStyles = {
inputBackground: this.inputBackground,
inputForeground: this.inputForeground,
Expand Down
77 changes: 1 addition & 76 deletions src/vs/base/browser/ui/list/list.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,72 +65,7 @@
z-index: 1000;
}

/* Type filter */

.monaco-list-type-filter {
display: flex;
align-items: center;
position: absolute;
border-radius: 2px;
padding: 0px 3px;
max-width: calc(100% - 10px);
text-overflow: ellipsis;
overflow: hidden;
text-align: right;
box-sizing: border-box;
cursor: all-scroll;
font-size: 13px;
line-height: 18px;
height: 20px;
z-index: 1;
top: 4px;
}

.monaco-list-type-filter.dragging {
transition: top 0.2s, left 0.2s;
}

.monaco-list-type-filter.ne {
right: 4px;
}

.monaco-list-type-filter.nw {
left: 4px;
}

.monaco-list-type-filter > .controls {
display: flex;
align-items: center;
box-sizing: border-box;
transition: width 0.2s;
width: 0;
}

.monaco-list-type-filter.dragging > .controls,
.monaco-list-type-filter:hover > .controls {
width: 36px;
}

.monaco-list-type-filter > .controls > * {
border: none;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
background: none;
width: 16px;
height: 16px;
flex-shrink: 0;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}

.monaco-list-type-filter > .controls > .filter {
margin-left: 4px;
}
/* Filter */

.monaco-list-type-filter-message {
position: absolute;
Expand All @@ -149,13 +84,3 @@
.monaco-list-type-filter-message:empty {
display: none;
}

/* Electron */

.monaco-list-type-filter {
cursor: grab;
}

.monaco-list-type-filter.dragging {
cursor: grabbing;
}
10 changes: 5 additions & 5 deletions src/vs/base/browser/ui/list/listPaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { IThemable } from 'vs/base/common/styler';
import 'vs/css!./list';
import { IListContextMenuEvent, IListEvent, IListMouseEvent, IListRenderer, IListVirtualDelegate } from './list';
import { IListAccessibilityProvider, IListOptions, IListOptionsUpdate, IListStyles, List } from './listWidget';
import { IListAccessibilityProvider, IListOptions, IListOptionsUpdate, IListStyles, List, TypeNavigationMode } from './listWidget';

export interface IPagedRenderer<TElement, TTemplateData> extends IListRenderer<TElement, TTemplateData> {
renderPlaceholder(index: number, templateData: TTemplateData): void;
Expand Down Expand Up @@ -95,8 +95,8 @@ class PagedAccessibilityProvider<T> implements IListAccessibilityProvider<number
}

export interface IPagedListOptions<T> {
readonly enableKeyboardNavigation?: boolean;
readonly automaticKeyboardNavigation?: boolean;
readonly typeNavigationEnabled?: boolean;
readonly typeNavigationMode?: TypeNavigationMode;
readonly ariaLabel?: string;
readonly keyboardSupport?: boolean;
readonly multipleSelectionSupport?: boolean;
Expand Down Expand Up @@ -282,8 +282,8 @@ export class PagedList<T> implements IThemable, IDisposable {
this.list.layout(height, width);
}

toggleKeyboardNavigation(): void {
this.list.toggleKeyboardNavigation();
triggerTypeNavigation(): void {
this.list.triggerTypeNavigation();
}

reveal(index: number, relativeTop?: number): void {
Expand Down
Loading

0 comments on commit 01b57e3

Please sign in to comment.