public static bool nk_do_selectable(ref uint state, CommandBuffer _out_, RectangleF bounds, string str, nk_text_align align, ref bool value, nk_style_selectable style, nk_input _in_, nk_font font) { bool old_value; var touch = new RectangleF(); if (_out_ == null || str == null || style == null || font == null) { return(false); } old_value = value; touch.X = bounds.X - style.touch_padding.X; touch.Y = bounds.Y - style.touch_padding.Y; touch.Width = bounds.Width + style.touch_padding.X * 2; touch.Height = bounds.Height + style.touch_padding.Y * 2; if (ButtonBehavior(ref state, touch, _in_, NK_BUTTON_DEFAULT)) { value = !value; } if (style.draw_begin != null) { style.draw_begin(_out_); } _out_.DrawSelectable(state, style, value, &bounds, null, null, str, align, font); if (style.draw_end != null) { style.draw_end(_out_); } return(old_value != value); }
public static bool nk_do_selectable_image(ref uint state, CommandBuffer _out_, RectangleF bounds, string str, nk_text_align align, ref bool value, nk_image img, nk_style_selectable style, nk_input _in_, nk_font font) { bool old_value; var touch = new RectangleF(); var icon = new RectangleF(); if (_out_ == null || str == null || style == null || font == null) { return(false); } old_value = value; touch.X = bounds.X - style.touch_padding.X; touch.Y = bounds.Y - style.touch_padding.Y; touch.Width = bounds.Width + style.touch_padding.X * 2; touch.Height = bounds.Height + style.touch_padding.Y * 2; if (ButtonBehavior(ref state, touch, _in_, NK_BUTTON_DEFAULT)) { value = !value; } icon.Y = bounds.Y + style.padding.Y; icon.Width = icon.Height = bounds.Height - 2 * style.padding.Y; if ((align & nk_text_align.NK_TEXT_ALIGN_LEFT) != 0) { icon.X = bounds.X + bounds.Width - (2 * style.padding.X + icon.Width); icon.X = icon.X < 0 ? 0 : icon.X; } else { icon.X = bounds.X + 2 * style.padding.X; } icon.X += style.image_padding.X; icon.Y += style.image_padding.Y; icon.Width -= 2 * style.image_padding.X; icon.Height -= 2 * style.image_padding.Y; if (style.draw_begin != null) { style.draw_begin(_out_); } _out_.DrawSelectable(state, style, value, &bounds, &icon, img, str, align, font); if (style.draw_end != null) { style.draw_end(_out_); } return(old_value != value); }