protected void open_dropdown(DropdownMenuData menu) { if (Dropdown.instance == null) { gameObject.AddOrGetComponent <Dropdown>().open(menu); } else { Dropdown.instance.close_menu(); } }
protected void dropdown(string label, string menu_ref, DropdownMenuData menu, DryUI parent_window, Rect offset, float btn_width, GUIStyle button_style, GUIStyle menu_style, GUIStyle menu_item_style, MenuResponse callback) { if (anchors.ContainsKey(menu_ref)) { menu.set_attributes(anchors[menu_ref], offset, parent_window, btn_width, menu_style, menu_item_style, callback); } if (GUILayout.Button(label, button_style, width(btn_width))) { open_dropdown(menu); } track_rect(menu_ref, GUILayoutUtility.GetLastRect(), true); }
protected void dropdown(string label_value, Texture texture, string menu_ref, DropdownMenuData menu, DryUI parent_window, Rect offset, float btn_width, GUIStyle button_style, GUIStyle menu_style, GUIStyle menu_item_style, MenuResponse callback) { if (anchors.ContainsKey(menu_ref)) { menu.set_attributes(anchors[menu_ref], offset, parent_window, btn_width, menu_style, menu_item_style, callback); } section("Button", () => { label(label_value, "button.text"); GUILayout.Label(texture, width(16f), height(16f)); }, evt => { if (evt.single_click) { open_dropdown(menu); } }); track_rect(menu_ref, GUILayoutUtility.GetLastRect(), true); }
protected void dropdown(string label_value, Texture texture, string menu_ref, DropdownMenuData menu, DryUI parent_window, Rect offset, float btn_width, MenuResponse callback) { dropdown(label_value, texture, menu_ref, menu, parent_window, offset, btn_width, "Button", "menu.background", "menu.item", callback); }
protected void dropdown(string label, string menu_ref, DropdownMenuData menu, DryUI parent_window, float btn_width, GUIStyle button_style, GUIStyle menu_style, GUIStyle menu_item_style, MenuResponse callback) { dropdown(label, menu_ref, menu, parent_window, default_offset, btn_width, button_style, menu_style, menu_item_style, callback); }
protected void dropdown(string label, string menu_ref, DropdownMenuData menu, DryUI parent_window, float btn_width, GUIStyle button_style, MenuResponse callback) { dropdown(label, menu_ref, menu, parent_window, btn_width, button_style, "menu.background", "menu.item", callback); }
public void open(DropdownMenuData menu_data) { menu = menu_data; anchor_rec = menu_data.attrs.anchor; anchor_offset = menu_data.attrs.offset; parent_window = menu_data.attrs.parent_window; skin = parent_window.skin; menu_content = (DropdownMenuData)menu_data; menu_content.fetch_data(); style_menu = menu_data.attrs.menu_style; style_menu_item = menu_data.attrs.menu_item_style; float h = anchor_rec.y + parent_window.window_pos.y + anchor_rec.height + anchor_offset.y; if (h + scroll_height > Screen.height) { scroll_height = Screen.height - h; } foreach (string val in menu_content.values) { float w = menu_data.attrs.menu_item_style.CalcSize(new GUIContent(val)).x + 15; if (w > menu_width) { menu_width = w; } } container.height = 10; Vector2 val_size; List <string> vals = new List <string>(menu_content.values); foreach (KeyValuePair <string, string> pair in menu_content.special_items) { vals.Add(pair.Value); } foreach (string val in vals) { val_size = menu_data.attrs.menu_item_style.CalcSize(new GUIContent(val)); float w = val_size.x + 15; container.height += val_size.y + 4; if (w > menu_width) { menu_width = w; } } container.width = menu_width + 5; scroll_width = menu_width + 6; if (container.height + 5 > scroll_height) { scroll_width += 22; container.width += 22; } if (menu.on_menu_open != null) { menu.on_menu_open(); } resp = menu_data.attrs.callback; }