public void UpdateRevisions(IEnumerable <RevisionData> datas, string tip, int totalRevisions, int currentPage) { var elements = new List <VisualElement>(); var isFullDateObtained = false; // Has everything from this date been obtained? m_HistoryItems.Clear(); if (datas != null) { DateTime currentDate = DateTime.MinValue; foreach (var data in datas) { if (data.timeStamp.Date != currentDate.Date) { elements.Add(new CollabHistoryRevisionLine(data.timeStamp, isFullDateObtained)); currentDate = data.timeStamp; } var item = new CollabHistoryItem(data); m_HistoryItems.Add(item); var container = new VisualContainer(); container.style.flexDirection = FlexDirection.Row; if (data.current) { isFullDateObtained = true; container.AddToClassList("currentRevision"); container.AddToClassList("obtainedRevision"); } else if (data.obtained) { container.AddToClassList("obtainedRevision"); } else { container.AddToClassList("absentRevision"); } // If we use the index as-is, the latest commit will become #1, but we want it to be last container.Add(new CollabHistoryRevisionLine(data.index)); container.Add(item); elements.Add(container); } } m_HistoryView.scrollOffset = new Vector2(0, 0); m_Pager.totalItems = totalRevisions; m_Pager.curPage = currentPage; m_Pager.items = elements; }
public VisualContainer CreateTask(string name) { var task = new VisualContainer(); task.focusIndex = 0; task.name = name; task.AddToClassList("task"); task.RegisterCallback <KeyDownEvent, VisualContainer>(DeleteTask, task); var taskName = new Toggle(() => {}) { text = name, name = "checkbox" }; task.Add(taskName); var taskDelete = new Button(() => task.parent.Remove(task)) { name = "delete", text = "Delete" }; task.Add(taskDelete); return(task); }
public void OnEnable() { var root = this.GetRootVisualContainer(); root.AddStyleSheetPath("styles"); // Here we just take all layout properties and other to extract them in USS! var boxes = new VisualContainer() { name = "boxesContainer" }; boxes.AddToClassList("horizontalContainer"); root.Add(boxes); for (int i = 0; i < m_Colors.Length; i++) { Color c = m_Colors[i]; // inform layout system of desired width for each box boxes.Add(new VisualElement() { style = { backgroundColor = c } }); } // Some more advanced layout now! var twoPlusOneContainer = new VisualContainer() { name = "2Plus1Container" }; twoPlusOneContainer.AddToClassList("horizontalContainer"); root.Add(twoPlusOneContainer); twoPlusOneContainer.Add(new VisualElement() { name = "large" }); twoPlusOneContainer.Add(new VisualElement() { name = "small" }); var wrapContainer = new VisualContainer() { name = "wrapContainer" }; wrapContainer.AddToClassList("horizontalContainer"); root.Add(wrapContainer); for (int i = 0; i < 20; i++) { wrapContainer.Add(new VisualElement()); } }
public void UpdateRevisions(IEnumerable <RevisionData> datas, string tip, int totalRevisions) { List <VisualElement> list = new List <VisualElement>(); bool isFullDateObtained = false; this.m_HistoryItems.Clear(); DateTime dateTime = DateTime.MinValue; foreach (RevisionData current in datas) { if (current.timeStamp.Date != dateTime.Date) { list.Add(new CollabHistoryRevisionLine(current.timeStamp, isFullDateObtained)); dateTime = current.timeStamp; } CollabHistoryItem collabHistoryItem = new CollabHistoryItem(current); this.m_HistoryItems.Add(collabHistoryItem); VisualContainer visualContainer = new VisualContainer(); visualContainer.style.flexDirection = FlexDirection.Row; if (current.current) { isFullDateObtained = true; visualContainer.AddToClassList("currentRevision"); visualContainer.AddToClassList("obtainedRevision"); } else if (current.obtained) { visualContainer.AddToClassList("obtainedRevision"); } else { visualContainer.AddToClassList("absentRevision"); } visualContainer.Add(new CollabHistoryRevisionLine(current.index)); visualContainer.Add(collabHistoryItem); list.Add(visualContainer); } this.m_Pager.totalItems = totalRevisions; this.m_Pager.items = list; }
private void TaskListSection(VisualElement root) { VisualContainer list = new VisualContainer { name = "taskList" }; root.Add(list); foreach (string task in _selectedTodo.GetAllTasks()) { VisualContainer row = new VisualContainer(); row.AddToClassList("taskRow"); list.Add(row); Label taskNameLabel = new Label(task); taskNameLabel.AddToClassList("taskNameLabel"); if (_selectedTodo.GetTask(task) ?? true) { taskNameLabel.AddToClassList("taskDone"); } row.Add(taskNameLabel); Button taskUpdateButton = new Button(() => UpdateTodoTask(task)); taskUpdateButton.AddToClassList("taskUpdateButton"); if (_selectedTodo.GetTask(task) ?? true) { taskNameLabel.AddToClassList("taskDone"); taskUpdateButton.text = "Not Done"; } else { taskUpdateButton.text = "Done"; } row.Add(taskUpdateButton); Button taskDeleteButton = new Button(() => DeleteTodoTask(task)) { text = "Delete" }; taskDeleteButton.AddToClassList("taskDeleteButton"); row.Add(taskDeleteButton); } }
public VisualContainer CreateTask(string name) { var task = new VisualContainer(); task.name = name; task.AddToClassList("task"); var taskName = new Toggle(() => {}) { text = name, name = "checkbox" }; task.AddChild(taskName); var taskDelete = new Button(() => task.parent.RemoveChild(task)) { name = "delete", text = "Delete" }; task.AddChild(taskDelete); return(task); }
public void AddMyPorts() { m_InputPortBox = new VisualContainer() { name = "input-port-box" }; m_OutputPortBox = new VisualContainer() { name = "output-port-box" }; m_InputPortBox.AddToClassList("port-box"); m_OutputPortBox.AddToClassList("port-box"); contentContainer.AddToClassList("center-content-vertically"); contentContainer.Add(m_InputPortBox); contentContainer.Add(m_OutputPortBox); AddPort(Orientation.Horizontal, Direction.Input, ""); AddPort(Orientation.Horizontal, Direction.Output, ""); }