protected override void UpdateInternal() { Manager.NativeManager.PushItemWidth(-1); // Address bar { // Back directory (BS shortcut key) if (Manager.NativeManager.IsWindowFocused() && Manager.NativeManager.IsKeyPressed(Manager.NativeManager.GetKeyIndex(swig.Key.Backspace)) && !Manager.NativeManager.IsAnyItemActive() && !string.IsNullOrEmpty(CurrentPath)) { UpdateFileListWithProjectPath(CurrentPath); } // Back directory if (Manager.NativeManager.Button("↑") && !String.IsNullOrEmpty(CurrentPath)) { UpdateFileListWithProjectPath(CurrentPath); } Manager.NativeManager.SameLine(); // Display current directory if (Manager.NativeManager.InputText("###AddressBar", addressText)) { addressText = Manager.NativeManager.GetInputTextResult(); UpdateFileList(addressText); } if (Manager.NativeManager.IsItemActivated()) { addressEditing = true; } if (Manager.NativeManager.IsItemDeactivated()) { addressEditing = false; addressText = CurrentPath; } } Manager.NativeManager.Separator(); // Display all files for (int i = 0; i < items.Count; i++) { var item = items[i]; string icon = Icons.Empty; swig.ImageResource image = null; switch (item.Type) { case FileType.Directory: icon = Icons.FileDirectory; break; case FileType.EffekseerProject: icon = Icons.FileEfkefc; break; case FileType.Image: image = item.Image; break; case FileType.Sound: icon = Icons.FileSound; break; case FileType.Model: icon = Icons.FileModel; break; case FileType.Material: icon = Icons.FileEfkmat; break; default: icon = Icons.FileOther; break; } float iconPosX = Manager.NativeManager.GetCursorPosX(); string caption = icon + " " + Path.GetFileName(item.FilePath); if (Manager.NativeManager.Selectable(caption, item.Selected, swig.SelectableFlags.AllowDoubleClick)) { if (Manager.NativeManager.IsCtrlKeyDown()) { item.Selected = !item.Selected; } else if (Manager.NativeManager.IsShiftKeyDown() && selectedIndex >= 0) { int min = Math.Min(selectedIndex, i); int max = Math.Max(selectedIndex, i); for (int j = min; j <= max; j++) { items[j].Selected = true; } } else { ResetSelected(); item.Selected = true; } selectedIndex = i; if (Manager.NativeManager.IsMouseDoubleClicked(0) || Manager.NativeManager.IsKeyDown(Manager.NativeManager.GetKeyIndex(swig.Key.Enter))) { OnFilePicked(); } } if (Manager.NativeManager.IsItemFocused()) { ResetSelected(); } if (Manager.NativeManager.IsItemClicked(1)) { if (!item.Selected) { ResetSelected(); item.Selected = true; } selectedIndex = i; Manager.NativeManager.OpenPopup(ContextMenuPopupId); } // D&D switch (item.Type) { case FileType.Image: DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Image); break; case FileType.Sound: DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Sound); break; case FileType.Model: DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Model); break; case FileType.Material: DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Material); break; case FileType.Curve: DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Curve); break; default: DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Other); break; } if (image != null) { Manager.NativeManager.SameLine(); Manager.NativeManager.SetCursorPosX(iconPosX); float iconSize = Manager.NativeManager.GetTextLineHeight(); Manager.NativeManager.Image(image, iconSize, iconSize); } } UpdateContextMenu(); Manager.NativeManager.PopItemWidth(); if (shouldUpdateFileList) { UpdateFileList(); shouldUpdateFileList = false; } }
void UpdateFileView(float dpiScale, swig.Vec2 regionSize, swig.Vec2 spacing) { var viewMode = Core.Option.FileViewerViewMode.GetValue(); float iconSize = Core.Option.FileViewerIconSize.GetValue(); int contentCountX = 1; if (viewMode == Data.OptionValues.FileViewMode.IconView) { contentCountX = (int)((regionSize.X + spacing.X * 2) / (iconSize + spacing.X)); if (contentCountX <= 0) { contentCountX = 1; } } for (int i = 0; i < items.Count; i++) { var item = items[i]; string icon = item.GetIcon(viewMode == Data.OptionValues.FileViewMode.ListView); if (i != 0 && i % contentCountX != 0) { Manager.NativeManager.SameLine(); } item.DrawPosX = Manager.NativeManager.GetCursorPosX(); item.DrawPosY = Manager.NativeManager.GetCursorPosY(); string label = icon + Path.GetFileName(item.FilePath); bool selected = false; switch (viewMode) { case Data.OptionValues.FileViewMode.IconView: selected = Manager.NativeManager.SelectableContent("###FileContent_" + i, label, item.Selected, item.Image, iconSize, iconSize, swig.SelectableFlags.AllowDoubleClick); break; case Data.OptionValues.FileViewMode.ListView: selected = Manager.NativeManager.Selectable(label + "###FileContent_" + i, item.Selected, swig.SelectableFlags.AllowDoubleClick); break; } item.ItemID = Manager.NativeManager.GetItemID(); if (selected) { if (Manager.NativeManager.IsCtrlKeyDown()) { item.Selected = !item.Selected; } else if (Manager.NativeManager.IsShiftKeyDown() && selectedIndex >= 0) { int min = Math.Min(selectedIndex, i); int max = Math.Max(selectedIndex, i); for (int j = min; j <= max; j++) { items[j].Selected = true; } } else { ResetSelected(); item.Selected = true; } selectedIndex = i; if (Manager.NativeManager.IsMouseDoubleClicked(0) || Manager.NativeManager.IsKeyDown(Manager.NativeManager.GetKeyIndex(swig.Key.Enter))) { OnFilePicked(); } } if (Manager.NativeManager.IsItemClicked(1)) { if (!item.Selected) { ResetSelected(); item.Selected = true; } selectedIndex = i; Manager.NativeManager.OpenPopup(ContextMenuPopupId); } // D&D switch (item.Type) { case FileType.Texture: DragAndDrops.UpdateFileSrc(item.FilePath, FileType.Texture); break; case FileType.Sound: DragAndDrops.UpdateFileSrc(item.FilePath, FileType.Sound); break; case FileType.Model: DragAndDrops.UpdateFileSrc(item.FilePath, FileType.Model); break; case FileType.Material: DragAndDrops.UpdateFileSrc(item.FilePath, FileType.Material); break; case FileType.Curve: DragAndDrops.UpdateFileSrc(item.FilePath, FileType.Curve); break; default: DragAndDrops.UpdateFileSrc(item.FilePath, FileType.Other); break; } if (viewMode == Data.OptionValues.FileViewMode.ListView) { if (item.Image != null) { Manager.NativeManager.SameLine(); Manager.NativeManager.SetCursorPosX(item.DrawPosX); float listIconSize = Manager.NativeManager.GetTextLineHeight(); Manager.NativeManager.ImageData(item.Image, listIconSize, listIconSize); } } } UpdateContextMenu(); if (!Manager.NativeManager.IsPopupOpen(ContextMenuPopupId) && !Manager.NativeManager.IsAnyItemActive() && Manager.NativeManager.IsMouseClicked(0, false)) { ResetSelected(); } }