/// <summary> /// Returns true if the specified view is implemented by the current skin. /// </summary> public bool IsViewAvailable(BrowserViewMode view) { switch (view) { case BrowserViewMode.FILMSTRIP: return(FilmstripViewAvailable); case BrowserViewMode.COVERFLOW: return(CoverFlowViewAvailable); case BrowserViewMode.LARGEICON: return(LargeIconViewAvailable); case BrowserViewMode.SMALLICON: return(IconViewAvailable); case BrowserViewMode.LIST: return(ListViewAvailable); case BrowserViewMode.DETAILS: return(DetailsViewAvailable); default: logger.Warn("No \"IsViewAvailable\" skin setting for " + view.ToString() + " view."); return(true); } }
void LoadSettings() { // View Mode viewMode = (BrowserViewMode)EditorPrefs.GetInt("UnityVersionControl.BrowserViewMode", (int)BrowserViewMode.Default); // Staged Files Filter stagedFilesFilter = (FileState)EditorPrefs.GetInt("UnityVersionControl.StagedFilesFilter", (int)(FileState.Added | FileState.Copied | FileState.Deleted | FileState.Modified | FileState.Renamed | FileState.Unmerged | FileState.Unmodified | FileState.Untracked | FileState.Ignored)); // Working Tree Filter workingTreeFilter = (FileState)EditorPrefs.GetInt("UnityVersionControl.WorkingTreeFilter", (int)(FileState.Added | FileState.Copied | FileState.Deleted | FileState.Modified | FileState.Renamed | FileState.Unmerged | FileState.Untracked)); // Diff Widget horizontalResizeWidget1 = Mathf.Clamp(EditorPrefs.GetFloat("UnityVersionControl.HWidget1", position.width - 500), 80, position.width - 80); // Tree/Index Widget verticalResizeWidget1 = Mathf.Clamp(EditorPrefs.GetFloat("UnityVersionControl.VWidget1", (position.height - 220) / 2), 60, position.height - 180); // Show staged files showStagedFiles = EditorPrefs.GetBool("UnityVersionControl.ShowStagedFiles", true); // Show diff showDiff = EditorPrefs.GetBool("UnityVersionControl.ShowDiff", true); }
/// <summary> /// Returns true if the backdrop should be displayed for the specified view. /// </summary> public bool UseBackdrop(BrowserViewMode view) { switch (view) { case BrowserViewMode.FILMSTRIP: return(UseBackdropInFilmstripView); case BrowserViewMode.COVERFLOW: return(UseBackdropInCoverFlowView); case BrowserViewMode.LARGEICON: return(UseBackdropInLargeIconView); case BrowserViewMode.SMALLICON: return(UseBackdropInIconView); case BrowserViewMode.LIST: return(UseBackdropInListView); case BrowserViewMode.DETAILS: return(UseBackdropInDetailsView); case BrowserViewMode.CATEGORIES: return(UseBackdropInCategoriesView); default: logger.Warn("No \"UseBackdrop\" skin setting for " + view.ToString() + " view."); return(true); } }
/// <summary> /// Returns true if the backdrop should be displayed for the specified view. /// </summary> public bool UseBackdrop(BrowserViewMode view) { switch (view) { case BrowserViewMode.FILMSTRIP: return UseBackdropInFilmstripView; case BrowserViewMode.COVERFLOW: return UseBackdropInCoverFlowView; case BrowserViewMode.LARGEICON: return UseBackdropInLargeIconView; case BrowserViewMode.SMALLICON: return UseBackdropInIconView; case BrowserViewMode.LIST: return UseBackdropInListView; case BrowserViewMode.DETAILS: return UseBackdropInDetailsView; case BrowserViewMode.CATEGORIES: return UseBackdropInCategoriesView; default: logger.Warn("No \"UseBackdrop\" skin setting for " + view.ToString() + " view."); return true; } }
/// <summary> /// Returns true if the specified view is implemented by the current skin. /// </summary> public bool IsViewAvailable(BrowserViewMode view) { switch (view) { case BrowserViewMode.FILMSTRIP: return FilmstripViewAvailable; case BrowserViewMode.COVERFLOW: return CoverFlowViewAvailable; case BrowserViewMode.LARGEICON: return LargeIconViewAvailable; case BrowserViewMode.SMALLICON: return IconViewAvailable; case BrowserViewMode.LIST: return ListViewAvailable; default: logger.Warn("No \"IsViewAvailable\" skin setting for " + view.ToString() + " view."); return true; } }
void OnGUI() { GUI.enabled = BrowserUtility.guiEnabled; if (!initGUIStyle) { InitializeStyle(); LoadSettings(); } scrollPosition1 = GUILayout.BeginScrollView(scrollPosition1, false, false, GUI.skin.horizontalScrollbar, blankScrollbar, GUILayout.Height(110)); #region Main button row GUILayout.BeginHorizontal(); DisplayButtons(); GUILayout.EndHorizontal(); #endregion GUILayout.Space(12); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(3)); #region Repository location, initialization GUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(BrowserUtility.repositoryLocation)) { GUILayout.Label(versionControlTypeLogo); GUILayout.Space(10); GUILayout.Label(BrowserUtility.repositoryShortName); GUILayout.FlexibleSpace(); /* TODO: Put this in the settings window * if (viewMode != BrowserViewMode.ArtistMode) { if (GUILayout.Button("Reinitialize")) BrowserUtility.OnButton_Init(this); } */ var vm = (BrowserViewMode)EditorGUILayout.EnumPopup(viewMode); if (vm != viewMode) { viewMode = vm; EditorPrefs.SetInt("UnityVersionControl.BrowserViewMode", (int)viewMode); } } else { GUI.color = Color.red; GUILayout.Label("No project repository found!"); GUI.color = Color.white; GUILayout.FlexibleSpace(); // Todo, make initialization UI prettier if (GUILayout.Button("Initialize")) BrowserUtility.OnButton_Init(this); var vm = (BrowserViewMode)EditorGUILayout.EnumPopup(viewMode); if (vm != viewMode) { viewMode = vm; EditorPrefs.SetInt("UnityVersionControl.BrowserViewMode", (int)viewMode); } } GUILayout.EndHorizontal(); #endregion GUILayout.EndScrollView(); mainScrollPosition = GUILayout.BeginScrollView(mainScrollPosition); GUILayout.BeginHorizontal(); if (viewMode != BrowserViewMode.ArtistMode && showDiff) { GUILayout.BeginVertical(GUILayout.Width(horizontalResizeWidget1 - 3)); } else { GUILayout.BeginVertical(); } #region First scroll area - Staged files (git) if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.BeginVertical(GUILayout.Height(verticalResizeWidget1 - 3)); GUILayout.BeginHorizontal(); GUILayout.Label("Staged files", EditorStyles.toolbarButton); stagedFilesFilter = (FileState)EditorGUILayout.EnumMaskField(stagedFilesFilter, EditorStyles.toolbarPopup, GUILayout.Width(100)); GUILayout.EndHorizontal(); scrollPosition2 = GUILayout.BeginScrollView(scrollPosition2, false, false); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUI.backgroundColor *= .5f; GUILayout.Label("State", EditorStyles.toolbarButton, GUILayout.Width(80)); GUILayout.Label("File", EditorStyles.toolbarButton, GUILayout.Width(300)); GUILayout.Label("Path", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); filteredStagedFiles.Clear(); filteredStagedFiles.AddRange(BrowserUtility.stagedFiles.Values); FilterFileList(filteredStagedFiles, true); for(int i = 0; i < filteredStagedFiles.Count; i++) { DisplayFile(filteredStagedFiles[i], i, true, filteredStagedFiles); } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } #endregion #region Resize widget if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { Rect r = new Rect(position.x, position.y - 220, position.width, position.height); bool drag = GUIHelpers.ResizeWidget(drag1, ref verticalResizeWidget1, 60, position.height - 180, 6, true, r, this); if (drag != drag1) { drag1 = drag; EditorPrefs.SetFloat("UnityVersionControl.VWidget1", verticalResizeWidget1); } } #endregion #region Second scroll area - Working tree if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.BeginVertical(GUILayout.Height(position.height - 126 - verticalResizeWidget1 - 3)); } GUILayout.BeginHorizontal(); GUILayout.Label("Working tree", EditorStyles.toolbarButton); workingTreeFilter = (FileState)EditorGUILayout.EnumMaskField(workingTreeFilter, EditorStyles.toolbarPopup, GUILayout.Width(100)); GUILayout.EndHorizontal(); scrollPosition3 = GUILayout.BeginScrollView(scrollPosition3, false, false); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUI.backgroundColor *= .5f; GUILayout.Label("State", EditorStyles.toolbarButton, GUILayout.Width(80)); if (viewMode != BrowserViewMode.ArtistMode) { GUILayout.Label("File", EditorStyles.toolbarButton, GUILayout.Width(300)); } GUILayout.Label("Path", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); filteredWorkingTree.Clear(); filteredWorkingTree.AddRange(BrowserUtility.workingTree.Values); FilterFileList(filteredWorkingTree, false); for(int i = 0; i < filteredWorkingTree.Count; i++) { DisplayFile(filteredWorkingTree[i], i, false, filteredWorkingTree); } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.EndVertical(); } #endregion GUILayout.EndVertical(); #region Resize widget if (viewMode != BrowserViewMode.ArtistMode && showDiff) { bool drag = GUIHelpers.ResizeWidget(drag2, ref horizontalResizeWidget1, 80, position.width - 80, 4, false, position, this); if (drag != drag2) { drag2 = drag; EditorPrefs.SetFloat("UnityVersionControl.HWidget1", horizontalResizeWidget1); } } #endregion #region 3rd scroll area - Diff if (viewMode != BrowserViewMode.ArtistMode && showDiff) { GUILayout.BeginVertical(GUILayout.Width(position.width - horizontalResizeWidget1)); GUILayout.BeginHorizontal(); GUILayout.Label("Diff", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); scrollPosition4 = GUILayout.BeginScrollView(scrollPosition4, false, false); EditorGUILayout.SelectableLabel(BrowserUtility.diffString, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); GUILayout.EndVertical(); } #endregion GUILayout.EndHorizontal(); GUILayout.EndScrollView(); #region Status bar DisplayStatusBar(); #endregion GUI.enabled = BrowserUtility.guiEnabled; if (BrowserUtility.guiEnabled) { BrowserUtility.ProcessKeyboardEvents(ref lastSelectedIndex, filteredStagedFiles, filteredWorkingTree); } }
void OnGUI() { GUI.enabled = BrowserUtility.guiEnabled; if (!initGUIStyle) { InitializeStyle(); LoadSettings(); } scrollPosition1 = GUILayout.BeginScrollView(scrollPosition1, false, false, GUI.skin.horizontalScrollbar, blankScrollbar, GUILayout.Height(110)); #region Main button row GUILayout.BeginHorizontal(); DisplayButtons(); GUILayout.EndHorizontal(); #endregion GUILayout.Space(12); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(3)); #region Repository location, initialization GUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(BrowserUtility.repositoryLocation)) { GUILayout.Label(versionControlTypeLogo); GUILayout.Space(10); GUILayout.Label(BrowserUtility.repositoryShortName); GUILayout.FlexibleSpace(); /* TODO: Put this in the settings window * * if (viewMode != BrowserViewMode.ArtistMode) * { * if (GUILayout.Button("Reinitialize")) * BrowserUtility.OnButton_Init(this); * } */ var vm = (BrowserViewMode)EditorGUILayout.EnumPopup(viewMode); if (vm != viewMode) { viewMode = vm; EditorPrefs.SetInt("UnityVersionControl.BrowserViewMode", (int)viewMode); } } else { GUI.color = Color.red; GUILayout.Label("No project repository found!"); GUI.color = Color.white; GUILayout.FlexibleSpace(); // Todo, make initialization UI prettier if (GUILayout.Button("Initialize")) { BrowserUtility.OnButton_Init(this); } var vm = (BrowserViewMode)EditorGUILayout.EnumPopup(viewMode); if (vm != viewMode) { viewMode = vm; EditorPrefs.SetInt("UnityVersionControl.BrowserViewMode", (int)viewMode); } } GUILayout.EndHorizontal(); #endregion GUILayout.EndScrollView(); mainScrollPosition = GUILayout.BeginScrollView(mainScrollPosition); GUILayout.BeginHorizontal(); if (viewMode != BrowserViewMode.ArtistMode && showDiff) { GUILayout.BeginVertical(GUILayout.Width(horizontalResizeWidget1 - 3)); } else { GUILayout.BeginVertical(); } #region First scroll area - Staged files (git) if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.BeginVertical(GUILayout.Height(verticalResizeWidget1 - 3)); GUILayout.BeginHorizontal(); GUILayout.Label("Staged files", EditorStyles.toolbarButton); stagedFilesFilter = (FileState)EditorGUILayout.EnumMaskField(stagedFilesFilter, EditorStyles.toolbarPopup, GUILayout.Width(100)); GUILayout.EndHorizontal(); scrollPosition2 = GUILayout.BeginScrollView(scrollPosition2, false, false); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUI.backgroundColor *= .5f; GUILayout.Label("State", EditorStyles.toolbarButton, GUILayout.Width(80)); GUILayout.Label("File", EditorStyles.toolbarButton, GUILayout.Width(300)); GUILayout.Label("Path", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); filteredStagedFiles.Clear(); filteredStagedFiles.AddRange(BrowserUtility.stagedFiles.Values); FilterFileList(filteredStagedFiles, true); for (int i = 0; i < filteredStagedFiles.Count; i++) { DisplayFile(filteredStagedFiles[i], i, true, filteredStagedFiles); } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } #endregion #region Resize widget if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { Rect r = new Rect(position.x, position.y - 220, position.width, position.height); bool drag = GUIHelpers.ResizeWidget(drag1, ref verticalResizeWidget1, 60, position.height - 180, 6, true, r, this); if (drag != drag1) { drag1 = drag; EditorPrefs.SetFloat("UnityVersionControl.VWidget1", verticalResizeWidget1); } } #endregion #region Second scroll area - Working tree if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.BeginVertical(GUILayout.Height(position.height - 126 - verticalResizeWidget1 - 3)); } GUILayout.BeginHorizontal(); GUILayout.Label("Working tree", EditorStyles.toolbarButton); workingTreeFilter = (FileState)EditorGUILayout.EnumMaskField(workingTreeFilter, EditorStyles.toolbarPopup, GUILayout.Width(100)); GUILayout.EndHorizontal(); scrollPosition3 = GUILayout.BeginScrollView(scrollPosition3, false, false); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUI.backgroundColor *= .5f; GUILayout.Label("State", EditorStyles.toolbarButton, GUILayout.Width(80)); if (viewMode != BrowserViewMode.ArtistMode) { GUILayout.Label("File", EditorStyles.toolbarButton, GUILayout.Width(300)); } GUILayout.Label("Path", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); filteredWorkingTree.Clear(); filteredWorkingTree.AddRange(BrowserUtility.workingTree.Values); FilterFileList(filteredWorkingTree, false); for (int i = 0; i < filteredWorkingTree.Count; i++) { DisplayFile(filteredWorkingTree[i], i, false, filteredWorkingTree); } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.EndVertical(); } #endregion GUILayout.EndVertical(); #region Resize widget if (viewMode != BrowserViewMode.ArtistMode && showDiff) { bool drag = GUIHelpers.ResizeWidget(drag2, ref horizontalResizeWidget1, 80, position.width - 80, 4, false, position, this); if (drag != drag2) { drag2 = drag; EditorPrefs.SetFloat("UnityVersionControl.HWidget1", horizontalResizeWidget1); } } #endregion #region 3rd scroll area - Diff if (viewMode != BrowserViewMode.ArtistMode && showDiff) { GUILayout.BeginVertical(GUILayout.Width(position.width - horizontalResizeWidget1)); GUILayout.BeginHorizontal(); GUILayout.Label("Diff", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); scrollPosition4 = GUILayout.BeginScrollView(scrollPosition4, false, false); EditorGUILayout.SelectableLabel(BrowserUtility.diffString, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); GUILayout.EndVertical(); } #endregion GUILayout.EndHorizontal(); GUILayout.EndScrollView(); #region Status bar DisplayStatusBar(); #endregion GUI.enabled = BrowserUtility.guiEnabled; if (BrowserUtility.guiEnabled) { BrowserUtility.ProcessKeyboardEvents(ref lastSelectedIndex, filteredStagedFiles, filteredWorkingTree); } }
private void OnBrowserViewChanged(BrowserViewMode previousView, BrowserViewMode currentView) { if (currentView == BrowserViewMode.DETAILS) { GUIWindowManager.Process(); GUIControl.FocusControl(GUIWindowManager.ActiveWindow, playButton.GetID); } // set the backdrop visibility based on the skin settings if (movieBackdropControl != null) backdrop.Active = skinSettings.UseBackdrop(currentView); if (currentView != BrowserViewMode.CATEGORIES) PublishMovieDetails(browser.SelectedMovie); }
private BrowserViewMode GetNextValidView(BrowserViewMode startView) { BrowserViewMode newView = startView; do { // rotate view until one is available if (newView == BrowserViewMode.COVERFLOW) newView = BrowserViewMode.LIST; else newView++; } while (!skinSettings.IsViewAvailable(newView)); return newView; }
/// <summary> /// Reloads the current view to the GUI. /// </summary> public void ReloadView() { if (currentView == BrowserViewMode.LASTUSED) { currentView = MovingPicturesCore.Settings.LastUsedView; } logger.Debug("CurrentView: {0}", currentView.ToString()); // Facade visibility if (currentView != BrowserViewMode.CATEGORIES && _categoriesFacade != null) { _categoriesFacade.Visible(false); } if (currentView == BrowserViewMode.CATEGORIES || currentView == BrowserViewMode.DETAILS) { facade.Visible(false); } // Switch facade view switch (currentView) { case BrowserViewMode.CATEGORIES: //_categoriesFacade.View = GUIFacadeControl.ViewMode.List; //_categoriesFacade.CurrentLayout = GUIFacadeControl.Layout.List; _categoriesFacade.SetCurrentLayout("List"); break; case BrowserViewMode.LIST: //facade.View = GUIFacadeControl.ViewMode.List; //facade.CurrentLayout = GUIFacadeControl.Layout.List; facade.SetCurrentLayout("List"); break; case BrowserViewMode.SMALLICON: //facade.View = GUIFacadeControl.ViewMode.SmallIcons; //facade.CurrentLayout = GUIFacadeControl.Layout.SmallIcons; facade.SetCurrentLayout("SmallIcons"); break; case BrowserViewMode.LARGEICON: //facade.View = GUIFacadeControl.ViewMode.LargeIcons; //facade.CurrentLayout = GUIFacadeControl.Layout.LargeIcons; facade.SetCurrentLayout("LargeIcons"); break; case BrowserViewMode.FILMSTRIP: //facade.View = GUIFacadeControl.ViewMode.Filmstrip; //facade.CurrentLayout = GUIFacadeControl.Layout.Filmstrip; facade.SetCurrentLayout("Filmstrip"); break; case BrowserViewMode.COVERFLOW: facade.SetCurrentLayout("CoverFlow"); break; } // Reload facade content ReloadFacade(); // Set facade visibility and focus Focus(); // Update listeners that the view changed if (ViewChanged != null) ViewChanged(previousView, currentView); }
/// <summary> /// Rotates the current view. /// </summary> public void CycleView() { if (CurrentView == BrowserViewMode.DETAILS || CurrentView == BrowserViewMode.CATEGORIES) return; previousView = CurrentView; CurrentView = GetNextValidView(CurrentView); }