internal override void DoRepaint(IStylePainter args) { int num; float elemWidth; float elemHeight; if (this.ComputeElemDimensions(out num, out elemWidth, out elemHeight)) { GUIStyle gUIStyle = GUIStyle.none; GUIClip.Internal_Push(base.position, Vector2.zero, Vector2.zero, false); Rect position = new Rect(0f, 0f, base.position.width, base.position.height); Rect[] array = IMButtonGrid.CalcMouseRects(position, num, this.xCount, elemWidth, elemHeight, base.style, this.firstStyle, this.midStyle, this.lastStyle, false); Vector2 mousePos = args.mousePosition - base.position.position; int buttonGridMouseSelection = this.GetButtonGridMouseSelection(array, mousePos, base.id == GUIUtility.hotControl); bool flag = position.Contains(args.mousePosition); GUIUtility.mouseUsed |= flag; for (int i = 0; i < num; i++) { GUIStyle gUIStyle2; if (i != 0) { gUIStyle2 = this.midStyle; } else { gUIStyle2 = this.firstStyle; } if (i == num - 1) { gUIStyle2 = this.lastStyle; } if (num == 1) { gUIStyle2 = base.style; } if (i != this.selected) { gUIStyle2.Draw(array[i], this.contents[i], i == buttonGridMouseSelection && (this.enabled || base.id == GUIUtility.hotControl) && (base.id == GUIUtility.hotControl || GUIUtility.hotControl == 0), base.id == GUIUtility.hotControl && this.enabled, false, false); } else { gUIStyle = gUIStyle2; } } if (this.selected < num && this.selected > -1) { gUIStyle.Draw(array[this.selected], this.contents[this.selected], this.selected == buttonGridMouseSelection && (this.enabled || base.id == GUIUtility.hotControl) && (base.id == GUIUtility.hotControl || GUIUtility.hotControl == 0), base.id == GUIUtility.hotControl, true, false); } if (buttonGridMouseSelection >= 0) { GUI.tooltip = this.contents[buttonGridMouseSelection].tooltip; } GUIClip.Internal_Pop(); } }
protected override bool DoMouseDown(MouseEventArgs args) { bool result; if (base.position.Contains(args.mousePosition)) { int count; float elemWidth; float elemHeight; if (this.ComputeElemDimensions(out count, out elemWidth, out elemHeight)) { Rect[] buttonRects = IMButtonGrid.CalcMouseRects(base.position, count, this.xCount, elemWidth, elemHeight, base.style, this.firstStyle, this.midStyle, this.lastStyle, false); if (this.GetButtonGridMouseSelection(buttonRects, args.mousePosition, true) != -1) { GUIUtility.hotControl = base.id; result = true; return(result); } } } result = false; return(result); }