void DrawContents() { if (WindowHelper.Data == null || WindowHelper.CurCategory(selectCategoryId) == null) { EditorGUILayout.HelpBox("fatal Error.", MessageType.Error); selectCategoryId = 0; return; } Header(); if (selectMode == 0) { UnityEditorMemoSplitterGUI.BeginVerticalSplit(WindowHelper.VerticalState); { MemoContents(); PostContents(); } UnityEditorMemoSplitterGUI.EndVerticalSplit(); } else if (selectMode == 1) { CategoryContents(); LabelConfigContents(); } }
void LabelGUI() { EditorGUILayout.BeginHorizontal(); { var curToggles = new bool[6]; footerToggle.CopyTo(curToggles, 0); curToggles[0] = GUILayout.Toggle(curToggles[0], "all", EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(1); curToggles[1] = GUILayout.Toggle(curToggles[1], UnityEditorMemoPrefs.Label1, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(2); curToggles[2] = GUILayout.Toggle(curToggles[2], UnityEditorMemoPrefs.Label2, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(3); curToggles[3] = GUILayout.Toggle(curToggles[3], UnityEditorMemoPrefs.Label3, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(4); curToggles[4] = GUILayout.Toggle(curToggles[4], UnityEditorMemoPrefs.Label4, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(5); curToggles[5] = GUILayout.Toggle(curToggles[5], UnityEditorMemoPrefs.Label5, EditorStyles.toolbarButton); GUI.backgroundColor = Color.white; var label = WindowHelper.ChangeFooterStatus(selectLabel, ref curToggles); if (label != selectLabel) { UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_LABEL); // avoid error. why? :( postMemoLabel = label; selectLabel = label; memoTreeView.SelectLabel = ( UnityEditorMemoLabel )selectLabel; memoTreeView.Reload(); GUIUtility.keyboardControl = 0; } footerToggle = curToggles; } EditorGUILayout.EndHorizontal(); }
//====================================================================== // Event Process //====================================================================== #region event process void EventProcess(Event e) { if (WindowHelper.Data == null || WindowHelper.CurCategory(selectCategoryId) == null) { return; } var memos = WindowHelper.CurCategory(selectCategoryId).Memo; for (int i = 0; i < memos.Count; i++) { var memo = memos[i]; if (memo.IsContextClick) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Edit"), false, () => { memo.isFoldout = true; }); menu.AddItem(new GUIContent("Delete"), false, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_MEMO); WindowHelper.CurCategory(selectCategoryId).Memo.Remove(memo); }); menu.ShowAsContext(); break; } } }
void Footer() { GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); { var curToggles = new bool[6]; footerToggle.CopyTo(curToggles, 0); curToggles[0] = GUILayout.Toggle(curToggles[0], "all", EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(1); curToggles[1] = GUILayout.Toggle(curToggles[1], WindowHelper.Data.LabelTag[0], EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(2); curToggles[2] = GUILayout.Toggle(curToggles[2], WindowHelper.Data.LabelTag[1], EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(3); curToggles[3] = GUILayout.Toggle(curToggles[3], WindowHelper.Data.LabelTag[2], EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(4); curToggles[4] = GUILayout.Toggle(curToggles[4], WindowHelper.Data.LabelTag[3], EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(5); curToggles[5] = GUILayout.Toggle(curToggles[5], WindowHelper.Data.LabelTag[4], EditorStyles.toolbarButton); GUI.backgroundColor = Color.white; var label = WindowHelper.ChangeFooterStatus(selectLabel, ref curToggles); if (label != selectLabel) { //Undo.IncrementCurrentGroup(); //UndoHelper.WindowUndo( UndoHelper.UNDO_CHANGE_LABEL ); // avoid error. why? :( postMemoLabel = label; GUIUtility.keyboardControl = 0; } selectLabel = label; footerToggle = curToggles; } EditorGUILayout.EndHorizontal(); }
void CategoryMenu() { var selectedId = 0; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); { //searchText = GUILayout.TextField( searchText, GUIHelper.Styles.SearchField, GUILayout.Width( 200 ) ); //if( GUILayout.Button( "", GUIHelper.Styles.SearchFieldCancel ) ) { // searchText = ""; // GUIUtility.keyboardControl = 0; //} GUILayout.Space(position.width * 0.48f); GUI.backgroundColor = Color.yellow; selectedId = EditorGUILayout.Popup(selectCategoryId, WindowHelper.Data.CategoryList, EditorStyles.toolbarPopup); GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); if (selectCategoryId != selectedId) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY); GUIUtility.keyboardControl = 0; selectLabel = 0; footerToggle = new bool[] { true, false, false, false, false, false }; WindowHelper.CurCategory(selectedId).OnCategoryChange(); } selectCategoryId = selectedId; }
static void Initialize() { WindowHelper.Initialize(win.position); if (win != null) { win.Repaint(); } }
private void OnMemoDelete(UnityEditorMemo memo) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_MEMO); WindowHelper.GetCategory(selectCategoryId).Memo.Remove(memo); EditorUtility.SetDirty(WindowHelper.Data); MemoTreeViewInitialize(); }
private void OnMemoOrderChanged(List <UnityEditorMemo> newMemos) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); var currentCategory = WindowHelper.GetCategory(selectCategoryId); currentCategory.Memo = newMemos; Initialize(); }
private void OnCategoryChange() { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY); selectLabel = 0; footerToggle = new bool[] { true, false, false, false, false, false }; WindowHelper.GetCategory(selectCategoryId).Initialize(); MemoTreeViewInitialize(); EditorGUIUtility.keyboardControl = 0; }
void DrawContents() { if (WindowHelper.Data == null || WindowHelper.GetCategory(selectCategoryId) == null) { EditorGUILayout.HelpBox("fatal Error.", MessageType.Error); selectCategoryId = 0; return; } HeaderGUI(); SplitterGUI.BeginVerticalSplit(verticalState); { MemoGUI(); PostGUI(); } SplitterGUI.EndVerticalSplit(); }
private void MemoTreeViewInitialize() { WindowHelper.CheckMemoHasRootElement(selectCategoryId); if (memoTreeViewState == null) { memoTreeViewState = new TreeViewState(); } var rowRectSize = isCategoryVisible ? (preMemoWidth == 0 ? position.width * 0.7f : preMemoWidth) : position.width; var treeModel = new TreeModel <UnityEditorMemo>(WindowHelper.GetCategory(selectCategoryId).Memo); memoTreeView = new UnityEditorMemoTreeView(memoTreeViewState, treeModel, rowRectSize); memoTreeView.OnContextClicked += OnMemoContextClicked; memoTreeView.SelectLabel = ( UnityEditorMemoLabel )selectLabel; memoTreeView.Reload(); }
void MemoContents() { var curCategory = WindowHelper.CurCategory(selectCategoryId); var memos = WindowHelper.DisplayMemoList(curCategory, selectLabel, displayMemoMode); EditorGUILayout.BeginVertical(); { CategoryMenu(); GUILayout.Space(5); if (curCategory.IsDevideMemo(selectLabel)) { displayMemoMode = GUILayout.Toolbar(displayMemoMode, displayMemoModeTexts, EditorStyles.toolbarButton); } else { displayMemoMode = 0; } if (curCategory.Memo.Count == 0) { EditorGUILayout.HelpBox(WindowHelper.TEXT_NO_MEMO, MessageType.Warning); } else if (memos.Count > 0) { //try { // this cause erro!:( memoScrollView = EditorGUILayout.BeginScrollView(memoScrollView); { for (int i = 0; i < memos.Count; i++) { memos[i].OnGUI(); } } EditorGUILayout.EndScrollView(); //} catch { } } Footer(); } EditorGUILayout.EndVertical(); }
private void Initialize() { WindowHelper.LoadData(); var category = WindowHelper.GetCategory(selectCategoryId); if (category == null) { selectCategoryId = 0; return; } category.Initialize(); verticalState = new SplitterState(new float[] { position.height * 0.9f, position.height * 0.1f }, new int[] { 200, 180 }, new int[] { 1500, 300 }); SetHorizontalState(); CategoryTreeViewInitialize(); MemoTreeViewInitialize(); IsInitialized = true; EditorGUIUtility.keyboardControl = 0; Repaint(); }
void OnGUI() { if (win == null) { OpenWindow(); } if (!IsInitialized) { Initialize(); } EditorGUI.BeginChangeCheck(); WindowHelper.OnGUIFirst(position.width); DrawContents(); WindowHelper.OnGUIEnd(); if (WindowHelper.Data != null && EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(WindowHelper.Data); } }
private void labelSelectionGUI(Rect rect) { var curToggles = new bool[6]; footerToggle.CopyTo(curToggles, 0); rect.width = rect.width / 6; rect.height = 15f; GUI.backgroundColor = Color.white; curToggles[0] = GUI.Toggle(rect, curToggles[0], "", GUIHelper.Styles.LargeButtonLeft); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(1); curToggles[1] = GUI.Toggle(rect, curToggles[1], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(2); curToggles[2] = GUI.Toggle(rect, curToggles[2], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(3); curToggles[3] = GUI.Toggle(rect, curToggles[3], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(4); curToggles[4] = GUI.Toggle(rect, curToggles[4], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(5); curToggles[5] = GUI.Toggle(rect, curToggles[5], "", GUIHelper.Styles.LargeButtonRight); rect.x += rect.width; GUI.backgroundColor = Color.white; var label = ( UnityEditorMemoLabel )WindowHelper.ChangeFooterStatus((int)Label, ref curToggles); if (label != Label) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_CHANGE_LABEL); Label = label; } footerToggle = curToggles; }
void OnGUI() { if (win == null) { OpenWindow(); if (WindowHelper.CurCategory(selectCategoryId) != null) { WindowHelper.CurCategory(selectCategoryId).Initialize(); } } EditorGUI.BeginChangeCheck(); WindowHelper.OnGUIFirst(position.width); DrawContents(); EventProcess(Event.current); WindowHelper.OnGUIEnd(); if (WindowHelper.Data != null && EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(WindowHelper.Data); } }
void CategoryMenu() { var selectedId = 0; EditorGUILayout.BeginHorizontal(GUIHelper.Styles.NoSpaceBox, GUILayout.ExpandWidth(true)); { GUILayout.Label("Category".ToBold()); GUI.backgroundColor = Color.yellow; selectedId = EditorGUILayout.Popup(selectCategoryId, WindowHelper.Data.CategoryList, EditorStyles.toolbarPopup); GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); if (selectCategoryId != selectedId) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY); GUIUtility.keyboardControl = 0; selectLabel = 0; footerToggle = new bool[] { true, false, false, false, false, false }; WindowHelper.CurCategory(selectCategoryId).OnCategoryChange(); } selectCategoryId = selectedId; }
private void OnMemoContextClicked(UnityEditorMemo memo) { var menu = new GenericMenu(); menu.AddItem(new GUIContent(!memo.IsEdit ? "Edit" : "Done"), false, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.IsEdit = !memo.IsEdit; memoTreeView.UpdateRowHeight(); }); menu.AddItem(new GUIContent("Repost"), false, () => { OnMemoDelete(memo); memo.Date = DateTime.Now.RenderDate(); OnMemoPost(WindowHelper.GetCategory(selectCategoryId), memo); }); if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label1)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label1), memo.Label == 0, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = 0; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label2)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label2), ( int )memo.Label == 1, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )1; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label3)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label3), ( int )memo.Label == 2, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )2; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label4)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label4), ( int )memo.Label == 3, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )3; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label5)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label5), ( int )memo.Label == 5, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )5; }); } menu.AddSeparator(""); if (!string.IsNullOrEmpty(memo.URL)) { menu.AddItem(new GUIContent("Open URL"), false, () => { Application.OpenURL(memo.URL); }); menu.AddSeparator(""); } menu.AddItem(new GUIContent("Delete"), false, () => { OnMemoDelete(memo); }); menu.ShowAsContext(); }
/// <summary> /// display posting area /// </summary> void PostContents() { var category = WindowHelper.CurCategory(selectCategoryId); EditorGUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true) }); { GUILayout.Box("", GUIHelper.Styles.NoSpaceBox, new GUILayoutOption[] { GUILayout.Height(2), GUILayout.ExpandWidth(true) }); GUILayout.Space(5); GUILayout.Label((WindowHelper.TEXT_CREATEMEMO_TITLE + category.Name).ToMiddleBold()); EditorGUILayout.BeginVertical(); { // date EditorGUILayout.BeginHorizontal(); { GUILayout.Label(DateTime.Now.RenderDate(), GUIHelper.Styles.MemoBox, new GUILayoutOption[] { GUILayout.Width(150), GUILayout.Height(25) }); postMemoLabel = EditorGUILayout.Popup(postMemoLabel, GUIHelper.Label, GUILayout.Width(100)); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); // draft Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT); memoText = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) }); EditorGUILayout.BeginHorizontal(); { postMemoTex = GUILayout.Toolbar(postMemoTex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(150) }); GUILayout.FlexibleSpace(); //if ( GUILayout.Button( "test", new GUILayoutOption[] { GUILayout.Height( 30 ), GUILayout.Width( 50 ) } ) ) { // for( int i = 0; i < 110; i++ ) { // category.AddMemo( new UnityEditorMemo( i.ToString(), postMemoLabel, postMemoTex ) ); // } //} // post button GUI.backgroundColor = Color.cyan; if (GUILayout.Button("Post", new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(100) })) { if (!string.IsNullOrEmpty(memoText)) { Undo.IncrementCurrentGroup(); UndoHelper.EditorMemoUndo(UndoHelper.UNDO_POST); category.AddMemo(new UnityEditorMemo(memoText, postMemoLabel, postMemoTex)); memoText = ""; postMemoLabel = 0; postMemoTex = 0; memoScrollView = Vector2.zero; GUIUtility.keyboardControl = 0; } else { Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY); } } GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); }
/// <summary> /// display posting area /// </summary> void PostGUI() { var category = WindowHelper.GetCategory(selectCategoryId); EditorGUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true) }); { GUILayout.Box("", GUIHelper.Styles.NoSpaceBox, new GUILayoutOption[] { GUILayout.Height(2), GUILayout.ExpandWidth(true) }); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { GUILayout.Label(DateTime.Now.RenderDate()); GUILayout.Space(5); GUI.backgroundColor = GUIHelper.Colors.LabelColor(postMemoLabel); postMemoLabel = EditorGUILayout.Popup(postMemoLabel, GUIHelper.LabelMenu, EditorStyles.toolbarPopup, GUILayout.Width(80)); GUI.backgroundColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.Label("URL", GUILayout.Width(30)); postMemoUrl = EditorGUILayout.TextField(postMemoUrl, EditorStyles.toolbarTextField); } EditorGUILayout.EndHorizontal(); if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { UnityEditorMemoPrefs.UnityEditorMemoSlackChannel = EditorGUILayout.TextField(UnityEditorMemoPrefs.UnityEditorMemoSlackChannel); postToSlack = GUILayout.Toggle(postToSlack, "Post to Slack", EditorStyles.toolbarButton, GUILayout.Width(100)); } EditorGUILayout.EndHorizontal(); } GUILayout.Space(5); EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { GUILayout.Label((WindowHelper.TEXT_CREATEMEMO_TITLE + category.Name).ToMiddleBold()); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); postScrollView = EditorGUILayout.BeginScrollView(postScrollView); { // draft var tmp = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) }); if (tmp != memoText) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT); memoText = tmp; } } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); postMemoTex = GUILayout.Toolbar(postMemoTex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.MaxWidth(150) }); //if ( GUILayout.Button( "test", new GUILayoutOption[] { GUILayout.Height( 30 ), GUILayout.Width( 50 ) } ) ) { // for( int i = 0; i < 110; i++ ) { // category.AddMemo( new UnityEditorMemo( i.ToString(), postMemoLabel, postMemoTex ) ); // } //} // post button GUI.backgroundColor = Color.cyan; if (GUILayout.Button("Post", new GUILayoutOption[] { GUILayout.Height(30), GUILayout.MaxWidth(120) })) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_POST); if (!string.IsNullOrEmpty(memoText)) { var memo = new UnityEditorMemo(memoText, postMemoLabel, postMemoTex, postMemoUrl); memo.id = category.Memo.Count; if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack && postToSlack) { if (SlackHelper.Post(memo, category.Name)) { OnMemoPost(category, memo); } } else { OnMemoPost(category, memo); } } else { Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY); } } GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); }