public static CSGOperationType?ShowOperationChoicesInternal(Rect rect, CSGOperationType?operation, bool showAuto = true) { if (styles == null) { styles = new Styles(); } var additiveIcon = ChiselDefaultGeneratorDetails.GetIconContent(CSGOperationType.Additive, "Boolean Operation"); var subtractiveIcon = ChiselDefaultGeneratorDetails.GetIconContent(CSGOperationType.Subtractive, "Boolean Operation"); var intersectingIcon = ChiselDefaultGeneratorDetails.GetIconContent(CSGOperationType.Intersecting, "Boolean Operation"); using (new EditorGUIUtility.IconSizeScope(new Vector2(16, 16))) // This ensures that the icons will be the same size on regular displays and HDPI displays // Note that the loaded images are different sizes on different displays { Rect toggleRect = rect; toggleRect.xMin = toggleRect.xMax - GetOperationChoicesInternalWidth(showAuto); if (showAuto) { toggleRect.width = kAutomaticToggleWidth; var autoIcon = ChiselEditorResources.GetIconContent(kAutoIconName, $"Automatic boolean operation"); if (ToggleLabel(ref toggleRect, !operation.HasValue, autoIcon, styles.leftButton)) { return(null); } toggleRect.width = kOperationToggleWidth; } else { toggleRect.width = kOperationToggleWidth + kLeftStylePadding; } var operationType = !operation.HasValue ? ((CSGOperationType)255) : (operation.Value); if (Toggle(ref toggleRect, (operationType == CSGOperationType.Additive), additiveIcon, showAuto ? styles.midButton : styles.leftButton)) { return(CSGOperationType.Additive); } if (!showAuto) { toggleRect.width -= kLeftStylePadding; } if (Toggle(ref toggleRect, (operationType == CSGOperationType.Subtractive), subtractiveIcon, styles.midButton)) { return(CSGOperationType.Subtractive); } if (Toggle(ref toggleRect, (operationType == CSGOperationType.Intersecting), intersectingIcon, styles.rightButton)) { return(CSGOperationType.Intersecting); } return(operationType); } }
// TODO: put somewhere else public static CSGOperationType?ShowOperationChoicesInternal(CSGOperationType?operation, bool showAuto = true) { if (styles == null) { styles = new Styles(); } var additiveIcon = ChiselDefaultGeneratorDetails.GetIconContent(CSGOperationType.Additive, "Boolean Operation"); var subtractiveIcon = ChiselDefaultGeneratorDetails.GetIconContent(CSGOperationType.Subtractive, "Boolean Operation"); var intersectingIcon = ChiselDefaultGeneratorDetails.GetIconContent(CSGOperationType.Intersecting, "Boolean Operation"); using (new EditorGUIUtility.IconSizeScope(new Vector2(16, 16))) // This ensures that the icons will be the same size on regular displays and HDPI displays // Note that the loaded images are different sizes on different displays { if (showAuto) { const string kAutoIconName = "Automatic"; var autoIcon = ChiselEditorResources.GetIconContent(kAutoIconName, $"Automatic boolean operation"); if (Toggle(!operation.HasValue, autoIcon, styles.leftButton)) { return(null); } } var operationType = !operation.HasValue ? ((CSGOperationType)255) : (operation.Value); if (Toggle((operationType == CSGOperationType.Additive), additiveIcon, showAuto ? styles.midButton : styles.leftButton)) { return(CSGOperationType.Additive); } if (Toggle((operationType == CSGOperationType.Subtractive), subtractiveIcon, styles.midButton)) { return(CSGOperationType.Subtractive); } if (Toggle((operationType == CSGOperationType.Intersecting), intersectingIcon, styles.rightButton)) { return(CSGOperationType.Intersecting); } return(operationType); } }