private void ScrubButton_dragged(OxBase obj, Vector2 delta) { AppearanceInfo dimensions = CurrentAppearanceInfo(); float scrubPosition = scrubButton.x, scrubSize = scrubButton.width, barSize = dimensions.centerWidth, changeInProgress = delta.x; if (!horizontal) { scrubPosition = scrubButton.y; scrubSize = scrubButton.height; barSize = dimensions.centerHeight; changeInProgress = delta.y; } float amountChanged = progress; if (scrubPosition + changeInProgress < 0) { progress = 0; } else if (scrubPosition + changeInProgress > barSize - scrubSize) { progress = 1; } else { progress = OxHelpers.TruncateTo((scrubPosition + changeInProgress) / (barSize - scrubSize), 3); } amountChanged = progress - amountChanged; if (amountChanged != 0) { FireScrollValueChangedEvent(amountChanged); } }
protected void FireScrollValueChangedEvent(float delta) { if (scrollValueChanged != null) { scrollValueChanged(this, OxHelpers.TruncateTo(delta, 3)); } }
private void AddFiles() { string searchPattern = ""; for (int i = 0; i < extensions.Count; i++) { searchPattern += "*." + extensions[i]; if (i < extensions.Count - 1) { searchPattern += "|"; } } string[] files = new string[0]; if (searchPattern.Length > 0) { files = Directory.GetFiles(currentDirectory, searchPattern, SearchOption.TopDirectoryOnly); } else { files = Directory.GetFiles(currentDirectory); } foreach (string file in files) { string shortednedFile = OxHelpers.GetLastPartInAbsolutePath(file); OxButton fileButton = new OxButton(shortednedFile); AddItems(fileButton); } }
internal virtual void TextPaint() { AppearanceInfo dimensions = CurrentAppearanceInfo(); float xPos = x, yPos = y, drawWidth = dimensions.leftSideWidth, drawHeight = dimensions.topSideHeight; GUIStyle textStyle = new GUIStyle(); if (manualSizeAllText) { textStyle.fontSize = allTextSize; } else if (autoSizeAllText) { textStyle.fontSize = OxHelpers.CalculateFontSize(OxHelpers.InchesToPixel(new Vector2(0, 0.2f)).y); } else if (autoSizeText) { textStyle.fontSize = OxHelpers.CalculateFontSize(dimensions.centerHeight); } else { textStyle.fontSize = textSize; } textStyle.normal.textColor = textColor; textStyle.alignment = ((TextAnchor)textAlignment); textStyle.clipping = TextClipping.Clip; xPos = x; yPos = y; drawWidth = dimensions.leftSideWidth; drawHeight = dimensions.topSideHeight; if (textPosition == OxHelpers.Alignment.Top || textPosition == OxHelpers.Alignment.Center || textPosition == OxHelpers.Alignment.Bottom) { xPos += dimensions.leftSideWidth; drawWidth = dimensions.centerWidth; } else if (textPosition == OxHelpers.Alignment.Top_Right || textPosition == OxHelpers.Alignment.Right || textPosition == OxHelpers.Alignment.Bottom_Right) { xPos += dimensions.leftSideWidth + dimensions.centerWidth; drawWidth = dimensions.rightSideWidth; } if (textPosition == OxHelpers.Alignment.Left || textPosition == OxHelpers.Alignment.Center || textPosition == OxHelpers.Alignment.Right) { yPos += dimensions.topSideHeight; drawHeight = dimensions.centerHeight; } else if (textPosition == OxHelpers.Alignment.Bottom_Left || textPosition == OxHelpers.Alignment.Bottom || textPosition == OxHelpers.Alignment.Bottom_Right) { yPos += dimensions.topSideHeight + dimensions.centerHeight; drawHeight = dimensions.bottomSideHeight; } string shownText = text; if (shownText.Length <= 0 && value != null) { shownText = value.ToString(); } GUI.Label(new Rect(xPos, yPos, drawWidth, drawHeight), shownText, textStyle); }
private void AddDrives() { string[] drives = Directory.GetLogicalDrives(); foreach (string drive in drives) { OxButton driveButton = new OxButton(OxHelpers.PathConvention(drive)); driveButton.clicked += DirectoryButton_clicked; AddItems(driveButton); } }
private void AddDirectories() { string[] directories = Directory.GetDirectories(currentDirectory); foreach (string directory in directories) { string shortenedDirectory = OxHelpers.GetLastPartInAbsolutePath(directory); OxButton dirButton = new OxButton(shortenedDirectory + "/"); dirButton.clicked += DirectoryButton_clicked; AddItems(dirButton); } }
private void DirectoryButton_clicked(OxBase obj) { if (!dragging && (!directorySelection || obj.isSelected)) { string nextDirectory = currentDirectory + obj.text; if (OxHelpers.CanBrowseDirectory(nextDirectory)) { currentDirectory = nextDirectory; } savedScroll.Add(scrollProgress); scrollProgress = 0; } }
internal override void TextPaint() { AppearanceInfo dimensions = CurrentAppearanceInfo(); GUIStyle textStyle = new GUIStyle(); textStyle.font = font; if (manualSizeAllText) { textStyle.fontSize = allTextSize; } else if (autoSizeAllText) { textStyle.fontSize = OxHelpers.CalculateFontSize(OxHelpers.InchesToPixel(new Vector2(0, 0.2f)).y); } else if (autoSizeText) { textStyle.fontSize = OxHelpers.CalculateFontSize(dimensions.centerHeight); } else { textStyle.fontSize = textSize; } textStyle.normal.textColor = textColor; textStyle.wordWrap = wordWrap; textStyle.alignment = ((TextAnchor)textAlignment); textStyle.clipping = clipping; textStyle.contentOffset = contentOffset; textStyle.fontStyle = fontStyle; textStyle.richText = richText; //string shownText = text; if (text.Length <= 0 && value != null) { text = value.ToString(); } string prevText = text; if (multiline) { text = GUI.TextArea(new Rect(x + dimensions.leftSideWidth, y + dimensions.topSideHeight, dimensions.centerWidth, dimensions.centerHeight), text, textStyle); } else { text = GUI.TextField(new Rect(x + dimensions.leftSideWidth, y + dimensions.topSideHeight, dimensions.centerWidth, dimensions.centerHeight), text, textStyle); } if (!prevText.Equals(text)) { FireTextChangedEvent(prevText); } }
private void BackButton_clicked(OxBase obj) { if (!dragging) { currentDirectory = OxHelpers.ParentPath(currentDirectory); if (savedScroll.Count > 0) { scrollProgress = savedScroll[savedScroll.Count - 1]; savedScroll.RemoveAt(savedScroll.Count - 1); } else { scrollProgress = 0; } } }
private void PopulateList() { currentDirectory = OxHelpers.PathConvention(currentDirectory); FindDirectory(); ClearItems(); if (currentDirectory.Length > 0) { AddBackButton(); AddDirectories(); if (!directorySelection) { AddFiles(); } } else { AddDrives(); } }