nuklear/
lib.rs

1#![cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ptr))] // TODO later
2#![cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] // TODO later
3#![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] // API requirement
4#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] // API requirement
5#![cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))] // API requirement
6#![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] // required by allocator
7#![cfg_attr(feature = "cargo-clippy", allow(non_upper_case_globals))]
8#![allow(non_upper_case_globals)]
9#![cfg_attr(feature = "rust_allocator", feature(allocator_api))]
10
11#[macro_use]
12extern crate log;
13
14#[cfg(feature = "rust_allocator")]
15mod alloc_heap;
16mod alloc_vec;
17
18use std::borrow::Cow;
19use std::default::Default;
20use std::os::raw::*;
21
22use nuklear_sys::*;
23
24pub use nuklear_sys;
25pub use nuklear_sys::nk_allocation_type as AllocationType;
26pub use nuklear_sys::nk_draw_list_stroke as DrawListStroke;
27pub use nuklear_sys::nk_flags as Flags; //TODO
28pub use nuklear_sys::nk_font_coord_type as FontCoordType;
29pub use nuklear_sys::nk_panel_row_layout_type as PanelRowLayoutType;
30pub use nuklear_sys::nk_panel_type as PanelType;
31pub use nuklear_sys::nk_style_colors as StyleColor;
32pub use nuklear_sys::nk_style_cursor as StyleCursor;
33pub use nuklear_sys::nk_style_header_align as StyleHeaderAlign;
34pub use nuklear_sys::nk_widget_layout_states as WidgetLayoutState;
35
36pub use nuklear_sys::nk_chart_slot as ChartSlot;
37pub use nuklear_sys::nk_color as Color;
38pub use nuklear_sys::nk_colorf as ColorF;
39pub use nuklear_sys::nk_menu_state as MenuState;
40pub use nuklear_sys::nk_popup_buffer as PopupBuffer;
41pub use nuklear_sys::nk_rect as Rect;
42pub use nuklear_sys::nk_recti as Recti;
43pub use nuklear_sys::nk_scroll as Scroll;
44pub use nuklear_sys::nk_size as Size;
45pub use nuklear_sys::nk_style_text as StyleText;
46pub use nuklear_sys::nk_vec2 as Vec2;
47pub use nuklear_sys::nk_vec2i as Vec2i;
48
49pub use nuklear_sys::nk_glyph as Glyph;
50
51pub use nuklear_sys::nk_plugin_copy as PluginCopy;
52pub use nuklear_sys::nk_plugin_filter as PluginFilter;
53pub use nuklear_sys::nk_plugin_paste as PluginPaste;
54
55pub const NK_FILTER_DEFAULT: PluginFilter = Some(nk_filter_default);
56pub const NK_FILTER_ASCII: PluginFilter = Some(nk_filter_ascii);
57pub const NK_FILTER_FLOAT: PluginFilter = Some(nk_filter_float);
58pub const NK_FILTER_DECIMAL: PluginFilter = Some(nk_filter_decimal);
59pub const NK_FILTER_HEX: PluginFilter = Some(nk_filter_hex);
60pub const NK_FILTER_OCT: PluginFilter = Some(nk_filter_oct);
61pub const NK_FILTER_BINARY: PluginFilter = Some(nk_filter_binary);
62
63pub const ALIGNMENT: usize = 16;
64
65macro_rules! wrapper_impls {
66    ($name:ident, $typ:ty) => {
67        impl AsRef<$typ> for $name {
68            fn as_ref(&self) -> &$typ {
69                &self.internal
70            }
71        }
72        impl AsMut<$typ> for $name {
73            fn as_mut(&mut self) -> &mut $typ {
74                &mut self.internal
75            }
76        }
77        impl AsRef<$name> for $typ {
78            fn as_ref(&self) -> &$name {
79                unsafe { &*(self as *const $typ as *const $name) }
80            }
81        }
82        impl AsMut<$name> for $typ {
83            fn as_mut(&mut self) -> &mut $name {
84                unsafe { &mut *(self as *mut $typ as *mut $name) }
85            }
86        }
87
88        impl Default for $name {
89            fn default() -> Self {
90                $name { internal: unsafe { ::std::mem::zeroed() } }
91            }
92        }
93    };
94}
95
96macro_rules! wrapper_type {
97    ($name:ident, $typ:ty) => {
98        #[derive(Clone)]
99        #[repr(C)]
100        pub struct $name {
101            internal: $typ,
102        }
103
104        wrapper_impls!($name, $typ);
105    };
106}
107
108macro_rules! wrapper_type_no_clone {
109    ($name:ident, $typ:ty) => {
110        #[repr(C)]
111        pub struct $name {
112            internal: $typ,
113        }
114
115        wrapper_impls!($name, $typ);
116    };
117}
118
119macro_rules! from_into_enum {
120    ($name:ident, $typ:ty) => {
121        impl From<$name> for $typ {
122            fn from(a: $name) -> $typ {
123                a as $typ
124            }
125        }
126        impl From<$typ> for $name {
127            fn from(a: $typ) -> $name {
128                unsafe { ::std::mem::transmute(a) }
129            }
130        }
131        impl<'a> From<&'a $typ> for &'a $name {
132            fn from(a: &'a $typ) -> &'a $name {
133                unsafe { ::std::mem::transmute(a) }
134            }
135        }
136    };
137}
138
139// ==========================================================================================================
140
141#[repr(C)]
142#[derive(Clone, Copy, PartialEq, Eq)]
143pub enum CommandType {
144    Nop = nk_command_type_NK_COMMAND_NOP as isize,
145    Scissor = nk_command_type_NK_COMMAND_SCISSOR as isize,
146    Line = nk_command_type_NK_COMMAND_LINE as isize,
147    Curve = nk_command_type_NK_COMMAND_CURVE as isize,
148    Rect = nk_command_type_NK_COMMAND_RECT as isize,
149    RectFilled = nk_command_type_NK_COMMAND_RECT_FILLED as isize,
150    RectMultiColor = nk_command_type_NK_COMMAND_RECT_MULTI_COLOR as isize,
151    Circle = nk_command_type_NK_COMMAND_CIRCLE as isize,
152    CircleFilled = nk_command_type_NK_COMMAND_CIRCLE_FILLED as isize,
153    Arc = nk_command_type_NK_COMMAND_ARC as isize,
154    ArcFilled = nk_command_type_NK_COMMAND_ARC_FILLED as isize,
155    Triangle = nk_command_type_NK_COMMAND_TRIANGLE as isize,
156    TriangleFilled = nk_command_type_NK_COMMAND_TRIANGLE_FILLED as isize,
157    Polygon = nk_command_type_NK_COMMAND_POLYGON as isize,
158    PolygonFilled = nk_command_type_NK_COMMAND_POLYGON_FILLED as isize,
159    Polyline = nk_command_type_NK_COMMAND_POLYLINE as isize,
160    Text = nk_command_type_NK_COMMAND_TEXT as isize,
161    Image = nk_command_type_NK_COMMAND_IMAGE as isize,
162    Custom = nk_command_type_NK_COMMAND_CUSTOM as isize,
163}
164from_into_enum!(CommandType, nk_command_type);
165
166// ==========================================================================================================
167
168#[repr(C)]
169#[derive(Clone, Copy, PartialEq, Eq)]
170pub enum SymbolType {
171    None = nk_symbol_type_NK_SYMBOL_NONE as isize,
172    X = nk_symbol_type_NK_SYMBOL_X as isize,
173    Underscore = nk_symbol_type_NK_SYMBOL_UNDERSCORE as isize,
174    CircleSolid = nk_symbol_type_NK_SYMBOL_CIRCLE_SOLID as isize,
175    CircleOutline = nk_symbol_type_NK_SYMBOL_CIRCLE_OUTLINE as isize,
176    RectSolid = nk_symbol_type_NK_SYMBOL_RECT_SOLID as isize,
177    RectOutline = nk_symbol_type_NK_SYMBOL_RECT_OUTLINE as isize,
178    TriangleUp = nk_symbol_type_NK_SYMBOL_TRIANGLE_UP as isize,
179    TriangleDown = nk_symbol_type_NK_SYMBOL_TRIANGLE_DOWN as isize,
180    TriangleLeft = nk_symbol_type_NK_SYMBOL_TRIANGLE_LEFT as isize,
181    TriangleRight = nk_symbol_type_NK_SYMBOL_TRIANGLE_RIGHT as isize,
182    Plus = nk_symbol_type_NK_SYMBOL_PLUS as isize,
183    Minus = nk_symbol_type_NK_SYMBOL_MINUS as isize,
184    Max = nk_symbol_type_NK_SYMBOL_MAX as isize,
185}
186from_into_enum!(SymbolType, nk_symbol_type);
187
188// ==========================================================================================================
189
190#[repr(C)]
191#[derive(Clone, Copy, PartialEq, Eq)]
192pub enum EditFlag {
193    Default = nk_edit_flags_NK_EDIT_DEFAULT as isize,
194    ReadOnly = nk_edit_flags_NK_EDIT_READ_ONLY as isize,
195    AutoSelect = nk_edit_flags_NK_EDIT_AUTO_SELECT as isize,
196    SigEnter = nk_edit_flags_NK_EDIT_SIG_ENTER as isize,
197    AllowTab = nk_edit_flags_NK_EDIT_ALLOW_TAB as isize,
198    NoCursor = nk_edit_flags_NK_EDIT_NO_CURSOR as isize,
199    Selectable = nk_edit_flags_NK_EDIT_SELECTABLE as isize,
200    Clipboard = nk_edit_flags_NK_EDIT_CLIPBOARD as isize,
201    CtrlEnterNewline = nk_edit_flags_NK_EDIT_CTRL_ENTER_NEWLINE as isize,
202    NoHorizontalScroll = nk_edit_flags_NK_EDIT_NO_HORIZONTAL_SCROLL as isize,
203    AlwaysInsertMode = nk_edit_flags_NK_EDIT_ALWAYS_INSERT_MODE as isize,
204    Multiline = nk_edit_flags_NK_EDIT_MULTILINE as isize,
205    GoToEndOnActivate = nk_edit_flags_NK_EDIT_GOTO_END_ON_ACTIVATE as isize,
206}
207from_into_enum!(EditFlag, nk_edit_flags);
208
209// ==========================================================================================================
210
211#[repr(C)]
212#[derive(Clone, Copy, PartialEq, Eq)]
213pub enum EditType {
214    Simple = nk_edit_types_NK_EDIT_SIMPLE as isize,
215    Field = nk_edit_types_NK_EDIT_FIELD as isize,
216    Box = nk_edit_types_NK_EDIT_BOX as isize,
217    Editor = nk_edit_types_NK_EDIT_EDITOR as isize,
218}
219from_into_enum!(EditType, nk_edit_types);
220
221// ==========================================================================================================
222
223#[repr(C)]
224#[derive(Clone, Copy, PartialEq, Eq)]
225pub enum EditEvent {
226    Active = nk_edit_events_NK_EDIT_ACTIVE as isize,
227    Inactive = nk_edit_events_NK_EDIT_INACTIVE as isize,
228    Activated = nk_edit_events_NK_EDIT_ACTIVATED as isize,
229    Deactivated = nk_edit_events_NK_EDIT_DEACTIVATED as isize,
230    Commited = nk_edit_events_NK_EDIT_COMMITED as isize,
231}
232from_into_enum!(EditEvent, nk_edit_events);
233
234// ==========================================================================================================
235
236#[repr(C)]
237#[derive(Clone, Copy, PartialEq, Eq)]
238pub enum PanelFlags {
239    Border = nk_panel_flags_NK_WINDOW_BORDER as isize,
240    Movable = nk_panel_flags_NK_WINDOW_MOVABLE as isize,
241    Scalable = nk_panel_flags_NK_WINDOW_SCALABLE as isize,
242    Closable = nk_panel_flags_NK_WINDOW_CLOSABLE as isize,
243    Minimizable = nk_panel_flags_NK_WINDOW_MINIMIZABLE as isize,
244    NoScrollbar = nk_panel_flags_NK_WINDOW_NO_SCROLLBAR as isize,
245    Title = nk_panel_flags_NK_WINDOW_TITLE as isize,
246    ScrollAutoHide = nk_panel_flags_NK_WINDOW_SCROLL_AUTO_HIDE as isize,
247    Background = nk_panel_flags_NK_WINDOW_BACKGROUND as isize,
248    ScaleLeft = nk_panel_flags_NK_WINDOW_SCALE_LEFT as isize,
249    NoInput = nk_panel_flags_NK_WINDOW_NO_INPUT as isize,
250}
251from_into_enum!(PanelFlags, nk_panel_flags);
252
253// ==========================================================================================================
254
255#[repr(C)]
256#[derive(Clone, Copy, PartialEq, Eq)]
257pub enum Heading {
258    Up = nk_heading_NK_UP as isize,
259    Right = nk_heading_NK_RIGHT as isize,
260    Down = nk_heading_NK_DOWN as isize,
261    Left = nk_heading_NK_LEFT as isize,
262}
263from_into_enum!(Heading, nk_heading);
264
265// ==========================================================================================================
266
267#[repr(C)]
268#[derive(Clone, Copy, PartialEq, Eq)]
269pub enum ButtonBehavior {
270    Default = nk_button_behavior_NK_BUTTON_DEFAULT as isize,
271    Repeater = nk_button_behavior_NK_BUTTON_REPEATER as isize,
272}
273from_into_enum!(ButtonBehavior, nk_button_behavior);
274
275// ==========================================================================================================
276
277#[repr(C)]
278#[derive(Clone, Copy, PartialEq, Eq)]
279pub enum Modify {
280    Fixed = nk_modify_NK_FIXED as isize,
281    Modifiable = nk_modify_NK_MODIFIABLE as isize,
282}
283from_into_enum!(Modify, nk_modify);
284
285// ==========================================================================================================
286
287#[repr(C)]
288#[derive(Clone, Copy, PartialEq, Eq)]
289pub enum Orientation {
290    Vertical = nk_orientation_NK_VERTICAL as isize,
291    Horizontal = nk_orientation_NK_HORIZONTAL as isize,
292}
293from_into_enum!(Orientation, nk_orientation);
294
295// ==========================================================================================================
296
297#[repr(C)]
298#[derive(Clone, Copy, PartialEq, Eq)]
299pub enum CollapseState {
300    Minimized = nk_collapse_states_NK_MINIMIZED as isize,
301    Maximized = nk_collapse_states_NK_MAXIMIZED as isize,
302}
303from_into_enum!(CollapseState, nk_collapse_states);
304
305// ==========================================================================================================
306
307#[repr(C)]
308#[derive(Clone, Copy, PartialEq, Eq)]
309pub enum ShowState {
310    Hidden = nk_show_states_NK_HIDDEN as isize,
311    Shown = nk_show_states_NK_SHOWN as isize,
312}
313from_into_enum!(ShowState, nk_show_states);
314
315// ==========================================================================================================
316
317#[repr(C)]
318#[derive(Clone, Copy, PartialEq, Eq)]
319pub enum ChartType {
320    Lines = nk_chart_type_NK_CHART_LINES as isize,
321    Column = nk_chart_type_NK_CHART_COLUMN as isize,
322    Max = nk_chart_type_NK_CHART_MAX as isize,
323}
324from_into_enum!(ChartType, nk_chart_type);
325
326// ==========================================================================================================
327
328#[repr(C)]
329#[derive(Clone, Copy, PartialEq, Eq)]
330pub enum ChartEvent {
331    Hovering = nk_chart_event_NK_CHART_HOVERING as isize,
332    Clicked = nk_chart_event_NK_CHART_CLICKED as isize,
333}
334from_into_enum!(ChartEvent, nk_chart_event);
335
336// ==========================================================================================================
337
338#[repr(C)]
339#[derive(Clone, Copy, PartialEq, Eq)]
340pub enum ColorFormat {
341    Rgb = nk_color_format_NK_RGB as isize,
342    Rgba = nk_color_format_NK_RGBA as isize,
343}
344from_into_enum!(ColorFormat, nk_color_format);
345
346// ==========================================================================================================
347
348#[repr(C)]
349#[derive(Clone, Copy, PartialEq, Eq)]
350pub enum PopupType {
351    Static = nk_popup_type_NK_POPUP_STATIC as isize,
352    Dynamic = nk_popup_type_NK_POPUP_DYNAMIC as isize,
353}
354from_into_enum!(PopupType, nk_popup_type);
355
356// ==========================================================================================================
357
358#[repr(C)]
359#[derive(Clone, Copy, PartialEq, Eq)]
360pub enum LayoutFormat {
361    Dynamic = nk_layout_format_NK_DYNAMIC as isize,
362    Static = nk_layout_format_NK_STATIC as isize,
363}
364from_into_enum!(LayoutFormat, nk_layout_format);
365
366// ==========================================================================================================
367
368#[repr(C)]
369#[derive(Clone, Copy, PartialEq, Eq)]
370pub enum TreeType {
371    Node = nk_tree_type_NK_TREE_NODE as isize,
372    Tab = nk_tree_type_NK_TREE_TAB as isize,
373}
374from_into_enum!(TreeType, nk_tree_type);
375
376// ==========================================================================================================
377
378#[repr(C)]
379#[derive(Clone, Copy, PartialEq, Eq)]
380pub enum TextAlign {
381    Left = nk_text_align_NK_TEXT_ALIGN_LEFT as isize,
382    Centered = nk_text_align_NK_TEXT_ALIGN_CENTERED as isize,
383    Right = nk_text_align_NK_TEXT_ALIGN_RIGHT as isize,
384    Top = nk_text_align_NK_TEXT_ALIGN_TOP as isize,
385    Middle = nk_text_align_NK_TEXT_ALIGN_MIDDLE as isize,
386    Bottom = nk_text_align_NK_TEXT_ALIGN_BOTTOM as isize,
387}
388from_into_enum!(TextAlign, nk_text_align);
389
390// ==========================================================================================================
391
392#[repr(C)]
393#[derive(Clone, Copy, PartialEq, Eq)]
394pub enum TextAlignment {
395    Left = nk_text_alignment_NK_TEXT_LEFT as isize,
396    Centered = nk_text_alignment_NK_TEXT_CENTERED as isize,
397    Right = nk_text_alignment_NK_TEXT_RIGHT as isize,
398}
399from_into_enum!(TextAlignment, nk_text_alignment);
400
401// ==========================================================================================================
402
403#[repr(C)]
404#[derive(Clone, Copy, PartialEq, Eq)]
405pub enum Key {
406    None = nk_keys_NK_KEY_NONE as isize,
407    Shift = nk_keys_NK_KEY_SHIFT as isize,
408    Ctrl = nk_keys_NK_KEY_CTRL as isize,
409    Del = nk_keys_NK_KEY_DEL as isize,
410    Enter = nk_keys_NK_KEY_ENTER as isize,
411    Tab = nk_keys_NK_KEY_TAB as isize,
412    Backspace = nk_keys_NK_KEY_BACKSPACE as isize,
413    Copy = nk_keys_NK_KEY_COPY as isize,
414    Cut = nk_keys_NK_KEY_CUT as isize,
415    Paste = nk_keys_NK_KEY_PASTE as isize,
416    Up = nk_keys_NK_KEY_UP as isize,
417    Down = nk_keys_NK_KEY_DOWN as isize,
418    Left = nk_keys_NK_KEY_LEFT as isize,
419    Right = nk_keys_NK_KEY_RIGHT as isize,
420    InsertMode = nk_keys_NK_KEY_TEXT_INSERT_MODE as isize,
421    ReplaceMode = nk_keys_NK_KEY_TEXT_REPLACE_MODE as isize,
422    ResetMode = nk_keys_NK_KEY_TEXT_RESET_MODE as isize,
423    LineStart = nk_keys_NK_KEY_TEXT_LINE_START as isize,
424    LineEnd = nk_keys_NK_KEY_TEXT_LINE_END as isize,
425    TextStart = nk_keys_NK_KEY_TEXT_START as isize,
426    TextEnd = nk_keys_NK_KEY_TEXT_END as isize,
427    TextUndo = nk_keys_NK_KEY_TEXT_UNDO as isize,
428    TextRedo = nk_keys_NK_KEY_TEXT_REDO as isize,
429    TextSelectAll = nk_keys_NK_KEY_TEXT_SELECT_ALL as isize,
430    TextWordLeft = nk_keys_NK_KEY_TEXT_WORD_LEFT as isize,
431    TextWordRight = nk_keys_NK_KEY_TEXT_WORD_RIGHT as isize,
432    ScrollStart = nk_keys_NK_KEY_SCROLL_START as isize,
433    ScrollEnd = nk_keys_NK_KEY_SCROLL_END as isize,
434    ScrollDown = nk_keys_NK_KEY_SCROLL_DOWN as isize,
435    ScrollUp = nk_keys_NK_KEY_SCROLL_UP as isize,
436}
437from_into_enum!(Key, nk_keys);
438
439// ==========================================================================================================
440
441#[repr(C)]
442#[derive(Clone, Copy, PartialEq, Eq)]
443pub enum Button {
444    Left = nk_buttons_NK_BUTTON_LEFT as isize,
445    Middle = nk_buttons_NK_BUTTON_MIDDLE as isize,
446    Right = nk_buttons_NK_BUTTON_RIGHT as isize,
447    Double = nk_buttons_NK_BUTTON_DOUBLE as isize,
448    Max = nk_buttons_NK_BUTTON_MAX as isize,
449}
450from_into_enum!(Button, nk_buttons);
451
452// ==========================================================================================================
453
454#[repr(C)]
455#[derive(Clone, Copy, PartialEq, Eq)]
456pub enum AntiAliasing {
457    Off = nk_anti_aliasing_NK_ANTI_ALIASING_OFF as isize,
458    On = nk_anti_aliasing_NK_ANTI_ALIASING_ON as isize,
459}
460from_into_enum!(AntiAliasing, nk_anti_aliasing);
461
462// ==========================================================================================================
463
464#[repr(C)]
465#[derive(Clone, Copy, PartialEq, Eq)]
466pub enum DrawVertexLayoutFormat {
467    Char = nk_draw_vertex_layout_format_NK_FORMAT_SCHAR as isize,
468    Short = nk_draw_vertex_layout_format_NK_FORMAT_SSHORT as isize,
469    Int = nk_draw_vertex_layout_format_NK_FORMAT_SINT as isize,
470    Uchar = nk_draw_vertex_layout_format_NK_FORMAT_UCHAR as isize,
471    Ushort = nk_draw_vertex_layout_format_NK_FORMAT_USHORT as isize,
472    Uint = nk_draw_vertex_layout_format_NK_FORMAT_UINT as isize,
473    Float = nk_draw_vertex_layout_format_NK_FORMAT_FLOAT as isize,
474    Double = nk_draw_vertex_layout_format_NK_FORMAT_DOUBLE as isize,
475    R8G8B8 = nk_draw_vertex_layout_format_NK_FORMAT_R8G8B8 as isize,
476    R16G16B16 = nk_draw_vertex_layout_format_NK_FORMAT_R16G15B16 as isize,
477    R32G32B32 = nk_draw_vertex_layout_format_NK_FORMAT_R32G32B32 as isize,
478    R8G8B8A8 = nk_draw_vertex_layout_format_NK_FORMAT_R8G8B8A8 as isize,
479    B8G8R8A8 = nk_draw_vertex_layout_format_NK_FORMAT_B8G8R8A8 as isize,
480    R16G15B16A16 = nk_draw_vertex_layout_format_NK_FORMAT_R16G15B16A16 as isize,
481    R32G32B32A32 = nk_draw_vertex_layout_format_NK_FORMAT_R32G32B32A32 as isize,
482    R32G32B32A32Float = nk_draw_vertex_layout_format_NK_FORMAT_R32G32B32A32_FLOAT as isize,
483    R32G32B32A32Double = nk_draw_vertex_layout_format_NK_FORMAT_R32G32B32A32_DOUBLE as isize,
484    Rgb32 = nk_draw_vertex_layout_format_NK_FORMAT_RGB32 as isize,
485    Rgba32 = nk_draw_vertex_layout_format_NK_FORMAT_RGBA32 as isize,
486    Count = nk_draw_vertex_layout_format_NK_FORMAT_COUNT as isize,
487}
488from_into_enum!(DrawVertexLayoutFormat, nk_draw_vertex_layout_format);
489
490// ==========================================================================================================
491
492#[repr(C)]
493#[derive(Clone, Copy, PartialEq, Eq)]
494pub enum DrawVertexLayoutAttribute {
495    Position = nk_draw_vertex_layout_attribute_NK_VERTEX_POSITION as isize,
496    Color = nk_draw_vertex_layout_attribute_NK_VERTEX_COLOR as isize,
497    TexCoord = nk_draw_vertex_layout_attribute_NK_VERTEX_TEXCOORD as isize,
498    AttributeCount = nk_draw_vertex_layout_attribute_NK_VERTEX_ATTRIBUTE_COUNT as isize,
499}
500from_into_enum!(DrawVertexLayoutAttribute, nk_draw_vertex_layout_attribute);
501
502// ==========================================================================================================
503
504#[repr(C)]
505#[derive(Clone, Copy, PartialEq, Eq)]
506pub enum FontAtlasFormat {
507    Alpha8 = nk_font_atlas_format_NK_FONT_ATLAS_ALPHA8 as isize,
508    Rgba32 = nk_font_atlas_format_NK_FONT_ATLAS_RGBA32 as isize,
509}
510from_into_enum!(FontAtlasFormat, nk_font_atlas_format);
511
512// ==========================================================================================================
513
514unsafe extern "C" fn nk_filter_custom(arg1: *const nk_text_edit, unicode: nk_rune) -> ::std::os::raw::c_int {
515    if let Some(f) = CUSTOM_EDIT_FILTER {
516        if f(&*(arg1 as *const TextEdit), ::std::char::from_u32_unchecked(unicode)) {
517            1
518        } else {
519            0
520        }
521    } else {
522        1
523    }
524}
525
526static mut CUSTOM_EDIT_FILTER: Option<fn(&TextEdit, char) -> bool> = None;
527
528// ===========================================================================================================
529
530// unsafe extern "C" fn nk_plot_value_getter_custom(user: *mut ::std::os::raw::c_void, index: ::std::os::raw::c_int) -> f32 {
531// let f = user as *const _ as &[f32];
532// f[index as usize]
533// }
534
535// ===========================================================================================================
536
537#[derive(Clone)]
538pub struct String<'a> {
539    bytes: Cow<'a, [u8]>,
540}
541
542impl<'a> String<'a> {
543    pub unsafe fn from_bytes_unchecked(bytes: &'a [u8]) -> String<'a> {
544        String { bytes: Cow::Borrowed(bytes) }
545    }
546    pub fn as_ptr(&self) -> *const c_char {
547        self.bytes.as_ptr() as *const c_char
548    }
549
550    // pub fn nk_str_init(arg1: *mut nk_str, arg2: *const nk_allocator,
551    // size: nk_size);
552    // pub fn nk_str_init_fixed(arg1: *mut nk_str,
553    // memory: *mut ::std::os::raw::c_void,
554    // size: nk_size);
555    // pub fn nk_str_clear(arg1: *mut nk_str);
556    // pub fn nk_str_free(arg1: *mut nk_str);
557    // pub fn nk_str_append_text_char(arg1: *mut nk_str,
558    // arg2: *const ::std::os::raw::c_char,
559    // arg3: ::std::os::raw::c_int)
560    // -> ::std::os::raw::c_int;
561    // pub fn nk_str_append_str_char(arg1: *mut nk_str,
562    // arg2: *const ::std::os::raw::c_char)
563    // -> ::std::os::raw::c_int;
564    // pub fn nk_str_append_text_utf8(arg1: *mut nk_str,
565    // arg2: *const ::std::os::raw::c_char,
566    // arg3: ::std::os::raw::c_int)
567    // -> ::std::os::raw::c_int;
568    // pub fn nk_str_append_str_utf8(arg1: *mut nk_str,
569    // arg2: *const ::std::os::raw::c_char)
570    // -> ::std::os::raw::c_int;
571    // pub fn nk_str_append_text_runes(arg1: *mut nk_str, arg2: *const nk_rune,
572    // arg3: ::std::os::raw::c_int)
573    // -> ::std::os::raw::c_int;
574    // pub fn nk_str_append_str_runes(arg1: *mut nk_str, arg2: *const nk_rune)
575    // -> ::std::os::raw::c_int;
576    // pub fn nk_str_insert_at_char(arg1: *mut nk_str,
577    // pos: ::std::os::raw::c_int,
578    // arg2: *const ::std::os::raw::c_char,
579    // arg3: ::std::os::raw::c_int)
580    // -> ::std::os::raw::c_int;
581    // pub fn nk_str_insert_at_rune(arg1: *mut nk_str,
582    // pos: ::std::os::raw::c_int,
583    // arg2: *const ::std::os::raw::c_char,
584    // arg3: ::std::os::raw::c_int)
585    // -> ::std::os::raw::c_int;
586    // pub fn nk_str_insert_text_char(arg1: *mut nk_str,
587    // pos: ::std::os::raw::c_int,
588    // arg2: *const ::std::os::raw::c_char,
589    // arg3: ::std::os::raw::c_int)
590    // -> ::std::os::raw::c_int;
591    // pub fn nk_str_insert_str_char(arg1: *mut nk_str,
592    // pos: ::std::os::raw::c_int,
593    // arg2: *const ::std::os::raw::c_char)
594    // -> ::std::os::raw::c_int;
595    // pub fn nk_str_insert_text_utf8(arg1: *mut nk_str,
596    // pos: ::std::os::raw::c_int,
597    // arg2: *const ::std::os::raw::c_char,
598    // arg3: ::std::os::raw::c_int)
599    // -> ::std::os::raw::c_int;
600    // pub fn nk_str_insert_str_utf8(arg1: *mut nk_str,
601    // pos: ::std::os::raw::c_int,
602    // arg2: *const ::std::os::raw::c_char)
603    // -> ::std::os::raw::c_int;
604    // pub fn nk_str_insert_text_runes(arg1: *mut nk_str,
605    // pos: ::std::os::raw::c_int,
606    // arg2: *const nk_rune,
607    // arg3: ::std::os::raw::c_int)
608    // -> ::std::os::raw::c_int;
609    // pub fn nk_str_insert_str_runes(arg1: *mut nk_str,
610    // pos: ::std::os::raw::c_int,
611    // arg2: *const nk_rune)
612    // -> ::std::os::raw::c_int;
613    // pub fn nk_str_remove_chars(arg1: *mut nk_str, len: ::std::os::raw::c_int);
614    // pub fn nk_str_remove_runes(str: *mut nk_str, len: ::std::os::raw::c_int);
615    // pub fn nk_str_delete_chars(arg1: *mut nk_str, pos: ::std::os::raw::c_int,
616    // len: ::std::os::raw::c_int);
617    // pub fn nk_str_delete_runes(arg1: *mut nk_str, pos: ::std::os::raw::c_int,
618    // len: ::std::os::raw::c_int);
619    // pub fn nk_str_at_char(arg1: *mut nk_str, pos: ::std::os::raw::c_int)
620    // -> *mut ::std::os::raw::c_char;
621    // pub fn nk_str_at_rune(arg1: *mut nk_str, pos: ::std::os::raw::c_int,
622    // unicode: *mut nk_rune,
623    // len: *mut ::std::os::raw::c_int)
624    // -> *mut ::std::os::raw::c_char;
625    // pub fn nk_str_rune_at(arg1: *const nk_str, pos: ::std::os::raw::c_int)
626    // -> nk_rune;
627    // pub fn nk_str_at_char_const(arg1: *const nk_str,
628    // pos: ::std::os::raw::c_int)
629    // -> *const ::std::os::raw::c_char;
630    // pub fn nk_str_at_const(arg1: *const nk_str, pos: ::std::os::raw::c_int,
631    // unicode: *mut nk_rune,
632    // len: *mut ::std::os::raw::c_int)
633    // -> *const ::std::os::raw::c_char;
634    // pub fn nk_str_get(arg1: *mut nk_str) -> *mut ::std::os::raw::c_char;
635    // pub fn nk_str_get_const(arg1: *const nk_str)
636    // -> *const ::std::os::raw::c_char;
637    // pub fn nk_str_len(arg1: *mut nk_str) -> ::std::os::raw::c_int;
638    // pub fn nk_str_len_char(arg1: *mut nk_str) -> ::std::os::raw::c_int;
639    //
640}
641
642impl<'a> From<&'a str> for String<'a> {
643    fn from(value: &'a str) -> String<'a> {
644        let mut bytes: Vec<u8> = value.bytes().collect();
645        bytes.push(0);
646        String { bytes: Cow::Owned(bytes) }
647    }
648}
649
650impl<'a> From<::std::string::String> for String<'a> {
651    fn from(mut value: ::std::string::String) -> String<'a> {
652        value.push('\0');
653        String { bytes: Cow::Owned(value.into_bytes()) }
654    }
655}
656
657#[macro_export]
658macro_rules! nk_string {
659    ($e:tt) => ({
660        let value = concat!($e, "\0");
661        unsafe { $crate::String::from_bytes_unchecked(value.as_bytes()) }
662    });
663    ($e:tt, $($arg:tt)*) => ({
664        $crate::String::from(format!($e, $($arg)*))
665    })
666}
667
668// ======================================================================================
669
670#[derive(Clone)]
671pub struct StringArray<'a> {
672    arr: Vec<String<'a>>,
673    ptrs: Vec<*const c_char>,
674}
675
676impl<'a> StringArray<'a> {
677    pub fn as_ptr(&self) -> *const *const c_char {
678        self.ptrs.as_slice() as *const _ as *const *const c_char
679    }
680    pub fn as_mut(&mut self) -> *mut *const c_char {
681        self.ptrs.as_mut_slice() as *mut _ as *mut *const c_char
682    }
683    pub fn len(&self) -> usize {
684        self.ptrs.len()
685    }
686    pub fn is_empty(&self) -> bool {
687        self.len() < 1
688    }
689}
690
691impl<'a> From<&'a [&'a str]> for StringArray<'a> {
692    fn from(value: &[&'a str]) -> StringArray<'a> {
693        let mut r = StringArray {
694            arr: Vec::with_capacity(value.len()),
695            ptrs: Vec::with_capacity(value.len()),
696        };
697
698        for s in value {
699            r.arr.push(String::from(*s));
700            r.ptrs.push(r.arr[r.arr.len() - 1].as_ptr());
701        }
702
703        r
704    }
705}
706
707// ======================================================================================
708
709#[derive(Debug, Clone, PartialEq, Copy)]
710enum HandleKind {
711    Empty,
712    Ptr,
713    Id,
714    Unknown,
715}
716
717#[derive(Clone, Copy)]
718#[repr(C)]
719pub struct Handle {
720    internal: nk_handle,
721    kind: HandleKind,
722}
723
724impl Default for Handle {
725    fn default() -> Self {
726        Handle {
727            kind: HandleKind::Empty,
728            internal: nk_handle::default(),
729        }
730    }
731}
732
733impl Handle {
734    pub fn id(&mut self) -> Option<i32> {
735        match self.kind {
736            HandleKind::Id | HandleKind::Unknown => Some(unsafe { self.internal.id }),
737            _ => None,
738        }
739    }
740
741    pub fn ptr(&mut self) -> Option<*mut c_void> {
742        match self.kind {
743            HandleKind::Ptr | HandleKind::Unknown => Some(unsafe { self.internal.ptr }),
744            _ => None,
745        }
746    }
747
748    pub fn from_id(value: i32) -> Handle {
749        Handle {
750            kind: HandleKind::Id,
751            internal: unsafe { nk_handle_id(value) },
752        }
753    }
754
755    pub unsafe fn from_ptr(value: *mut c_void) -> Handle {
756        Handle { kind: HandleKind::Ptr, internal: nk_handle_ptr(value) }
757    }
758}
759
760// ==================================================================================
761
762/*
763wrapper_type!(ConfigurationStacks, nk_configuration_stacks);
764
765impl ConfigurationStacks {
766    pub style_items: nk_config_stack_style_item,
767    pub floats: nk_config_stack_float,
768    pub vectors: nk_config_stack_vec2,
769    pub flags: nk_config_stack_flags,
770    pub colors: nk_config_stack_color,
771    pub fonts: nk_config_stack_user_font,
772    pub button_behaviors: nk_config_stack_button_behavior,
773
774}
775*/
776
777// ==================================================================================
778
779wrapper_type!(Clipboard, nk_clipboard);
780
781impl Clipboard {
782    pub unsafe fn userdata_ptr(&self) -> Handle {
783        Handle::from_ptr(self.internal.userdata.ptr)
784    }
785    pub unsafe fn userdata_id(&self) -> Handle {
786        Handle::from_id(self.internal.userdata.id)
787    }
788
789    pub fn paste(&self) -> PluginPaste {
790        self.internal.paste
791    }
792    pub fn set_paste(&mut self, plug: PluginPaste) {
793        self.internal.paste = plug;
794    }
795    pub fn copy(&self) -> PluginCopy {
796        self.internal.copy
797    }
798    pub fn set_copy(&mut self, plug: PluginCopy) {
799        self.internal.copy = plug;
800    }
801}
802
803// ==================================================================================
804
805wrapper_type!(Input, nk_input);
806
807impl Input {
808    pub fn mouse(&self) -> Mouse {
809        Mouse { internal: self.internal.mouse }
810    }
811
812    pub fn has_mouse_click(&self, b: Button) -> bool {
813        unsafe { nk_input_has_mouse_click(&self.internal, b.into()) != 0 }
814    }
815
816    pub fn has_mouse_click_in_rect(&self, b: Button, rect: Rect) -> bool {
817        unsafe { nk_input_has_mouse_click_in_rect(&self.internal, b.into(), rect) != 0 }
818    }
819
820    pub fn has_mouse_click_down_in_rect(&self, b: Button, rect: Rect, down: bool) -> bool {
821        unsafe { nk_input_has_mouse_click_down_in_rect(&self.internal, b.into(), rect, if down { 1 } else { 0 }) != 0 }
822    }
823
824    pub fn is_mouse_click_in_rect(&self, b: Button, rect: Rect) -> bool {
825        unsafe { nk_input_is_mouse_click_in_rect(&self.internal, b.into(), rect) != 0 }
826    }
827
828    pub fn is_mouse_click_down_in_rect(&self, b: Button, rect: Rect, down: bool) -> bool {
829        unsafe { nk_input_is_mouse_click_down_in_rect(&self.internal, b.into(), rect, down as ::std::os::raw::c_int) != 0 }
830    }
831
832    pub fn any_mouse_click_in_rect(&self, rect: Rect) -> bool {
833        unsafe { nk_input_any_mouse_click_in_rect(&self.internal, rect) != 0 }
834    }
835
836    pub fn is_mouse_prev_hovering_rect(&self, rect: Rect) -> bool {
837        unsafe { nk_input_is_mouse_prev_hovering_rect(&self.internal, rect) != 0 }
838    }
839
840    pub fn is_mouse_hovering_rect(&self, rect: Rect) -> bool {
841        unsafe { nk_input_is_mouse_hovering_rect(&self.internal, rect) != 0 }
842    }
843
844    pub fn is_mouse_clicked(&self, b: Button, rect: Rect) -> bool {
845        unsafe { nk_input_mouse_clicked(&self.internal, b.into(), rect) != 0 }
846    }
847
848    pub fn is_mouse_down(&self, b: Button) -> bool {
849        unsafe { nk_input_is_mouse_down(&self.internal, b.into()) != 0 }
850    }
851
852    pub fn is_mouse_pressed(&self, b: Button) -> bool {
853        unsafe { nk_input_is_mouse_pressed(&self.internal, b.into()) != 0 }
854    }
855
856    pub fn is_mouse_released(&self, b: Button) -> bool {
857        unsafe { nk_input_is_mouse_released(&self.internal, b.into()) != 0 }
858    }
859
860    pub fn is_key_pressed(&self, k: Key) -> bool {
861        unsafe { nk_input_is_key_pressed(&self.internal, k.into()) != 0 }
862    }
863
864    pub fn is_key_released(&self, k: Key) -> bool {
865        unsafe { nk_input_is_key_released(&self.internal, k.into()) != 0 }
866    }
867
868    pub fn is_key_down(&self, k: Key) -> bool {
869        unsafe { nk_input_is_key_down(&self.internal, k.into()) != 0 }
870    }
871}
872
873// =====================================================================
874
875wrapper_type!(DrawCommand, nk_draw_command);
876
877impl DrawCommand {
878    pub fn clip_rect(&self) -> &Rect {
879        &self.internal.clip_rect
880    }
881
882    pub fn elem_count(&self) -> u32 {
883        self.internal.elem_count
884    }
885
886    pub fn texture(&self) -> Handle {
887        Handle {
888            kind: HandleKind::Unknown,
889            internal: self.internal.texture,
890        }
891    }
892}
893
894// =====================================================================
895
896#[derive(Copy, Clone, Debug)]
897pub struct MouseButton {
898    pub down: bool,
899    pub clicked: bool,
900    pub clicked_pos: Vec2,
901}
902
903impl MouseButton {
904    fn from_native(n: nk_mouse_button) -> MouseButton {
905        MouseButton {
906            down: n.down > 0,
907            clicked: n.clicked > 0,
908            clicked_pos: n.clicked_pos,
909        }
910    }
911}
912
913wrapper_type!(Mouse, nk_mouse);
914
915impl Mouse {
916    pub fn pos(&self) -> &Vec2 {
917        &self.internal.pos
918    }
919
920    pub fn prev(&self) -> &Vec2 {
921        &self.internal.prev
922    }
923
924    pub fn delta(&self) -> &Vec2 {
925        &self.internal.delta
926    }
927
928    pub fn scroll_delta(&self) -> &Vec2 {
929        &self.internal.scroll_delta
930    }
931
932    pub fn buttons(&self) -> [MouseButton; 3] {
933        [MouseButton::from_native(self.internal.buttons[0]), MouseButton::from_native(self.internal.buttons[1]), MouseButton::from_native(self.internal.buttons[2])]
934    }
935
936    pub fn grabbed(&self) -> bool {
937        self.internal.grabbed > 0
938    }
939
940    // pub fn grab(&mut self) {
941    // self.internal.grab = 1;
942    // self.internal.ungrab = 0;
943    // }
944    //
945    // pub fn ungrab(&mut self) {
946    // self.internal.grab = 0;
947    // self.internal.ungrab = 1;
948    // }
949}
950
951// =====================================================================
952
953// =====================================================================
954
955wrapper_type!(Style, nk_style);
956
957impl Style {
958    // ===== mut getters =====
959
960    pub fn window_mut(&mut self) -> &mut StyleWindow {
961        unsafe { ::std::mem::transmute(&mut self.internal.window) }
962    }
963
964    pub fn font_mut(&mut self) -> &mut UserFont {
965        unsafe { ::std::mem::transmute(self.internal.font) }
966    }
967
968    pub fn cursors_mut(&mut self) -> &mut CursorMap {
969        unsafe { ::std::mem::transmute(&mut self.internal.cursors) }
970    }
971
972    pub fn cursor_active_mut(&mut self) -> &mut Cursor {
973        unsafe { ::std::mem::transmute(&mut self.internal.cursor_active) }
974    }
975
976    pub fn set_cursor_visible(&mut self, value: bool) {
977        self.internal.cursor_visible = if value { 1 } else { 0 }
978    }
979
980    pub fn text_mut(&mut self) -> &mut StyleText {
981        &mut self.internal.text
982    }
983
984    pub fn button_mut(&mut self) -> &mut StyleButton {
985        unsafe { ::std::mem::transmute(&mut self.internal.button) }
986    }
987
988    pub fn contextual_button_mut(&mut self) -> &mut StyleButton {
989        unsafe { ::std::mem::transmute(&mut self.internal.contextual_button) }
990    }
991
992    pub fn menu_button_mut(&mut self) -> &mut StyleButton {
993        unsafe { ::std::mem::transmute(&mut self.internal.menu_button) }
994    }
995
996    pub fn option_mut(&mut self) -> &mut StyleToggle {
997        unsafe { ::std::mem::transmute(&mut self.internal.option) }
998    }
999
1000    pub fn checkbox_mut(&mut self) -> &mut StyleToggle {
1001        unsafe { ::std::mem::transmute(&mut self.internal.checkbox) }
1002    }
1003
1004    pub fn selectable_mut(&mut self) -> &mut StyleSelectable {
1005        unsafe { ::std::mem::transmute(&mut self.internal.selectable) }
1006    }
1007
1008    pub fn slider_mut(&mut self) -> &mut StyleSlider {
1009        unsafe { ::std::mem::transmute(&mut self.internal.slider) }
1010    }
1011
1012    pub fn progress_mut(&mut self) -> &mut StyleProgress {
1013        unsafe { ::std::mem::transmute(&mut self.internal.progress) }
1014    }
1015
1016    pub fn property_mut(&mut self) -> &mut StyleProperty {
1017        unsafe { ::std::mem::transmute(&mut self.internal.property) }
1018    }
1019
1020    pub fn edit_mut(&mut self) -> &mut StyleEdit {
1021        unsafe { ::std::mem::transmute(&mut self.internal.edit) }
1022    }
1023
1024    pub fn chart_mut(&mut self) -> &mut StyleChart {
1025        unsafe { ::std::mem::transmute(&mut self.internal.chart) }
1026    }
1027
1028    pub fn scroll_h_mut(&mut self) -> &mut StyleScrollbar {
1029        unsafe { ::std::mem::transmute(&mut self.internal.scrollh) }
1030    }
1031
1032    pub fn scroll_v_mut(&mut self) -> &mut StyleScrollbar {
1033        unsafe { ::std::mem::transmute(&mut self.internal.scrollv) }
1034    }
1035
1036    pub fn tab_mut(&mut self) -> &mut StyleTab {
1037        unsafe { ::std::mem::transmute(&mut self.internal.tab) }
1038    }
1039
1040    pub fn combo_mut(&mut self) -> &mut StyleCombo {
1041        unsafe { ::std::mem::transmute(&mut self.internal.combo) }
1042    }
1043
1044    // ===== getters =====
1045
1046    pub fn window(&self) -> &StyleWindow {
1047        unsafe { ::std::mem::transmute(&self.internal.window) }
1048    }
1049
1050    pub fn font(&self) -> &UserFont {
1051        unsafe { ::std::mem::transmute(self.internal.font) }
1052    }
1053
1054    pub fn cursors(&self) -> &CursorMap {
1055        unsafe { ::std::mem::transmute(&self.internal.cursors) }
1056    }
1057
1058    pub fn cursor_active(&self) -> &Cursor {
1059        unsafe { ::std::mem::transmute(&self.internal.cursor_active) }
1060    }
1061
1062    pub fn cursor_visible(&self) -> bool {
1063        self.internal.cursor_visible > 0
1064    }
1065
1066    pub fn text(&self) -> &StyleText {
1067        &self.internal.text
1068    }
1069
1070    pub fn button(&self) -> &StyleButton {
1071        unsafe { ::std::mem::transmute(&self.internal.button) }
1072    }
1073
1074    pub fn contextual_button(&self) -> &StyleButton {
1075        unsafe { ::std::mem::transmute(&self.internal.contextual_button) }
1076    }
1077
1078    pub fn menu_button(&self) -> &StyleButton {
1079        unsafe { ::std::mem::transmute(&self.internal.menu_button) }
1080    }
1081
1082    pub fn option(&self) -> &StyleToggle {
1083        unsafe { ::std::mem::transmute(&self.internal.option) }
1084    }
1085
1086    pub fn checkbox(&self) -> &StyleToggle {
1087        unsafe { ::std::mem::transmute(&self.internal.checkbox) }
1088    }
1089
1090    pub fn selectable(&self) -> &StyleSelectable {
1091        unsafe { ::std::mem::transmute(&self.internal.selectable) }
1092    }
1093
1094    pub fn slider(&self) -> &StyleSlider {
1095        unsafe { ::std::mem::transmute(&self.internal.slider) }
1096    }
1097
1098    pub fn progress(&self) -> &StyleProgress {
1099        unsafe { ::std::mem::transmute(&self.internal.progress) }
1100    }
1101
1102    pub fn property(&self) -> &StyleProperty {
1103        unsafe { ::std::mem::transmute(&self.internal.property) }
1104    }
1105
1106    pub fn edit(&self) -> &StyleEdit {
1107        unsafe { ::std::mem::transmute(&self.internal.edit) }
1108    }
1109
1110    pub fn chart(&self) -> &StyleChart {
1111        unsafe { ::std::mem::transmute(&self.internal.chart) }
1112    }
1113
1114    pub fn scroll_h(&self) -> &StyleScrollbar {
1115        unsafe { ::std::mem::transmute(&self.internal.scrollh) }
1116    }
1117
1118    pub fn scroll_v(&self) -> &StyleScrollbar {
1119        unsafe { ::std::mem::transmute(&self.internal.scrollv) }
1120    }
1121
1122    pub fn tab(&self) -> &StyleTab {
1123        unsafe { ::std::mem::transmute(&self.internal.tab) }
1124    }
1125
1126    pub fn combo(&self) -> &StyleCombo {
1127        unsafe { ::std::mem::transmute(&self.internal.combo) }
1128    }
1129}
1130
1131// =====================================================================
1132
1133wrapper_type!(StyleCombo, nk_style_combo);
1134
1135impl StyleCombo {
1136    // ===== getters =====
1137
1138    pub fn normal(&self) -> &StyleItem {
1139        unsafe { ::std::mem::transmute(&self.internal.normal) }
1140    }
1141
1142    pub fn hover(&self) -> &StyleItem {
1143        unsafe { ::std::mem::transmute(&self.internal.hover) }
1144    }
1145
1146    pub fn active(&self) -> &StyleItem {
1147        unsafe { ::std::mem::transmute(&self.internal.active) }
1148    }
1149
1150    pub fn border_color(&self) -> &Color {
1151        &self.internal.border_color
1152    }
1153
1154    pub fn label_normal(&self) -> &Color {
1155        &self.internal.label_normal
1156    }
1157
1158    pub fn label_hover(&self) -> &Color {
1159        &self.internal.label_hover
1160    }
1161
1162    pub fn label_active(&self) -> &Color {
1163        &self.internal.label_active
1164    }
1165
1166    pub fn symbol_normal(&self) -> &Color {
1167        &self.internal.symbol_normal
1168    }
1169
1170    pub fn symbol_hover(&self) -> &Color {
1171        &self.internal.symbol_hover
1172    }
1173
1174    pub fn symbol_active(&self) -> &Color {
1175        &self.internal.symbol_active
1176    }
1177
1178    pub fn button(&self) -> &StyleButton {
1179        unsafe { ::std::mem::transmute(&self.internal.button) }
1180    }
1181
1182    pub fn sym_normal(&self) -> &SymbolType {
1183        (&self.internal.sym_normal).into()
1184    }
1185
1186    pub fn sym_hover(&self) -> &SymbolType {
1187        (&self.internal.sym_hover).into()
1188    }
1189
1190    pub fn sym_active(&self) -> &SymbolType {
1191        (&self.internal.sym_active).into()
1192    }
1193
1194    pub fn border(&self) -> f32 {
1195        self.internal.border
1196    }
1197
1198    pub fn rounding(&self) -> f32 {
1199        self.internal.rounding
1200    }
1201
1202    pub fn content_padding(&self) -> &Vec2 {
1203        &self.internal.content_padding
1204    }
1205
1206    pub fn button_padding(&self) -> &Vec2 {
1207        &self.internal.button_padding
1208    }
1209
1210    pub fn spacing(&self) -> &Vec2 {
1211        &self.internal.spacing
1212    }
1213
1214    // ===== setters ======
1215
1216    pub fn set_normal(&mut self, i: StyleItem) {
1217        self.internal.normal = i.internal;
1218    }
1219
1220    pub fn set_hover(&mut self, i: StyleItem) {
1221        self.internal.hover = i.internal;
1222    }
1223
1224    pub fn set_active(&mut self, i: StyleItem) {
1225        self.internal.active = i.internal;
1226    }
1227
1228    pub fn set_border_color(&mut self, c: Color) {
1229        self.internal.border_color = c
1230    }
1231
1232    pub fn set_label_normal(&mut self, c: Color) {
1233        self.internal.label_normal = c
1234    }
1235
1236    pub fn set_label_hover(&mut self, c: Color) {
1237        self.internal.label_hover = c
1238    }
1239
1240    pub fn set_label_active(&mut self, c: Color) {
1241        self.internal.label_active = c
1242    }
1243
1244    pub fn set_symbol_normal(&mut self, c: Color) {
1245        self.internal.symbol_normal = c
1246    }
1247
1248    pub fn set_symbol_hover(&mut self, c: Color) {
1249        self.internal.symbol_hover = c
1250    }
1251
1252    pub fn set_symbol_active(&mut self, c: Color) {
1253        self.internal.symbol_active = c
1254    }
1255
1256    pub fn set_button(&mut self, s: StyleButton) {
1257        self.internal.button = s.internal
1258    }
1259
1260    pub fn set_sym_normal(&mut self, t: SymbolType) {
1261        self.internal.sym_normal = t.into()
1262    }
1263
1264    pub fn set_sym_hover(&mut self, t: SymbolType) {
1265        self.internal.sym_hover = t.into()
1266    }
1267
1268    pub fn set_sym_active(&mut self, t: SymbolType) {
1269        self.internal.sym_active = t.into()
1270    }
1271
1272    pub fn set_border(&mut self, v: f32) {
1273        self.internal.border = v
1274    }
1275
1276    pub fn set_rounding(&mut self, v: f32) {
1277        self.internal.rounding = v
1278    }
1279
1280    pub fn set_content_padding(&mut self, v: Vec2) {
1281        self.internal.content_padding = v
1282    }
1283
1284    pub fn set_button_padding(&mut self, v: Vec2) {
1285        self.internal.button_padding = v
1286    }
1287
1288    pub fn set_spacing(&mut self, v: Vec2) {
1289        self.internal.spacing = v
1290    }
1291}
1292
1293// =====================================================================
1294
1295wrapper_type!(StyleTab, nk_style_tab);
1296
1297impl StyleTab {
1298    // ===== getters =====
1299
1300    pub fn background(&self) -> &StyleItem {
1301        unsafe { ::std::mem::transmute(&self.internal.background) }
1302    }
1303
1304    pub fn border_color(&self) -> &Color {
1305        &self.internal.border_color
1306    }
1307
1308    pub fn text(&self) -> &Color {
1309        &self.internal.text
1310    }
1311
1312    pub fn tab_maximize_button(&self) -> &StyleButton {
1313        unsafe { ::std::mem::transmute(&self.internal.tab_maximize_button) }
1314    }
1315
1316    pub fn tab_minimize_button(&self) -> &StyleButton {
1317        unsafe { ::std::mem::transmute(&self.internal.tab_minimize_button) }
1318    }
1319
1320    pub fn node_maximize_button(&self) -> &StyleButton {
1321        unsafe { ::std::mem::transmute(&self.internal.node_maximize_button) }
1322    }
1323
1324    pub fn node_minimize_button(&self) -> &StyleButton {
1325        unsafe { ::std::mem::transmute(&self.internal.node_minimize_button) }
1326    }
1327
1328    pub fn sym_minimize(&self) -> &SymbolType {
1329        (&self.internal.sym_minimize).into()
1330    }
1331
1332    pub fn sym_maximize(&self) -> &SymbolType {
1333        (&self.internal.sym_maximize).into()
1334    }
1335
1336    pub fn border(&self) -> f32 {
1337        self.internal.border
1338    }
1339
1340    pub fn rounding(&self) -> f32 {
1341        self.internal.rounding
1342    }
1343
1344    pub fn indent(&self) -> f32 {
1345        self.internal.indent
1346    }
1347
1348    pub fn padding(&self) -> &Vec2 {
1349        &self.internal.padding
1350    }
1351
1352    pub fn spacing(&self) -> &Vec2 {
1353        &self.internal.spacing
1354    }
1355
1356    // ===== setters =====
1357
1358    pub fn set_background(&mut self, i: StyleItem) {
1359        self.internal.background = i.internal;
1360    }
1361
1362    pub fn set_border_color(&mut self, c: Color) {
1363        self.internal.border_color = c
1364    }
1365
1366    pub fn set_text(&mut self, c: Color) {
1367        self.internal.text = c
1368    }
1369
1370    pub fn set_tab_maximize_button(&mut self, s: StyleButton) {
1371        self.internal.tab_maximize_button = s.internal
1372    }
1373
1374    pub fn set_tab_minimize_button(&mut self, s: StyleButton) {
1375        self.internal.tab_minimize_button = s.internal
1376    }
1377
1378    pub fn set_node_maximize_button(&mut self, s: StyleButton) {
1379        self.internal.node_maximize_button = s.internal
1380    }
1381
1382    pub fn set_node_minimize_button(&mut self, s: StyleButton) {
1383        self.internal.node_minimize_button = s.internal
1384    }
1385
1386    pub fn set_sym_minimize(&mut self, t: SymbolType) {
1387        self.internal.sym_minimize = t.into()
1388    }
1389
1390    pub fn set_sym_maximize(&mut self, t: SymbolType) {
1391        self.internal.sym_maximize = t.into()
1392    }
1393
1394    pub fn set_border(&mut self, v: f32) {
1395        self.internal.border = v
1396    }
1397
1398    pub fn set_rounding(&mut self, v: f32) {
1399        self.internal.rounding = v
1400    }
1401
1402    pub fn set_indent(&mut self, v: f32) {
1403        self.internal.indent = v
1404    }
1405
1406    pub fn set_padding(&mut self, v: Vec2) {
1407        self.internal.padding = v
1408    }
1409
1410    pub fn set_spacing(&mut self, v: Vec2) {
1411        self.internal.spacing = v
1412    }
1413}
1414
1415// =====================================================================
1416
1417wrapper_type!(StyleScrollbar, nk_style_scrollbar);
1418
1419impl StyleScrollbar {
1420    // ===== getters =====
1421
1422    pub fn normal(&self) -> &StyleItem {
1423        unsafe { ::std::mem::transmute(&self.internal.normal) }
1424    }
1425
1426    pub fn hover(&self) -> &StyleItem {
1427        unsafe { ::std::mem::transmute(&self.internal.hover) }
1428    }
1429
1430    pub fn active(&self) -> &StyleItem {
1431        unsafe { ::std::mem::transmute(&self.internal.active) }
1432    }
1433
1434    pub fn border_color(&self) -> &Color {
1435        &self.internal.border_color
1436    }
1437
1438    pub fn cursor_normal(&self) -> &StyleItem {
1439        unsafe { ::std::mem::transmute(&self.internal.cursor_normal) }
1440    }
1441
1442    pub fn cursor_hover(&self) -> &StyleItem {
1443        unsafe { ::std::mem::transmute(&self.internal.cursor_hover) }
1444    }
1445
1446    pub fn cursor_active(&self) -> &StyleItem {
1447        unsafe { ::std::mem::transmute(&self.internal.cursor_active) }
1448    }
1449
1450    pub fn cursor_border_color(&self) -> &Color {
1451        &self.internal.cursor_border_color
1452    }
1453
1454    pub fn border(&self) -> f32 {
1455        self.internal.border
1456    }
1457
1458    pub fn rounding(&self) -> f32 {
1459        self.internal.rounding
1460    }
1461
1462    pub fn border_cursor(&self) -> f32 {
1463        self.internal.border_cursor
1464    }
1465
1466    pub fn rounding_cursor(&self) -> f32 {
1467        self.internal.rounding_cursor
1468    }
1469
1470    pub fn padding(&self) -> &Vec2 {
1471        &self.internal.padding
1472    }
1473
1474    pub fn show_buttons(&self) -> bool {
1475        self.internal.show_buttons > 0
1476    }
1477
1478    pub fn inc_button(&self) -> &StyleButton {
1479        unsafe { ::std::mem::transmute(&self.internal.inc_button) }
1480    }
1481
1482    pub fn dec_button(&self) -> &StyleButton {
1483        unsafe { ::std::mem::transmute(&self.internal.dec_button) }
1484    }
1485
1486    pub fn inc_symbol(&self) -> &SymbolType {
1487        (&self.internal.inc_symbol).into()
1488    }
1489
1490    pub fn dec_symbol(&self) -> &SymbolType {
1491        (&self.internal.dec_symbol).into()
1492    }
1493
1494    // ===== setters =====
1495
1496    pub fn set_normal(&mut self, i: StyleItem) {
1497        self.internal.normal = i.internal;
1498    }
1499
1500    pub fn set_hover(&mut self, i: StyleItem) {
1501        self.internal.hover = i.internal;
1502    }
1503
1504    pub fn set_active(&mut self, i: StyleItem) {
1505        self.internal.active = i.internal;
1506    }
1507
1508    pub fn set_border_color(&mut self, c: Color) {
1509        self.internal.border_color = c
1510    }
1511
1512    pub fn set_cursor_normal(&mut self, i: StyleItem) {
1513        self.internal.cursor_normal = i.internal;
1514    }
1515
1516    pub fn set_cursor_hover(&mut self, i: StyleItem) {
1517        self.internal.cursor_hover = i.internal;
1518    }
1519
1520    pub fn set_cursor_active(&mut self, i: StyleItem) {
1521        self.internal.cursor_active = i.internal;
1522    }
1523
1524    pub fn set_cursor_border_color(&mut self, c: Color) {
1525        self.internal.cursor_border_color = c
1526    }
1527
1528    pub fn set_border(&mut self, v: f32) {
1529        self.internal.border = v
1530    }
1531
1532    pub fn set_rounding(&mut self, v: f32) {
1533        self.internal.rounding = v
1534    }
1535
1536    pub fn set_border_cursor(&mut self, v: f32) {
1537        self.internal.border_cursor = v
1538    }
1539
1540    pub fn set_rounding_cursor(&mut self, v: f32) {
1541        self.internal.rounding_cursor = v
1542    }
1543
1544    pub fn set_padding(&mut self, v: Vec2) {
1545        self.internal.padding = v
1546    }
1547
1548    pub fn set_show_buttons(&mut self, show: bool) {
1549        self.internal.show_buttons = if show { 1 } else { 0 }
1550    }
1551
1552    pub fn set_inc_button(&mut self, s: StyleButton) {
1553        self.internal.inc_button = s.internal
1554    }
1555
1556    pub fn set_dec_button(&mut self, s: StyleButton) {
1557        self.internal.dec_button = s.internal
1558    }
1559
1560    pub fn set_inc_symbol(&mut self, t: SymbolType) {
1561        self.internal.inc_symbol = t.into()
1562    }
1563
1564    pub fn set_dec_symbol(&mut self, t: SymbolType) {
1565        self.internal.dec_symbol = t.into()
1566    }
1567}
1568
1569// =====================================================================
1570
1571wrapper_type!(StyleChart, nk_style_chart);
1572
1573impl StyleChart {
1574    // ===== getters =====
1575
1576    pub fn background(&self) -> &StyleItem {
1577        unsafe { ::std::mem::transmute(&self.internal.background) }
1578    }
1579
1580    pub fn border_color(&self) -> &Color {
1581        &self.internal.border_color
1582    }
1583
1584    pub fn selected_color(&self) -> &Color {
1585        &self.internal.selected_color
1586    }
1587
1588    pub fn color(&self) -> &Color {
1589        &self.internal.color
1590    }
1591
1592    pub fn border(&self) -> f32 {
1593        self.internal.border
1594    }
1595
1596    pub fn rounding(&self) -> f32 {
1597        self.internal.rounding
1598    }
1599
1600    pub fn padding(&self) -> &Vec2 {
1601        &self.internal.padding
1602    }
1603
1604    // ===== setters =====
1605
1606    pub fn set_background(&mut self, i: StyleItem) {
1607        self.internal.background = i.internal;
1608    }
1609
1610    pub fn set_border_color(&mut self, c: Color) {
1611        self.internal.border_color = c
1612    }
1613
1614    pub fn set_selected_color(&mut self, c: Color) {
1615        self.internal.selected_color = c
1616    }
1617
1618    pub fn set_color(&mut self, c: Color) {
1619        self.internal.color = c
1620    }
1621
1622    pub fn set_border(&mut self, v: f32) {
1623        self.internal.border = v
1624    }
1625
1626    pub fn set_rounding(&mut self, v: f32) {
1627        self.internal.rounding = v
1628    }
1629
1630    pub fn set_padding(&mut self, v: Vec2) {
1631        self.internal.padding = v
1632    }
1633}
1634
1635// =====================================================================
1636
1637wrapper_type!(StyleEdit, nk_style_edit);
1638
1639impl StyleEdit {
1640    // ===== getters =====
1641
1642    pub fn normal(&self) -> &StyleItem {
1643        unsafe { ::std::mem::transmute(&self.internal.normal) }
1644    }
1645
1646    pub fn hover(&self) -> &StyleItem {
1647        unsafe { ::std::mem::transmute(&self.internal.hover) }
1648    }
1649
1650    pub fn active(&self) -> &StyleItem {
1651        unsafe { ::std::mem::transmute(&self.internal.active) }
1652    }
1653
1654    pub fn border_color(&self) -> &Color {
1655        &self.internal.border_color
1656    }
1657
1658    pub fn scrollbar(&self) -> &StyleScrollbar {
1659        unsafe { ::std::mem::transmute(&self.internal.scrollbar) }
1660    }
1661
1662    pub fn cursor_normal(&self) -> &Color {
1663        &self.internal.cursor_normal
1664    }
1665
1666    pub fn cursor_hover(&self) -> &Color {
1667        &self.internal.cursor_hover
1668    }
1669
1670    pub fn cursor_text_normal(&self) -> &Color {
1671        &self.internal.cursor_text_normal
1672    }
1673
1674    pub fn cursor_text_hover(&self) -> &Color {
1675        &self.internal.cursor_text_hover
1676    }
1677
1678    pub fn text_normal(&self) -> &Color {
1679        &self.internal.text_normal
1680    }
1681
1682    pub fn text_hover(&self) -> &Color {
1683        &self.internal.text_hover
1684    }
1685
1686    pub fn text_active(&self) -> &Color {
1687        &self.internal.text_active
1688    }
1689
1690    pub fn selected_normal(&self) -> &Color {
1691        &self.internal.selected_normal
1692    }
1693
1694    pub fn selected_hover(&self) -> &Color {
1695        &self.internal.selected_hover
1696    }
1697
1698    pub fn selected_text_normal(&self) -> &Color {
1699        &self.internal.selected_text_normal
1700    }
1701
1702    pub fn selected_text_hover(&self) -> &Color {
1703        &self.internal.selected_text_hover
1704    }
1705
1706    pub fn border(&self) -> f32 {
1707        self.internal.border
1708    }
1709
1710    pub fn rounding(&self) -> f32 {
1711        self.internal.rounding
1712    }
1713
1714    pub fn cursor_size(&self) -> f32 {
1715        self.internal.cursor_size
1716    }
1717
1718    pub fn scrollbar_size(&self) -> &Vec2 {
1719        &self.internal.scrollbar_size
1720    }
1721
1722    pub fn padding(&self) -> &Vec2 {
1723        &self.internal.padding
1724    }
1725
1726    pub fn row_padding(&self) -> f32 {
1727        self.internal.row_padding
1728    }
1729
1730    // ===== setters =====
1731
1732    pub fn set_normal(&mut self, i: StyleItem) {
1733        self.internal.normal = i.internal;
1734    }
1735
1736    pub fn set_hover(&mut self, i: StyleItem) {
1737        self.internal.hover = i.internal;
1738    }
1739
1740    pub fn set_active(&mut self, i: StyleItem) {
1741        self.internal.active = i.internal;
1742    }
1743
1744    pub fn set_border_color(&mut self, c: Color) {
1745        self.internal.border_color = c
1746    }
1747
1748    pub fn set_cursor_normal(&mut self, i: Color) {
1749        self.internal.cursor_normal = i;
1750    }
1751
1752    pub fn set_cursor_hover(&mut self, i: Color) {
1753        self.internal.cursor_hover = i;
1754    }
1755
1756    pub fn set_cursor_text_normal(&mut self, i: Color) {
1757        self.internal.cursor_text_normal = i;
1758    }
1759
1760    pub fn set_cursor_text_hover(&mut self, i: Color) {
1761        self.internal.cursor_text_hover = i;
1762    }
1763
1764    pub fn set_text_normal(&mut self, i: Color) {
1765        self.internal.text_normal = i;
1766    }
1767
1768    pub fn set_text_hover(&mut self, i: Color) {
1769        self.internal.text_hover = i;
1770    }
1771
1772    pub fn set_text_active(&mut self, i: Color) {
1773        self.internal.text_active = i;
1774    }
1775
1776    pub fn set_selected_normal(&mut self, i: Color) {
1777        self.internal.selected_normal = i;
1778    }
1779
1780    pub fn set_selected_hover(&mut self, i: Color) {
1781        self.internal.selected_hover = i;
1782    }
1783
1784    pub fn set_selected_text_normal(&mut self, i: Color) {
1785        self.internal.selected_text_normal = i;
1786    }
1787
1788    pub fn set_selected_text_hover(&mut self, i: Color) {
1789        self.internal.selected_text_hover = i;
1790    }
1791
1792    pub fn set_border(&mut self, v: f32) {
1793        self.internal.border = v
1794    }
1795
1796    pub fn set_rounding(&mut self, v: f32) {
1797        self.internal.rounding = v
1798    }
1799
1800    pub fn set_cursor_size(&mut self, v: f32) {
1801        self.internal.cursor_size = v
1802    }
1803
1804    pub fn set_scrollbar_size(&mut self, v: Vec2) {
1805        self.internal.scrollbar_size = v
1806    }
1807
1808    pub fn set_padding(&mut self, v: Vec2) {
1809        self.internal.padding = v
1810    }
1811
1812    pub fn set_row_padding(&mut self, v: f32) {
1813        self.internal.row_padding = v
1814    }
1815}
1816
1817// =====================================================================
1818
1819wrapper_type!(StyleProperty, nk_style_property);
1820
1821impl StyleProperty {
1822    // ===== getters =====
1823
1824    pub fn normal(&self) -> &StyleItem {
1825        unsafe { ::std::mem::transmute(&self.internal.normal) }
1826    }
1827
1828    pub fn hover(&self) -> &StyleItem {
1829        unsafe { ::std::mem::transmute(&self.internal.hover) }
1830    }
1831
1832    pub fn active(&self) -> &StyleItem {
1833        unsafe { ::std::mem::transmute(&self.internal.active) }
1834    }
1835
1836    pub fn border_color(&self) -> &Color {
1837        &self.internal.border_color
1838    }
1839
1840    pub fn label_normal(&self) -> &StyleItem {
1841        unsafe { ::std::mem::transmute(&self.internal.label_normal) }
1842    }
1843
1844    pub fn label_hover(&self) -> &StyleItem {
1845        unsafe { ::std::mem::transmute(&self.internal.label_hover) }
1846    }
1847
1848    pub fn label_active(&self) -> &StyleItem {
1849        unsafe { ::std::mem::transmute(&self.internal.label_active) }
1850    }
1851
1852    pub fn sym_left(&self) -> &SymbolType {
1853        (&self.internal.sym_left).into()
1854    }
1855
1856    pub fn sym_right(&self) -> &SymbolType {
1857        (&self.internal.sym_right).into()
1858    }
1859
1860    pub fn border(&self) -> f32 {
1861        self.internal.border
1862    }
1863
1864    pub fn rounding(&self) -> f32 {
1865        self.internal.rounding
1866    }
1867
1868    pub fn padding(&self) -> &Vec2 {
1869        &self.internal.padding
1870    }
1871
1872    pub fn edit(&self) -> &StyleEdit {
1873        unsafe { ::std::mem::transmute(&self.internal.edit) }
1874    }
1875
1876    pub fn inc_button(&self) -> &StyleButton {
1877        unsafe { ::std::mem::transmute(&self.internal.inc_button) }
1878    }
1879
1880    pub fn dec_button(&self) -> &StyleButton {
1881        unsafe { ::std::mem::transmute(&self.internal.dec_button) }
1882    }
1883
1884    // ===== setters =====
1885
1886    pub fn set_normal(&mut self, i: StyleItem) {
1887        self.internal.normal = i.internal;
1888    }
1889
1890    pub fn set_hover(&mut self, i: StyleItem) {
1891        self.internal.hover = i.internal;
1892    }
1893
1894    pub fn set_active(&mut self, i: StyleItem) {
1895        self.internal.active = i.internal;
1896    }
1897
1898    pub fn set_border_color(&mut self, c: Color) {
1899        self.internal.border_color = c
1900    }
1901
1902    pub fn set_label_normal(&mut self, c: Color) {
1903        self.internal.label_normal = c
1904    }
1905
1906    pub fn set_label_hover(&mut self, c: Color) {
1907        self.internal.label_hover = c
1908    }
1909
1910    pub fn set_label_active(&mut self, c: Color) {
1911        self.internal.label_active = c
1912    }
1913
1914    pub fn set_sym_left(&mut self, t: SymbolType) {
1915        self.internal.sym_left = t.into()
1916    }
1917
1918    pub fn set_sym_right(&mut self, t: SymbolType) {
1919        self.internal.sym_right = t.into()
1920    }
1921
1922    pub fn set_border(&mut self, v: f32) {
1923        self.internal.border = v
1924    }
1925
1926    pub fn set_rounding(&mut self, v: f32) {
1927        self.internal.rounding = v
1928    }
1929
1930    pub fn set_padding(&mut self, v: Vec2) {
1931        self.internal.padding = v
1932    }
1933
1934    pub fn set_inc_button(&mut self, s: StyleButton) {
1935        self.internal.inc_button = s.internal
1936    }
1937
1938    pub fn set_dec_button(&mut self, s: StyleButton) {
1939        self.internal.dec_button = s.internal
1940    }
1941}
1942
1943// =====================================================================
1944
1945wrapper_type!(StyleProgress, nk_style_progress);
1946
1947impl StyleProgress {
1948    // ===== getters =====
1949
1950    pub fn normal(&self) -> &StyleItem {
1951        unsafe { ::std::mem::transmute(&self.internal.normal) }
1952    }
1953
1954    pub fn hover(&self) -> &StyleItem {
1955        unsafe { ::std::mem::transmute(&self.internal.hover) }
1956    }
1957
1958    pub fn active(&self) -> &StyleItem {
1959        unsafe { ::std::mem::transmute(&self.internal.active) }
1960    }
1961
1962    pub fn border_color(&self) -> &Color {
1963        &self.internal.border_color
1964    }
1965
1966    pub fn cursor_normal(&self) -> &StyleItem {
1967        unsafe { ::std::mem::transmute(&self.internal.cursor_normal) }
1968    }
1969
1970    pub fn cursor_hover(&self) -> &StyleItem {
1971        unsafe { ::std::mem::transmute(&self.internal.cursor_hover) }
1972    }
1973
1974    pub fn cursor_active(&self) -> &StyleItem {
1975        unsafe { ::std::mem::transmute(&self.internal.cursor_active) }
1976    }
1977
1978    pub fn cursor_border_color(&self) -> &Color {
1979        &self.internal.cursor_border_color
1980    }
1981
1982    pub fn border(&self) -> f32 {
1983        self.internal.border
1984    }
1985
1986    pub fn rounding(&self) -> f32 {
1987        self.internal.rounding
1988    }
1989
1990    pub fn cursor_border(&self) -> f32 {
1991        self.internal.cursor_border
1992    }
1993
1994    pub fn cursor_rounding(&self) -> f32 {
1995        self.internal.cursor_rounding
1996    }
1997
1998    pub fn padding(&self) -> &Vec2 {
1999        &self.internal.padding
2000    }
2001
2002    // ===== setters =====
2003
2004    pub fn set_normal(&mut self, i: StyleItem) {
2005        self.internal.normal = i.internal;
2006    }
2007
2008    pub fn set_hover(&mut self, i: StyleItem) {
2009        self.internal.hover = i.internal;
2010    }
2011
2012    pub fn set_active(&mut self, i: StyleItem) {
2013        self.internal.active = i.internal;
2014    }
2015
2016    pub fn set_border_color(&mut self, c: Color) {
2017        self.internal.border_color = c
2018    }
2019
2020    pub fn set_cursor_normal(&mut self, i: StyleItem) {
2021        self.internal.cursor_normal = i.internal;
2022    }
2023
2024    pub fn set_cursor_hover(&mut self, i: StyleItem) {
2025        self.internal.cursor_hover = i.internal;
2026    }
2027
2028    pub fn set_cursor_active(&mut self, i: StyleItem) {
2029        self.internal.cursor_active = i.internal;
2030    }
2031
2032    pub fn set_cursor_border_color(&mut self, c: Color) {
2033        self.internal.cursor_border_color = c
2034    }
2035
2036    pub fn set_border(&mut self, v: f32) {
2037        self.internal.border = v
2038    }
2039
2040    pub fn set_rounding(&mut self, v: f32) {
2041        self.internal.rounding = v
2042    }
2043
2044    pub fn set_cursor_border(&mut self, v: f32) {
2045        self.internal.cursor_border = v
2046    }
2047
2048    pub fn set_cursor_rounding(&mut self, v: f32) {
2049        self.internal.cursor_rounding = v
2050    }
2051
2052    pub fn set_padding(&mut self, v: Vec2) {
2053        self.internal.padding = v
2054    }
2055}
2056
2057// =====================================================================
2058
2059wrapper_type!(StyleSlider, nk_style_slider);
2060
2061impl StyleSlider {
2062    // ===== getters =====
2063
2064    pub fn normal(&self) -> &StyleItem {
2065        unsafe { ::std::mem::transmute(&self.internal.normal) }
2066    }
2067
2068    pub fn hover(&self) -> &StyleItem {
2069        unsafe { ::std::mem::transmute(&self.internal.hover) }
2070    }
2071
2072    pub fn active(&self) -> &StyleItem {
2073        unsafe { ::std::mem::transmute(&self.internal.active) }
2074    }
2075
2076    pub fn border_color(&self) -> &Color {
2077        &self.internal.border_color
2078    }
2079
2080    pub fn bar_normal(&self) -> &Color {
2081        &self.internal.bar_normal
2082    }
2083
2084    pub fn bar_hover(&self) -> &Color {
2085        &self.internal.bar_hover
2086    }
2087
2088    pub fn bar_active(&self) -> &Color {
2089        &self.internal.bar_active
2090    }
2091
2092    pub fn bar_filled(&self) -> &Color {
2093        &self.internal.bar_filled
2094    }
2095
2096    pub fn cursor_normal(&self) -> &StyleItem {
2097        unsafe { ::std::mem::transmute(&self.internal.cursor_normal) }
2098    }
2099
2100    pub fn cursor_hover(&self) -> &StyleItem {
2101        unsafe { ::std::mem::transmute(&self.internal.cursor_hover) }
2102    }
2103
2104    pub fn cursor_active(&self) -> &StyleItem {
2105        unsafe { ::std::mem::transmute(&self.internal.cursor_active) }
2106    }
2107
2108    pub fn border(&self) -> f32 {
2109        self.internal.border
2110    }
2111
2112    pub fn rounding(&self) -> f32 {
2113        self.internal.rounding
2114    }
2115
2116    pub fn bar_height(&self) -> f32 {
2117        self.internal.bar_height
2118    }
2119
2120    pub fn spacing(&self) -> &Vec2 {
2121        &self.internal.spacing
2122    }
2123
2124    pub fn padding(&self) -> &Vec2 {
2125        &self.internal.padding
2126    }
2127
2128    pub fn cursor_size(&self) -> &Vec2 {
2129        &self.internal.cursor_size
2130    }
2131
2132    pub fn show_buttons(&self) -> bool {
2133        self.internal.show_buttons > 0
2134    }
2135
2136    pub fn inc_button(&self) -> &StyleButton {
2137        unsafe { ::std::mem::transmute(&self.internal.inc_button) }
2138    }
2139
2140    pub fn dec_button(&self) -> &StyleButton {
2141        unsafe { ::std::mem::transmute(&self.internal.dec_button) }
2142    }
2143
2144    pub fn inc_symbol(&self) -> &SymbolType {
2145        (&self.internal.inc_symbol).into()
2146    }
2147
2148    pub fn dec_symbol(&self) -> &SymbolType {
2149        (&self.internal.dec_symbol).into()
2150    }
2151
2152    // ===== setters =====
2153
2154    pub fn set_normal(&mut self, i: StyleItem) {
2155        self.internal.normal = i.internal;
2156    }
2157
2158    pub fn set_hover(&mut self, i: StyleItem) {
2159        self.internal.hover = i.internal;
2160    }
2161
2162    pub fn set_active(&mut self, i: StyleItem) {
2163        self.internal.active = i.internal;
2164    }
2165
2166    pub fn set_border_color(&mut self, c: Color) {
2167        self.internal.border_color = c
2168    }
2169
2170    pub fn set_bar_normal(&mut self, c: Color) {
2171        self.internal.bar_normal = c
2172    }
2173
2174    pub fn set_bar_hover(&mut self, c: Color) {
2175        self.internal.bar_hover = c
2176    }
2177
2178    pub fn set_bar_active(&mut self, c: Color) {
2179        self.internal.bar_active = c
2180    }
2181
2182    pub fn set_bar_filled(&mut self, c: Color) {
2183        self.internal.bar_filled = c
2184    }
2185
2186    pub fn set_cursor_normal(&mut self, i: StyleItem) {
2187        self.internal.cursor_normal = i.internal;
2188    }
2189
2190    pub fn set_cursor_hover(&mut self, i: StyleItem) {
2191        self.internal.cursor_hover = i.internal;
2192    }
2193
2194    pub fn set_cursor_active(&mut self, i: StyleItem) {
2195        self.internal.cursor_active = i.internal;
2196    }
2197
2198    pub fn set_border(&mut self, v: f32) {
2199        self.internal.border = v
2200    }
2201
2202    pub fn set_rounding(&mut self, v: f32) {
2203        self.internal.rounding = v
2204    }
2205
2206    pub fn set_bar_height(&mut self, v: f32) {
2207        self.internal.bar_height = v
2208    }
2209
2210    pub fn set_padding(&mut self, v: Vec2) {
2211        self.internal.padding = v
2212    }
2213
2214    pub fn set_spacing(&mut self, v: Vec2) {
2215        self.internal.spacing = v
2216    }
2217
2218    pub fn set_cursor_size(&mut self, v: Vec2) {
2219        self.internal.cursor_size = v
2220    }
2221
2222    pub fn set_show_buttons(&mut self, show: bool) {
2223        self.internal.show_buttons = if show { 1 } else { 0 }
2224    }
2225
2226    pub fn set_inc_button(&mut self, s: StyleButton) {
2227        self.internal.inc_button = s.internal
2228    }
2229
2230    pub fn set_dec_button(&mut self, s: StyleButton) {
2231        self.internal.dec_button = s.internal
2232    }
2233
2234    pub fn set_inc_symbol(&mut self, t: SymbolType) {
2235        self.internal.inc_symbol = t.into()
2236    }
2237
2238    pub fn set_dec_symbol(&mut self, t: SymbolType) {
2239        self.internal.dec_symbol = t.into()
2240    }
2241}
2242
2243// =====================================================================
2244
2245wrapper_type!(StyleSelectable, nk_style_selectable);
2246
2247impl StyleSelectable {
2248    // ===== getters =====
2249
2250    pub fn normal(&self) -> &StyleItem {
2251        unsafe { ::std::mem::transmute(&self.internal.normal) }
2252    }
2253
2254    pub fn hover(&self) -> &StyleItem {
2255        unsafe { ::std::mem::transmute(&self.internal.hover) }
2256    }
2257
2258    pub fn pressed(&self) -> &StyleItem {
2259        unsafe { ::std::mem::transmute(&self.internal.pressed) }
2260    }
2261
2262    pub fn normal_active(&self) -> &StyleItem {
2263        unsafe { ::std::mem::transmute(&self.internal.normal_active) }
2264    }
2265
2266    pub fn hover_active(&self) -> &StyleItem {
2267        unsafe { ::std::mem::transmute(&self.internal.hover_active) }
2268    }
2269
2270    pub fn pressed_active(&self) -> &StyleItem {
2271        unsafe { ::std::mem::transmute(&self.internal.pressed_active) }
2272    }
2273
2274    pub fn text_normal(&self) -> &Color {
2275        &self.internal.text_normal
2276    }
2277
2278    pub fn text_hover(&self) -> &Color {
2279        &self.internal.text_hover
2280    }
2281
2282    pub fn text_pressed(&self) -> &Color {
2283        &self.internal.text_pressed
2284    }
2285
2286    pub fn text_normal_active(&self) -> &Color {
2287        &self.internal.text_normal_active
2288    }
2289
2290    pub fn text_hover_active(&self) -> &Color {
2291        &self.internal.text_hover_active
2292    }
2293
2294    pub fn text_pressed_active(&self) -> &Color {
2295        &self.internal.text_pressed_active
2296    }
2297
2298    pub fn text_background(&self) -> &Color {
2299        &self.internal.text_background
2300    }
2301
2302    pub fn text_alignment(&self) -> u32 {
2303        self.internal.text_alignment
2304    }
2305
2306    pub fn rounding(&self) -> f32 {
2307        self.internal.rounding
2308    }
2309
2310    pub fn padding(&self) -> &Vec2 {
2311        &self.internal.padding
2312    }
2313
2314    pub fn touch_padding(&self) -> &Vec2 {
2315        &self.internal.touch_padding
2316    }
2317
2318    pub fn image_padding(&self) -> &Vec2 {
2319        &self.internal.image_padding
2320    }
2321
2322    // ===== setters =====
2323
2324    pub fn set_normal(&mut self, i: StyleItem) {
2325        self.internal.normal = i.internal;
2326    }
2327
2328    pub fn set_hover(&mut self, i: StyleItem) {
2329        self.internal.hover = i.internal;
2330    }
2331
2332    pub fn set_pressed(&mut self, i: StyleItem) {
2333        self.internal.pressed = i.internal;
2334    }
2335
2336    pub fn set_normal_active(&mut self, i: StyleItem) {
2337        self.internal.normal_active = i.internal;
2338    }
2339
2340    pub fn set_hover_active(&mut self, i: StyleItem) {
2341        self.internal.hover_active = i.internal;
2342    }
2343
2344    pub fn set_pressed_active(&mut self, i: StyleItem) {
2345        self.internal.pressed_active = i.internal;
2346    }
2347
2348    pub fn set_text_normal(&mut self, c: Color) {
2349        self.internal.text_normal = c
2350    }
2351
2352    pub fn set_text_hover(&mut self, c: Color) {
2353        self.internal.text_hover = c
2354    }
2355
2356    pub fn set_text_pressed(&mut self, c: Color) {
2357        self.internal.text_pressed = c
2358    }
2359
2360    pub fn set_text_normal_active(&mut self, c: Color) {
2361        self.internal.text_normal_active = c
2362    }
2363
2364    pub fn set_text_hover_active(&mut self, c: Color) {
2365        self.internal.text_hover_active = c
2366    }
2367
2368    pub fn set_text_pressed_active(&mut self, c: Color) {
2369        self.internal.text_pressed_active = c
2370    }
2371
2372    pub fn set_text_background(&mut self, c: Color) {
2373        self.internal.text_background = c
2374    }
2375
2376    pub fn set_text_alignment(&mut self, v: u32) {
2377        self.internal.text_alignment = v
2378    }
2379
2380    pub fn set_rounding(&mut self, v: f32) {
2381        self.internal.rounding = v
2382    }
2383
2384    pub fn set_padding(&mut self, v: Vec2) {
2385        self.internal.padding = v
2386    }
2387
2388    pub fn set_touch_padding(&mut self, v: Vec2) {
2389        self.internal.touch_padding = v
2390    }
2391
2392    pub fn set_image_padding(&mut self, v: Vec2) {
2393        self.internal.image_padding = v
2394    }
2395}
2396
2397// =====================================================================
2398
2399wrapper_type!(StyleButton, nk_style_button);
2400
2401impl StyleButton {
2402    // ===== getters =====
2403
2404    pub fn normal(&self) -> &StyleItem {
2405        unsafe { ::std::mem::transmute(&self.internal.normal) }
2406    }
2407
2408    pub fn hover(&self) -> &StyleItem {
2409        unsafe { ::std::mem::transmute(&self.internal.hover) }
2410    }
2411
2412    pub fn active(&self) -> &StyleItem {
2413        unsafe { ::std::mem::transmute(&self.internal.active) }
2414    }
2415
2416    pub fn border_color(&self) -> &Color {
2417        &self.internal.border_color
2418    }
2419
2420    pub fn text_background(&self) -> &Color {
2421        &self.internal.text_background
2422    }
2423
2424    pub fn text_normal(&self) -> &Color {
2425        &self.internal.text_normal
2426    }
2427
2428    pub fn text_hover(&self) -> &Color {
2429        &self.internal.text_hover
2430    }
2431
2432    pub fn text_active(&self) -> &Color {
2433        &self.internal.text_active
2434    }
2435
2436    pub fn text_alignment(&self) -> u32 {
2437        self.internal.text_alignment
2438    }
2439
2440    pub fn border(&self) -> f32 {
2441        self.internal.border
2442    }
2443
2444    pub fn rounding(&self) -> f32 {
2445        self.internal.rounding
2446    }
2447
2448    pub fn padding(&self) -> &Vec2 {
2449        &self.internal.padding
2450    }
2451
2452    pub fn touch_padding(&self) -> &Vec2 {
2453        &self.internal.touch_padding
2454    }
2455
2456    pub fn image_padding(&self) -> &Vec2 {
2457        &self.internal.image_padding
2458    }
2459
2460    // ===== setters =====
2461
2462    pub fn set_normal(&mut self, i: StyleItem) {
2463        self.internal.normal = i.internal;
2464    }
2465
2466    pub fn set_hover(&mut self, i: StyleItem) {
2467        self.internal.hover = i.internal;
2468    }
2469
2470    pub fn set_active(&mut self, i: StyleItem) {
2471        self.internal.active = i.internal;
2472    }
2473
2474    pub fn set_border_color(&mut self, c: Color) {
2475        self.internal.border_color = c
2476    }
2477
2478    pub fn set_text_background(&mut self, c: Color) {
2479        self.internal.text_background = c
2480    }
2481
2482    pub fn set_text_normal(&mut self, c: Color) {
2483        self.internal.text_normal = c
2484    }
2485
2486    pub fn set_text_hover(&mut self, c: Color) {
2487        self.internal.text_hover = c
2488    }
2489
2490    pub fn set_text_active(&mut self, c: Color) {
2491        self.internal.text_active = c
2492    }
2493
2494    pub fn set_text_alignment(&mut self, c: u32) {
2495        self.internal.text_alignment = c
2496    }
2497
2498    pub fn set_border(&mut self, c: f32) {
2499        self.internal.border = c
2500    }
2501
2502    pub fn set_rounding(&mut self, v: f32) {
2503        self.internal.rounding = v
2504    }
2505
2506    pub fn set_padding(&mut self, v: Vec2) {
2507        self.internal.padding = v
2508    }
2509
2510    pub fn set_touch_padding(&mut self, v: Vec2) {
2511        self.internal.touch_padding = v
2512    }
2513
2514    pub fn set_image_padding(&mut self, v: Vec2) {
2515        self.internal.image_padding = v
2516    }
2517}
2518
2519// =====================================================================
2520
2521wrapper_type!(StyleToggle, nk_style_toggle);
2522
2523impl StyleToggle {
2524    // ===== getters =====
2525
2526    pub fn normal(&self) -> &StyleItem {
2527        unsafe { ::std::mem::transmute(&self.internal.normal) }
2528    }
2529
2530    pub fn hover(&self) -> &StyleItem {
2531        unsafe { ::std::mem::transmute(&self.internal.hover) }
2532    }
2533
2534    pub fn active(&self) -> &StyleItem {
2535        unsafe { ::std::mem::transmute(&self.internal.active) }
2536    }
2537
2538    pub fn border_color(&self) -> &Color {
2539        &self.internal.border_color
2540    }
2541
2542    pub fn cursor_normal(&self) -> &StyleItem {
2543        unsafe { ::std::mem::transmute(&self.internal.cursor_normal) }
2544    }
2545
2546    pub fn cursor_hover(&self) -> &StyleItem {
2547        unsafe { ::std::mem::transmute(&self.internal.cursor_hover) }
2548    }
2549
2550    pub fn text_normal(&self) -> &Color {
2551        &self.internal.text_normal
2552    }
2553
2554    pub fn text_hover(&self) -> &Color {
2555        &self.internal.text_hover
2556    }
2557
2558    pub fn text_active(&self) -> &Color {
2559        &self.internal.text_active
2560    }
2561
2562    pub fn text_background(&self) -> &Color {
2563        &self.internal.text_background
2564    }
2565
2566    pub fn text_alignment(&self) -> u32 {
2567        self.internal.text_alignment
2568    }
2569
2570    pub fn spacing(&self) -> f32 {
2571        self.internal.spacing
2572    }
2573
2574    pub fn border(&self) -> f32 {
2575        self.internal.border
2576    }
2577
2578    pub fn padding(&self) -> &Vec2 {
2579        &self.internal.padding
2580    }
2581
2582    pub fn touch_padding(&self) -> &Vec2 {
2583        &self.internal.touch_padding
2584    }
2585
2586    // ===== setters =====
2587
2588    pub fn set_normal(&mut self, i: StyleItem) {
2589        self.internal.normal = i.internal;
2590    }
2591
2592    pub fn set_hover(&mut self, i: StyleItem) {
2593        self.internal.hover = i.internal;
2594    }
2595
2596    pub fn set_active(&mut self, i: StyleItem) {
2597        self.internal.active = i.internal;
2598    }
2599
2600    pub fn set_border_color(&mut self, c: Color) {
2601        self.internal.border_color = c
2602    }
2603
2604    pub fn set_cursor_normal(&mut self, i: StyleItem) {
2605        self.internal.cursor_normal = i.internal;
2606    }
2607
2608    pub fn set_cursor_hover(&mut self, i: StyleItem) {
2609        self.internal.cursor_hover = i.internal;
2610    }
2611
2612    pub fn set_text_background(&mut self, c: Color) {
2613        self.internal.text_background = c
2614    }
2615
2616    pub fn set_text_normal(&mut self, c: Color) {
2617        self.internal.text_normal = c
2618    }
2619
2620    pub fn set_text_hover(&mut self, c: Color) {
2621        self.internal.text_hover = c
2622    }
2623
2624    pub fn set_text_active(&mut self, c: Color) {
2625        self.internal.text_active = c
2626    }
2627
2628    pub fn set_text_alignment(&mut self, c: u32) {
2629        self.internal.text_alignment = c
2630    }
2631
2632    pub fn set_spacing(&mut self, v: f32) {
2633        self.internal.spacing = v
2634    }
2635
2636    pub fn set_border(&mut self, v: f32) {
2637        self.internal.border = v
2638    }
2639
2640    pub fn set_padding(&mut self, v: Vec2) {
2641        self.internal.padding = v
2642    }
2643
2644    pub fn set_touch_padding(&mut self, v: Vec2) {
2645        self.internal.touch_padding = v
2646    }
2647}
2648
2649// =====================================================================
2650
2651wrapper_type!(StyleWindowHeader, nk_style_window_header);
2652
2653impl StyleWindowHeader {
2654    // ===== getters =====
2655
2656    pub fn normal(&self) -> &StyleItem {
2657        unsafe { ::std::mem::transmute(&self.internal.normal) }
2658    }
2659
2660    pub fn hover(&self) -> &StyleItem {
2661        unsafe { ::std::mem::transmute(&self.internal.hover) }
2662    }
2663
2664    pub fn active(&self) -> &StyleItem {
2665        unsafe { ::std::mem::transmute(&self.internal.active) }
2666    }
2667
2668    pub fn close_button(&self) -> &StyleButton {
2669        unsafe { ::std::mem::transmute(&self.internal.close_button) }
2670    }
2671
2672    pub fn minimize_button(&self) -> &StyleButton {
2673        unsafe { ::std::mem::transmute(&self.internal.minimize_button) }
2674    }
2675
2676    pub fn close_symbol(&self) -> &SymbolType {
2677        (&self.internal.close_symbol).into()
2678    }
2679
2680    pub fn minimize_symbol(&self) -> &SymbolType {
2681        (&self.internal.minimize_symbol).into()
2682    }
2683
2684    pub fn maximize_symbol(&self) -> &SymbolType {
2685        (&self.internal.maximize_symbol).into()
2686    }
2687
2688    pub fn label_normal(&self) -> &Color {
2689        &self.internal.label_normal
2690    }
2691
2692    pub fn label_hover(&self) -> &Color {
2693        &self.internal.label_hover
2694    }
2695
2696    pub fn label_active(&self) -> &Color {
2697        &self.internal.label_active
2698    }
2699
2700    pub fn align(&self) -> &StyleHeaderAlign {
2701        &self.internal.align
2702    }
2703
2704    pub fn padding(&self) -> &Vec2 {
2705        &self.internal.padding
2706    }
2707
2708    pub fn label_padding(&self) -> &Vec2 {
2709        &self.internal.label_padding
2710    }
2711
2712    pub fn spacing(&self) -> &Vec2 {
2713        &self.internal.spacing
2714    }
2715
2716    // ===== setters =====
2717
2718    pub fn set_normal(&mut self, i: StyleItem) {
2719        self.internal.normal = i.internal;
2720    }
2721
2722    pub fn set_hover(&mut self, i: StyleItem) {
2723        self.internal.hover = i.internal;
2724    }
2725
2726    pub fn set_active(&mut self, i: StyleItem) {
2727        self.internal.active = i.internal;
2728    }
2729
2730    pub fn set_close_symbol(&mut self, t: SymbolType) {
2731        self.internal.close_symbol = t.into()
2732    }
2733
2734    pub fn set_minimize_symbol(&mut self, t: SymbolType) {
2735        self.internal.minimize_symbol = t.into()
2736    }
2737
2738    pub fn set_maximize_symbol(&mut self, t: SymbolType) {
2739        self.internal.maximize_symbol = t.into()
2740    }
2741
2742    pub fn set_label_normal(&mut self, c: Color) {
2743        self.internal.label_normal = c
2744    }
2745
2746    pub fn set_label_hover(&mut self, c: Color) {
2747        self.internal.label_hover = c
2748    }
2749
2750    pub fn set_label_active(&mut self, c: Color) {
2751        self.internal.label_active = c
2752    }
2753
2754    pub fn set_align(&mut self, c: StyleHeaderAlign) {
2755        self.internal.align = c
2756    }
2757
2758    pub fn set_padding(&mut self, v: Vec2) {
2759        self.internal.padding = v
2760    }
2761
2762    pub fn set_label_padding(&mut self, v: Vec2) {
2763        self.internal.label_padding = v
2764    }
2765
2766    pub fn set_spacing(&mut self, v: Vec2) {
2767        self.internal.spacing = v
2768    }
2769}
2770
2771// =====================================================================
2772
2773wrapper_type!(StyleWindow, nk_style_window);
2774
2775impl StyleWindow {
2776    // ===== getters =====
2777
2778    pub fn header(&self) -> &StyleWindowHeader {
2779        unsafe { ::std::mem::transmute(&self.internal.header) }
2780    }
2781
2782    pub fn fixed_background(&self) -> StyleItem {
2783        StyleItem { internal: self.internal.fixed_background }
2784    }
2785
2786    pub fn background(&self) -> &Color {
2787        &self.internal.background
2788    }
2789
2790    pub fn border_color(&self) -> &Color {
2791        &self.internal.border_color
2792    }
2793
2794    pub fn popup_border_color(&self) -> &Color {
2795        &self.internal.popup_border_color
2796    }
2797
2798    pub fn combo_border_color(&self) -> &Color {
2799        &self.internal.combo_border_color
2800    }
2801
2802    pub fn contextual_border_color(&self) -> &Color {
2803        &self.internal.contextual_border_color
2804    }
2805
2806    pub fn menu_border_color(&self) -> &Color {
2807        &self.internal.menu_border_color
2808    }
2809
2810    pub fn group_border_color(&self) -> &Color {
2811        &self.internal.group_border_color
2812    }
2813
2814    pub fn tooltip_border_color(&self) -> &Color {
2815        &self.internal.tooltip_border_color
2816    }
2817
2818    pub fn scaler(&self) -> &StyleItem {
2819        unsafe { ::std::mem::transmute(&self.internal.scaler) }
2820    }
2821
2822    pub fn border(&self) -> f32 {
2823        self.internal.border
2824    }
2825
2826    pub fn combo_border(&self) -> f32 {
2827        self.internal.combo_border
2828    }
2829
2830    pub fn contextual_border(&self) -> f32 {
2831        self.internal.contextual_border
2832    }
2833
2834    pub fn menu_border(&self) -> f32 {
2835        self.internal.menu_border
2836    }
2837
2838    pub fn group_border(&self) -> f32 {
2839        self.internal.group_border
2840    }
2841
2842    pub fn tooltip_border(&self) -> f32 {
2843        self.internal.tooltip_border
2844    }
2845
2846    pub fn popup_border(&self) -> f32 {
2847        self.internal.popup_border
2848    }
2849
2850    pub fn rounding(&self) -> f32 {
2851        self.internal.rounding
2852    }
2853
2854    pub fn spacing(&self) -> &Vec2 {
2855        &self.internal.spacing
2856    }
2857
2858    pub fn scrollbar_size(&self) -> &Vec2 {
2859        &self.internal.scrollbar_size
2860    }
2861
2862    pub fn min_size(&self) -> &Vec2 {
2863        &self.internal.min_size
2864    }
2865
2866    pub fn padding(&self) -> &Vec2 {
2867        &self.internal.padding
2868    }
2869
2870    pub fn group_padding(&self) -> &Vec2 {
2871        &self.internal.group_padding
2872    }
2873
2874    pub fn popup_padding(&self) -> &Vec2 {
2875        &self.internal.popup_padding
2876    }
2877
2878    pub fn combo_padding(&self) -> &Vec2 {
2879        &self.internal.combo_padding
2880    }
2881
2882    pub fn contextual_padding(&self) -> &Vec2 {
2883        &self.internal.contextual_padding
2884    }
2885
2886    pub fn menu_padding(&self) -> &Vec2 {
2887        &self.internal.menu_padding
2888    }
2889
2890    pub fn tooltip_padding(&self) -> &Vec2 {
2891        &self.internal.tooltip_padding
2892    }
2893
2894    // ===== setters =====
2895
2896    pub fn set_fixed_background(&mut self, item: StyleItem) {
2897        self.internal.fixed_background = item.internal;
2898    }
2899
2900    pub fn set_background(&mut self, color: Color) {
2901        self.internal.background = color;
2902    }
2903
2904    pub fn set_border_color(&mut self, color: Color) {
2905        self.internal.border_color = color;
2906    }
2907
2908    pub fn set_popup_border_color(&mut self, color: Color) {
2909        self.internal.popup_border_color = color;
2910    }
2911
2912    pub fn set_combo_border_color(&mut self, color: Color) {
2913        self.internal.combo_border_color = color;
2914    }
2915
2916    pub fn set_contextual_border_color(&mut self, color: Color) {
2917        self.internal.contextual_border_color = color;
2918    }
2919
2920    pub fn set_menu_border_color(&mut self, color: Color) {
2921        self.internal.menu_border_color = color;
2922    }
2923
2924    pub fn set_group_border_color(&mut self, color: Color) {
2925        self.internal.group_border_color = color;
2926    }
2927
2928    pub fn set_tooltip_border_color(&mut self, color: Color) {
2929        self.internal.tooltip_border_color = color;
2930    }
2931
2932    pub fn set_scaler(&mut self, i: StyleItem) {
2933        self.internal.scaler = i.internal;
2934    }
2935
2936    pub fn set_combo_border(&mut self, v: f32) {
2937        self.internal.combo_border = v
2938    }
2939
2940    pub fn set_border(&mut self, v: f32) {
2941        self.internal.border = v
2942    }
2943
2944    pub fn set_contextual_border(&mut self, v: f32) {
2945        self.internal.contextual_border = v
2946    }
2947
2948    pub fn set_menu_border(&mut self, v: f32) {
2949        self.internal.menu_border = v
2950    }
2951
2952    pub fn set_group_border(&mut self, v: f32) {
2953        self.internal.group_border = v
2954    }
2955
2956    pub fn set_tooltip_border(&mut self, v: f32) {
2957        self.internal.tooltip_border = v
2958    }
2959
2960    pub fn set_popup_border(&mut self, v: f32) {
2961        self.internal.popup_border = v
2962    }
2963
2964    pub fn set_rounding(&mut self, v: f32) {
2965        self.internal.rounding = v
2966    }
2967
2968    pub fn set_spacing(&mut self, spacing: Vec2) {
2969        self.internal.spacing = spacing;
2970    }
2971
2972    pub fn set_scrollbar_size(&mut self, s: Vec2) {
2973        self.internal.scrollbar_size = s;
2974    }
2975
2976    pub fn set_min_size(&mut self, s: Vec2) {
2977        self.internal.min_size = s;
2978    }
2979
2980    pub fn set_padding(&mut self, padding: Vec2) {
2981        self.internal.padding = padding;
2982    }
2983
2984    pub fn set_group_padding(&mut self, padding: Vec2) {
2985        self.internal.group_padding = padding;
2986    }
2987
2988    pub fn set_popup_padding(&mut self, padding: Vec2) {
2989        self.internal.popup_padding = padding;
2990    }
2991
2992    pub fn set_combo_padding(&mut self, padding: Vec2) {
2993        self.internal.combo_padding = padding;
2994    }
2995
2996    pub fn set_contextual_padding(&mut self, padding: Vec2) {
2997        self.internal.contextual_padding = padding;
2998    }
2999
3000    pub fn set_menu_padding(&mut self, padding: Vec2) {
3001        self.internal.menu_padding = padding;
3002    }
3003
3004    pub fn set_tooltip_padding(&mut self, padding: Vec2) {
3005        self.internal.tooltip_padding = padding;
3006    }
3007}
3008
3009// =====================================================================
3010
3011wrapper_type!(DrawList, nk_draw_list);
3012
3013impl DrawList {
3014    pub fn init(&mut self) {
3015        unsafe {
3016            nk_draw_list_init(&mut self.internal);
3017        }
3018    }
3019
3020    pub fn setup(&mut self, config: &ConvertConfig, cmds: &mut Buffer, vertices: &mut Buffer, elements: &mut Buffer, line_aa: AntiAliasing, shape_aa: AntiAliasing) {
3021        unsafe {
3022            nk_draw_list_setup(
3023                &mut self.internal,
3024                &config.internal as *const nk_convert_config,
3025                &mut cmds.internal as *mut nk_buffer,
3026                &mut vertices.internal as *mut nk_buffer,
3027                &mut elements.internal as *mut nk_buffer,
3028                line_aa.into(),
3029                shape_aa.into(),
3030            )
3031        }
3032    }
3033
3034    pub fn begin(&self, buf: &Buffer) -> &DrawCommand {
3035        unsafe { ::std::mem::transmute(nk__draw_list_begin(&self.internal, &buf.internal)) }
3036    }
3037
3038    pub fn next(&self, buf: &Buffer, prev: &DrawCommand) -> &DrawCommand {
3039        unsafe { ::std::mem::transmute(nk__draw_list_next(&prev.internal, &buf.internal, &self.internal)) }
3040    }
3041
3042    pub fn path_clear(&mut self) {
3043        unsafe {
3044            nk_draw_list_path_clear(&mut self.internal);
3045        }
3046    }
3047
3048    pub fn path_line_to(&mut self, pos: Vec2) {
3049        unsafe {
3050            nk_draw_list_path_line_to(&mut self.internal, pos);
3051        }
3052    }
3053
3054    pub fn path_arc_to_fast(&mut self, center: Vec2, radius: f32, a_min: i32, a_max: i32) {
3055        unsafe {
3056            nk_draw_list_path_arc_to_fast(&mut self.internal, center, radius, a_min, a_max);
3057        }
3058    }
3059
3060    pub fn path_arc_to(&mut self, center: Vec2, radius: f32, a_min: f32, a_max: f32, segments: u32) {
3061        unsafe {
3062            nk_draw_list_path_arc_to(&mut self.internal, center, radius, a_min, a_max, segments);
3063        }
3064    }
3065
3066    pub fn path_rect_to(&mut self, a: Vec2, b: Vec2, rounding: f32) {
3067        unsafe {
3068            nk_draw_list_path_rect_to(&mut self.internal, a, b, rounding);
3069        }
3070    }
3071
3072    pub fn path_curve_to(&mut self, p2: Vec2, p3: Vec2, p4: Vec2, num_segments: u32) {
3073        unsafe { nk_draw_list_path_curve_to(&mut self.internal, p2, p3, p4, num_segments) }
3074    }
3075
3076    pub fn path_fill(&mut self, col: Color) {
3077        unsafe {
3078            nk_draw_list_path_fill(&mut self.internal, col);
3079        }
3080    }
3081
3082    pub fn path_stroke(&mut self, arg2: Color, closed: DrawListStroke, thickness: f32) {
3083        unsafe {
3084            nk_draw_list_path_stroke(&mut self.internal, arg2, closed, thickness);
3085        }
3086    }
3087
3088    pub fn stroke_line(&mut self, a: Vec2, b: Vec2, arg2: Color, thickness: f32) {
3089        unsafe {
3090            nk_draw_list_stroke_line(&mut self.internal, a, b, arg2, thickness);
3091        }
3092    }
3093
3094    pub fn stroke_rect(&mut self, rect: Rect, arg2: Color, rounding: f32, thickness: f32) {
3095        unsafe {
3096            nk_draw_list_stroke_rect(&mut self.internal, rect, arg2, rounding, thickness);
3097        }
3098    }
3099
3100    pub fn stroke_triangle(&mut self, a: Vec2, b: Vec2, c: Vec2, arg2: Color, thickness: f32) {
3101        unsafe {
3102            nk_draw_list_stroke_triangle(&mut self.internal, a, b, c, arg2, thickness);
3103        }
3104    }
3105
3106    pub fn stroke_circle(&mut self, center: Vec2, radius: f32, arg2: Color, segs: u32, thickness: f32) {
3107        unsafe {
3108            nk_draw_list_stroke_circle(&mut self.internal, center, radius, arg2, segs, thickness);
3109        }
3110    }
3111
3112    pub fn stroke_curve(&mut self, p0: Vec2, cp0: Vec2, cp1: Vec2, p1: Vec2, arg2: Color, segments: u32, thickness: f32) {
3113        unsafe {
3114            nk_draw_list_stroke_curve(&mut self.internal, p0, cp0, cp1, p1, arg2, segments, thickness);
3115        }
3116    }
3117
3118    pub fn stroke_poly_line(&mut self, points: &[Vec2], arg2: Color, arg3: DrawListStroke, thickness: f32, aa: AntiAliasing) {
3119        unsafe {
3120            nk_draw_list_stroke_poly_line(&mut self.internal, points.as_ptr(), points.len() as u32, arg2, arg3, thickness, aa.into());
3121        }
3122    }
3123
3124    pub fn fill_rect(&mut self, rect: Rect, arg2: Color, rounding: f32) {
3125        unsafe {
3126            nk_draw_list_fill_rect(&mut self.internal, rect, arg2, rounding);
3127        }
3128    }
3129
3130    pub fn fill_rect_multi_color(&mut self, rect: Rect, left: Color, top: Color, right: Color, bottom: Color) {
3131        unsafe {
3132            nk_draw_list_fill_rect_multi_color(&mut self.internal, rect, left, top, right, bottom);
3133        }
3134    }
3135
3136    pub fn fill_triangle(&mut self, a: Vec2, b: Vec2, c: Vec2, arg2: Color) {
3137        unsafe {
3138            nk_draw_list_fill_triangle(&mut self.internal, a, b, c, arg2);
3139        }
3140    }
3141
3142    pub fn fill_circle(&mut self, center: Vec2, radius: f32, col: Color, segs: u32) {
3143        unsafe {
3144            nk_draw_list_fill_circle(&mut self.internal, center, radius, col, segs);
3145        }
3146    }
3147
3148    pub fn fill_poly_convex(&mut self, points: &[Vec2], arg2: Color, arg3: AntiAliasing) {
3149        unsafe {
3150            nk_draw_list_fill_poly_convex(&mut self.internal, points.as_ptr(), points.len() as u32, arg2, arg3.into());
3151        }
3152    }
3153
3154    pub fn add_image(&mut self, texture: Image, rect: Rect, arg2: Color) {
3155        unsafe {
3156            nk_draw_list_add_image(&mut self.internal, texture.internal, rect, arg2);
3157        }
3158    }
3159
3160    pub fn add_text(&mut self, arg2: &UserFont, arg3: Rect, text: String, font_height: f32, arg4: Color) {
3161        unsafe {
3162            nk_draw_list_add_text(&mut self.internal, &arg2.internal, arg3, text.as_ptr(), text.bytes.len() as i32, font_height, arg4);
3163        }
3164    }
3165
3166    // pub fn push_userdata(&mut self, userdata: nk_handle) {
3167    // unsafe {
3168    // nk_draw_list_push_userdata(&mut self as *mut nk_draw_list, userdata.internal);
3169    // }
3170    // }
3171}
3172
3173// ========
3174
3175#[derive(Clone, Copy)]
3176pub struct ColorMap {
3177    internal: [nk_color; 28],
3178}
3179
3180impl Default for ColorMap {
3181    fn default() -> Self {
3182        ColorMap { internal: [nk_color::default(); 28] }
3183    }
3184}
3185
3186impl ColorMap {
3187    pub fn set(&mut self, target: StyleColor, color: Color) {
3188        self.internal[target as usize] = color;
3189    }
3190}
3191
3192// ==================================================================================
3193
3194pub struct CursorMap<'a> {
3195    internal: [Option<&'a Cursor>; 7],
3196}
3197
3198impl<'a> Default for CursorMap<'a> {
3199    fn default() -> Self {
3200        unsafe {
3201            let mut map = CursorMap { internal: [::std::mem::zeroed(); 7] };
3202
3203            for i in &mut map.internal {
3204                ::std::ptr::write(i, None);
3205            }
3206
3207            map
3208        }
3209    }
3210}
3211
3212impl<'a> CursorMap<'a> {
3213    pub fn set(&mut self, target: StyleCursor, res: Option<&'a Cursor>) {
3214        self.internal[target as usize] = res;
3215    }
3216}
3217
3218// ==================================================================================
3219
3220wrapper_type!(Cursor, nk_cursor);
3221
3222impl Cursor {
3223    pub fn img(&self) -> &Image {
3224        unsafe { ::std::mem::transmute(&self.internal.img) }
3225    }
3226    pub fn size(&self) -> &Vec2 {
3227        &self.internal.size
3228    }
3229    pub fn offset(&self) -> &Vec2 {
3230        &self.internal.offset
3231    }
3232}
3233
3234// ==================================================================================
3235
3236wrapper_type!(Allocator, nk_allocator);
3237
3238impl Allocator {
3239    #[cfg(feature = "rust_allocator")]
3240    pub fn new_heap() -> Allocator {
3241        let mut a = Allocator::default();
3242
3243        a.internal.alloc = Some(alloc_heap::alloc);
3244        a.internal.free = Some(alloc_heap::free);
3245        a.internal.userdata = nk_handle::default();
3246        a.internal.userdata.ptr = ::std::ptr::null_mut();
3247        a
3248    }
3249
3250    pub fn new_vec() -> Allocator {
3251        let mut a = Allocator::default();
3252
3253        a.internal.alloc = Some(alloc_vec::alloc);
3254        a.internal.free = Some(alloc_vec::free);
3255        a.internal.userdata = nk_handle::default();
3256        a.internal.userdata.ptr = ::std::ptr::null_mut();
3257        a
3258    }
3259}
3260
3261// ============================================================================================
3262
3263wrapper_type!(ConvertConfig, nk_convert_config);
3264
3265impl ConvertConfig {
3266    pub fn set_global_alpha(&mut self, val: f32) {
3267        self.internal.global_alpha = val;
3268    }
3269    pub fn set_line_aa(&mut self, val: AntiAliasing) {
3270        self.internal.line_AA = val.into();
3271    }
3272    pub fn set_shape_aa(&mut self, val: AntiAliasing) {
3273        self.internal.shape_AA = val.into();
3274    }
3275    pub fn set_circle_segment_count(&mut self, val: u32) {
3276        self.internal.circle_segment_count = val;
3277    }
3278    pub fn set_arc_segment_count(&mut self, val: u32) {
3279        self.internal.arc_segment_count = val;
3280    }
3281    pub fn set_curve_segment_count(&mut self, val: u32) {
3282        self.internal.curve_segment_count = val;
3283    }
3284    pub fn set_null(&mut self, val: DrawNullTexture) {
3285        self.internal.null = val.internal;
3286    }
3287    pub fn set_vertex_layout(&mut self, val: &DrawVertexLayoutElements) {
3288        self.internal.vertex_layout = &val.arr.as_slice()[0];
3289    }
3290    pub fn set_vertex_size(&mut self, val: Size) {
3291        self.internal.vertex_size = val;
3292    }
3293    // pub fn set_vertex_alignment(&mut self, val: usize) {
3294    // self.internal.vertex_alignment = val;
3295    // }
3296}
3297
3298// ============================================================================================
3299
3300#[derive(Debug, Clone)]
3301pub struct DrawVertexLayoutElements {
3302    arr: Vec<nk_draw_vertex_layout_element>,
3303}
3304
3305impl DrawVertexLayoutElements {
3306    pub fn new(var: &[(DrawVertexLayoutAttribute, DrawVertexLayoutFormat, Size)]) -> DrawVertexLayoutElements {
3307        DrawVertexLayoutElements {
3308            arr: var.iter().map(|&(a, f, o)| nk_draw_vertex_layout_element { attribute: a.into(), format: f.into(), offset: o }).collect::<Vec<_>>(),
3309        }
3310    }
3311}
3312
3313// =============================================================================================
3314
3315wrapper_type!(StyleItem, nk_style_item);
3316
3317impl StyleItem {
3318    pub fn image(img: Image) -> StyleItem {
3319        unsafe { StyleItem { internal: nk_style_item_image(img.internal) } }
3320    }
3321
3322    pub fn color(col: Color) -> StyleItem {
3323        unsafe { StyleItem { internal: nk_style_item_color(col) } }
3324    }
3325
3326    pub fn hide() -> StyleItem {
3327        unsafe { StyleItem { internal: nk_style_item_hide() } }
3328    }
3329}
3330
3331// =============================================================================================
3332
3333wrapper_type_no_clone!(TextEdit, nk_text_edit);
3334
3335impl Drop for TextEdit {
3336    fn drop(&mut self) {
3337        unsafe {
3338            nk_textedit_free(&mut self.internal);
3339        }
3340    }
3341}
3342
3343impl TextEdit {
3344    pub fn init(&mut self, arg2: &mut Allocator, size: Size) {
3345        unsafe {
3346            nk_textedit_init(&mut self.internal, &mut arg2.internal as *mut nk_allocator, size);
3347        }
3348    }
3349
3350    pub fn text(&mut self, arg2: &str) {
3351        unsafe {
3352            nk_textedit_text(&mut self.internal, arg2.as_ptr() as *const i8, arg2.as_bytes().len() as ::std::os::raw::c_int);
3353        }
3354    }
3355
3356    pub fn delete(&mut self, where_: u32, len: u32) {
3357        unsafe {
3358            nk_textedit_delete(&mut self.internal, where_ as ::std::os::raw::c_int, len as ::std::os::raw::c_int);
3359        }
3360    }
3361
3362    pub fn delete_selection(&mut self) {
3363        unsafe {
3364            nk_textedit_delete_selection(&mut self.internal);
3365        }
3366    }
3367
3368    pub fn select_all(&mut self) {
3369        unsafe {
3370            nk_textedit_select_all(&mut self.internal);
3371        }
3372    }
3373
3374    pub fn cut(&mut self) -> bool {
3375        unsafe { nk_textedit_cut(&mut self.internal) != 0 }
3376    }
3377
3378    pub fn paste(&mut self, arg2: &str) -> bool {
3379        unsafe { nk_textedit_paste(&mut self.internal, arg2.as_ptr() as *const i8, arg2.as_bytes().len() as ::std::os::raw::c_int) != 0 }
3380    }
3381
3382    pub fn undo(&mut self) {
3383        unsafe {
3384            nk_textedit_undo(&mut self.internal);
3385        }
3386    }
3387
3388    pub fn redo(&mut self) {
3389        unsafe {
3390            nk_textedit_redo(&mut self.internal);
3391        }
3392    }
3393
3394    // pub fn nk_textedit_init_fixed(arg1: *mut nk_text_edit,
3395    // memory: *mut ::std::os::raw::c_void,
3396    // size: nk_size);
3397    //
3398}
3399
3400// =============================================================================================
3401
3402wrapper_type!(FontConfig, nk_font_config);
3403
3404impl FontConfig {
3405    pub fn with_size(pixel_height: f32) -> FontConfig {
3406        unsafe { FontConfig { internal: nk_font_config(pixel_height) } }
3407    }
3408
3409    pub fn is_ttf_data_owned_by_atlas(&self) -> bool {
3410        self.internal.ttf_data_owned_by_atlas > 0
3411    }
3412
3413    pub fn size(&self) -> f32 {
3414        self.internal.size
3415    }
3416
3417    pub fn oversample_v(&self) -> u8 {
3418        self.internal.oversample_v
3419    }
3420
3421    pub fn oversample_h(&self) -> u8 {
3422        self.internal.oversample_h
3423    }
3424
3425    pub fn glyph_range(&self) -> Option<&[(u32, u32)]> {
3426        if self.internal.range.is_null() {
3427            None
3428        } else {
3429            Some(raw_glyph_ranges_to_safe(self.internal.range))
3430        }
3431    }
3432
3433    // pub fn set_next<'a>(&'a mut self, next_cfg: &mut FontConfig) {
3434    // self.internal.next = &mut next_cfg.internal;
3435    // }
3436
3437    pub fn padding(&self) -> [u8; 3] {
3438        self.internal.padding
3439    }
3440
3441    pub fn fallback_glyph(&self) -> char {
3442        unsafe { ::std::char::from_u32_unchecked(self.internal.fallback_glyph) }
3443    }
3444
3445    pub fn spacing(&self) -> &Vec2 {
3446        &self.internal.spacing
3447    }
3448
3449    pub fn coord_type(&self) -> &FontCoordType {
3450        &self.internal.coord_type
3451    }
3452
3453    pub fn is_pixel_snap(&self) -> bool {
3454        self.internal.pixel_snap > 0
3455    }
3456
3457    pub fn is_merge_mode(&self) -> bool {
3458        self.internal.merge_mode > 0
3459    }
3460
3461    // ==
3462
3463    pub fn set_ttf_data_owned_by_atlas(&mut self, yes: bool) {
3464        self.internal.ttf_data_owned_by_atlas = if yes { 1 } else { 0 };
3465    }
3466
3467    pub fn set_size(&mut self, size: f32) {
3468        self.internal.size = size;
3469    }
3470
3471    pub fn set_oversample_v(&mut self, v: u8) {
3472        self.internal.oversample_v = v;
3473    }
3474
3475    pub fn set_oversample_h(&mut self, h: u8) {
3476        self.internal.oversample_h = h;
3477    }
3478
3479    pub fn set_glyph_range<'a>(&'a mut self, ranges: &'a [(u32, u32)]) {
3480        self.internal.range = ranges as *const _ as *const u32;
3481    }
3482
3483    // pub fn set_next<'a>(&'a mut self, next_cfg: &mut FontConfig) {
3484    // self.internal.next = &mut next_cfg.internal;
3485    // }
3486
3487    pub fn set_ttf<'a>(&'a mut self, font_bytes: &'a [u8]) {
3488        self.internal.ttf_size = font_bytes.len() as Size;
3489        self.internal.ttf_blob = font_bytes as *const _ as *mut c_void;
3490    }
3491
3492    pub fn set_padding(&mut self, p: [u8; 3]) {
3493        self.internal.padding = p;
3494    }
3495
3496    pub fn set_fallback_glyph(&mut self, g: char) {
3497        self.internal.fallback_glyph = g as u32;
3498    }
3499
3500    pub fn set_spacing(&mut self, s: Vec2) {
3501        self.internal.spacing = s;
3502    }
3503
3504    pub fn set_coord_type(&mut self, t: FontCoordType) {
3505        self.internal.coord_type = t;
3506    }
3507
3508    pub fn set_pixel_snap(&mut self, s: bool) {
3509        self.internal.pixel_snap = if s { 1 } else { 0 };
3510    }
3511
3512    pub fn set_merge_mode(&mut self, m: bool) {
3513        self.internal.merge_mode = if m { 1 } else { 0 };
3514    }
3515
3516    // pub ttf_data_owned_by_atlas: ::std::os::raw::c_uchar,
3517    // pub font: *mut nk_baked_font,
3518    //
3519}
3520
3521// =============================================================================================
3522
3523wrapper_type!(FontAtlas, nk_font_atlas);
3524pub type FontID = usize;
3525
3526impl Drop for FontAtlas {
3527    fn drop(&mut self) {
3528        self.clear();
3529    }
3530}
3531
3532impl FontAtlas {
3533    pub fn new(alloc: &mut Allocator) -> FontAtlas {
3534        let mut a = FontAtlas::default();
3535        a.init(alloc);
3536        a
3537    }
3538
3539    pub fn add_font_with_config(&mut self, cfg: &FontConfig) -> Option<FontID> {
3540        unsafe {
3541            if self.internal.font_num < 1 {
3542                nk_font_atlas_begin(&mut self.internal as *mut nk_font_atlas);
3543            }
3544            let current = self.internal.font_num;
3545
3546            let ret = nk_font_atlas_add(&mut self.internal as *mut nk_font_atlas, &cfg.internal as *const nk_font_config);
3547
3548            if !ret.is_null() && (self.internal.font_num - current) == 1 {
3549                Some(current as FontID)
3550            } else {
3551                None
3552            }
3553        }
3554    }
3555
3556    pub fn add_font_with_bytes(&mut self, font_bytes: &[u8], font_size: f32) -> Option<FontID> {
3557        let mut cfg = FontConfig::with_size(font_size);
3558
3559        cfg.internal.ttf_size = font_bytes.len() as Size;
3560        cfg.internal.ttf_blob = font_bytes as *const _ as *mut c_void;
3561        cfg.internal.size = font_size;
3562        cfg.internal.ttf_data_owned_by_atlas = 1;
3563
3564        self.add_font_with_config(&cfg)
3565    }
3566
3567    pub fn bake(&mut self, format: FontAtlasFormat) -> (&[u8], u32, u32) {
3568        let mut width: i32 = 0;
3569        let mut height: i32 = 0;
3570
3571        let image = unsafe { nk_font_atlas_bake(&mut self.internal as *mut nk_font_atlas, &mut width as *mut c_int, &mut height as *mut c_int, format.into()) };
3572
3573        if width < 1 || height < 1 {
3574            return (&[], width as u32, height as u32);
3575        }
3576
3577        let size = (match format {
3578            FontAtlasFormat::Alpha8 => 1,
3579            FontAtlasFormat::Rgba32 => 4,
3580        } * width
3581            * height) as usize;
3582
3583        (unsafe { ::std::slice::from_raw_parts(image as *const u8, size) }, width as u32, height as u32)
3584    }
3585
3586    pub fn end(&mut self, hnd: Handle, null_texture: Option<&mut DrawNullTexture>) {
3587        let nullt = match null_texture {
3588            Some(n) => &mut n.internal as *mut nk_draw_null_texture,
3589            None => ::std::ptr::null_mut(),
3590        };
3591        unsafe {
3592            nk_font_atlas_end(&mut self.internal as *mut nk_font_atlas, hnd.internal, nullt);
3593        }
3594    }
3595
3596    pub fn cleanup(&mut self) {
3597        unsafe {
3598            nk_font_atlas_cleanup(&mut self.internal as *mut nk_font_atlas);
3599        }
3600    }
3601
3602    fn clear(&mut self) {
3603        unsafe {
3604            nk_font_atlas_clear(&mut self.internal as *mut nk_font_atlas);
3605        }
3606    }
3607
3608    fn init(&mut self, arg2: &mut Allocator) {
3609        unsafe {
3610            nk_font_atlas_init(&mut self.internal as *mut nk_font_atlas, &mut arg2.internal as *mut nk_allocator);
3611        }
3612    }
3613
3614    #[allow(dead_code)]
3615    fn init_custom(&mut self, persistent: &mut Allocator, transient: &mut Allocator) {
3616        unsafe {
3617            nk_font_atlas_init_custom(&mut self.internal as *mut nk_font_atlas, &mut persistent.internal as *mut nk_allocator, &mut transient.internal as *mut nk_allocator);
3618        }
3619    }
3620
3621    pub fn begin(&mut self) {
3622        unsafe {
3623            nk_font_atlas_begin(&mut self.internal as *mut nk_font_atlas);
3624        }
3625    }
3626
3627    pub fn pixels(&self) -> &[u8] {
3628        unsafe { ::std::slice::from_raw_parts(self.internal.pixel as *const _ as *const u8, (self.internal.tex_width * self.internal.tex_height * 4) as usize) }
3629    }
3630
3631    pub fn tex_width(&self) -> u16 {
3632        self.internal.tex_width as u16
3633    }
3634
3635    pub fn tex_height(&self) -> u16 {
3636        self.internal.tex_height as u16
3637    }
3638
3639    pub fn custom(&self) -> Recti {
3640        self.internal.custom
3641    }
3642
3643    pub fn cursors(&self) -> &[Cursor] {
3644        unsafe { ::std::slice::from_raw_parts(self.internal.cursors.as_ptr() as *const Cursor, self.internal.cursors.len()) }
3645    }
3646
3647    pub fn glyphs(&self) -> &[FontGlyph] {
3648        unsafe { ::std::slice::from_raw_parts(self.internal.glyphs as *const _ as *const FontGlyph, self.internal.glyph_count as usize) }
3649    }
3650
3651    pub fn fonts_iterator(&self) -> FontIterator {
3652        FontIterator { ctx: self }
3653    }
3654
3655    pub fn font(&self, id: FontID) -> Option<&Font> {
3656        let id = self.internal.font_num as usize - id - 1;
3657        self.fonts_iterator().into_iter().nth(id)
3658    }
3659}
3660
3661pub struct FontIterator<'a> {
3662    ctx: &'a FontAtlas,
3663}
3664impl<'a> IntoIterator for FontIterator<'a> {
3665    type Item = &'a Font;
3666    type IntoIter = FontIntoIter<'a>;
3667
3668    fn into_iter(self) -> Self::IntoIter {
3669        let font = if self.ctx.internal.fonts.is_null() { None } else { Some(unsafe { ::std::mem::transmute(self.ctx.internal.fonts) }) };
3670        FontIntoIter { font }
3671    }
3672}
3673pub struct FontIntoIter<'a> {
3674    font: Option<&'a Font>,
3675}
3676impl<'a> Iterator for FontIntoIter<'a> {
3677    type Item = &'a Font;
3678    fn next(&mut self) -> Option<&'a Font> {
3679        let r = self.font;
3680
3681        self.font = if let Some(p) = self.font {
3682            if p.internal.next.is_null() {
3683                None
3684            } else {
3685                Some(unsafe { ::std::mem::transmute(p.internal.next) })
3686            }
3687        } else {
3688            None
3689        };
3690
3691        r
3692    }
3693}
3694
3695// =============================================================================================
3696
3697wrapper_type!(DrawNullTexture, nk_draw_null_texture);
3698
3699// =============================================================================================
3700
3701const DEFAULT_BUFFER_SIZE: usize = 8096;
3702
3703wrapper_type!(Buffer, nk_buffer);
3704
3705impl Drop for Buffer {
3706    fn drop(&mut self) {
3707        unsafe {
3708            nk_buffer_free(&mut self.internal);
3709        }
3710    }
3711}
3712
3713impl Buffer {
3714    pub fn new(alloc: &mut Allocator) -> Buffer {
3715        Buffer::with_size(alloc, DEFAULT_BUFFER_SIZE)
3716    }
3717
3718    pub fn with_size(alloc: &mut Allocator, buffer_size: usize) -> Buffer {
3719        let mut a = Buffer::default();
3720        unsafe {
3721            nk_buffer_init(&mut a.internal as *mut nk_buffer, &mut alloc.internal as *const nk_allocator, buffer_size as Size);
3722        }
3723        a
3724    }
3725
3726    pub fn with_fixed(memory: &mut [u8]) -> Buffer {
3727        let mut a = Buffer::default();
3728        unsafe {
3729            nk_buffer_init_fixed(&mut a.internal as *mut nk_buffer, memory as *mut _ as *mut ::std::os::raw::c_void, memory.len() as Size);
3730        }
3731        a
3732    }
3733
3734    pub fn total(&mut self) -> usize {
3735        unsafe { nk_buffer_total(&mut self.internal as *mut nk_buffer) as usize }
3736    }
3737
3738    pub fn info(&mut self) -> (usize, usize, usize, usize) /*size, allocated, needed, calls*/ {
3739        let mut s = nk_memory_status::default();
3740        unsafe {
3741            nk_buffer_info(&mut s, &mut self.internal as *mut nk_buffer);
3742        }
3743        (s.size as usize, s.allocated as usize, s.needed as usize, s.calls as usize)
3744    }
3745
3746    // pub fn nk_buffer_push(arg1: *mut nk_buffer,
3747    // type_: nk_buffer_allocation_type,
3748    // memory: *const ::std::os::raw::c_void,
3749    // size: nk_size, align: nk_size);
3750    // pub fn nk_buffer_mark(arg1: *mut nk_buffer,
3751    // type_: nk_buffer_allocation_type);
3752    // pub fn nk_buffer_reset(arg1: *mut nk_buffer,
3753    // type_: nk_buffer_allocation_type);
3754    // pub fn nk_buffer_clear(arg1: *mut nk_buffer);
3755    // pub fn nk_buffer_free(arg1: *mut nk_buffer);
3756    // pub fn nk_buffer_memory(arg1: *mut nk_buffer)
3757    // -> *mut ::std::os::raw::c_void;
3758    // pub fn nk_buffer_memory_const(arg1: *const nk_buffer)
3759    // -> *const ::std::os::raw::c_void;
3760    // pub fn nk_buffer_total(arg1: *mut nk_buffer) -> &_size;
3761    //
3762    // pub fn nk_buffer_init(arg1: *mut nk_buffer, arg2: *const nk_allocator,
3763    // size: nk_size);
3764    // pub fn nk_buffer_init_fixed(arg1: *mut nk_buffer,
3765    // memory: *mut ::std::os::raw::c_void,
3766    // size: nk_size);
3767    //
3768}
3769
3770// =============================================================================================
3771
3772pub struct Context {
3773    internal: nk_context,
3774}
3775
3776impl Default for Context {
3777    fn default() -> Self {
3778        Context { internal: nk_context::default() }
3779    }
3780}
3781
3782impl Drop for Context {
3783    fn drop(&mut self) {
3784        unsafe {
3785            nk_free(&mut self.internal as *mut nk_context);
3786        }
3787    }
3788}
3789
3790impl Context {
3791    pub fn new(alloc: &mut Allocator, font: &UserFont) -> Context {
3792        let mut a = Context::default();
3793
3794        unsafe {
3795            nk_init(&mut a.internal as *mut nk_context, &mut alloc.internal, &font.internal);
3796        }
3797
3798        a
3799    }
3800
3801    pub fn clip_mut(&mut self) -> &mut Clipboard {
3802        unsafe { ::std::mem::transmute(&mut self.internal.clip) }
3803    }
3804
3805    pub fn clip(&self) -> &Clipboard {
3806        unsafe { ::std::mem::transmute(&self.internal.clip) }
3807    }
3808
3809    pub fn last_widget_state(&self) -> Flags {
3810        self.internal.last_widget_state
3811    }
3812
3813    pub fn delta_time_seconds(&self) -> f32 {
3814        self.internal.delta_time_seconds
3815    }
3816
3817    pub fn button_behavior(&self) -> ButtonBehavior {
3818        self.internal.button_behavior.into()
3819    }
3820
3821    pub fn set_button_behavior(&mut self, bb: ButtonBehavior) {
3822        self.internal.button_behavior = bb.into()
3823    }
3824
3825    pub fn input_mut(&mut self) -> &mut Input {
3826        unsafe { ::std::mem::transmute(&mut self.internal.input) }
3827    }
3828
3829    pub fn style_mut(&mut self) -> &mut Style {
3830        unsafe { ::std::mem::transmute(&mut self.internal.style) }
3831    }
3832
3833    pub fn draw_list_mut(&mut self) -> &mut DrawList {
3834        unsafe { ::std::mem::transmute(&mut self.internal.draw_list) }
3835    }
3836
3837    pub fn input(&self) -> &Input {
3838        unsafe { ::std::mem::transmute(&self.internal.input) }
3839    }
3840
3841    pub fn style(&self) -> &Style {
3842        unsafe { ::std::mem::transmute(&self.internal.style) }
3843    }
3844
3845    pub fn draw_list(&self) -> &DrawList {
3846        unsafe { ::std::mem::transmute(&self.internal.draw_list) }
3847    }
3848
3849    pub fn clear(&mut self) {
3850        unsafe {
3851            nk_clear(&mut self.internal as *mut nk_context);
3852        }
3853    }
3854
3855    pub fn begin(&mut self, title: String, bounds: Rect, flags: Flags) -> bool {
3856        unsafe { nk_begin(&mut self.internal as *mut nk_context, title.as_ptr(), bounds, flags) != 0 }
3857    }
3858
3859    pub fn begin_titled(&mut self, name: String, title: String, bounds: Rect, flags: Flags) -> i32 {
3860        unsafe { nk_begin_titled(&mut self.internal as *mut nk_context, name.as_ptr(), title.as_ptr(), bounds, flags) }
3861    }
3862
3863    pub fn end(&mut self) {
3864        unsafe {
3865            nk_end(&mut self.internal as *mut nk_context);
3866        }
3867    }
3868
3869    pub fn window_find<S: AsRef<str>>(&self, name: S) -> Option<&Window> {
3870        let w = unsafe { nk_window_find(&self.internal as *const _ as *mut nk_context, name.as_ref().as_ptr() as *const i8) };
3871
3872        unsafe {
3873            if w.is_null() {
3874                None
3875            } else {
3876                Some(::std::mem::transmute(w))
3877            }
3878        }
3879    }
3880    pub fn window_find_mut(&mut self, name: String) -> Option<&mut Window> {
3881        let w = unsafe { nk_window_find(&mut self.internal as *mut nk_context, name.as_ptr()) };
3882
3883        unsafe {
3884            if w.is_null() {
3885                None
3886            } else {
3887                Some(::std::mem::transmute(w))
3888            }
3889        }
3890    }
3891
3892    pub fn window_get_bounds(&self) -> Rect {
3893        unsafe { nk_window_get_bounds(&self.internal as *const nk_context) }
3894    }
3895
3896    pub fn window_get_size(&self) -> Vec2 {
3897        unsafe { nk_window_get_size(&self.internal as *const nk_context) }
3898    }
3899
3900    pub fn window_get_position(&self) -> Vec2 {
3901        unsafe { nk_window_get_position(&self.internal as *const nk_context) }
3902    }
3903
3904    pub fn window_get_width(&self) -> f32 {
3905        unsafe { nk_window_get_width(&self.internal as *const nk_context) }
3906    }
3907
3908    pub fn window_get_height(&self) -> f32 {
3909        unsafe { nk_window_get_height(&self.internal as *const nk_context) }
3910    }
3911
3912    pub fn window_get_panel_mut(&mut self) -> Option<&mut Panel> {
3913        let p = unsafe { nk_window_get_panel(&mut self.internal as *mut nk_context) };
3914
3915        unsafe {
3916            if p.is_null() {
3917                None
3918            } else {
3919                Some(::std::mem::transmute(p))
3920            }
3921        }
3922    }
3923    pub fn window_get_panel(&self) -> Option<&Panel> {
3924        let p = unsafe { nk_window_get_panel(&self.internal as *const _ as *mut nk_context) };
3925
3926        unsafe {
3927            if p.is_null() {
3928                None
3929            } else {
3930                Some(::std::mem::transmute(p))
3931            }
3932        }
3933    }
3934
3935    pub fn window_get_content_region(&self) -> Rect {
3936        unsafe { nk_window_get_content_region(&self.internal as *const _ as *mut nk_context) }
3937    }
3938
3939    pub fn window_get_content_region_min(&self) -> Vec2 {
3940        unsafe { nk_window_get_content_region_min(&self.internal as *const _ as *mut nk_context) }
3941    }
3942
3943    pub fn window_get_content_region_max(&self) -> Vec2 {
3944        unsafe { nk_window_get_content_region_max(&self.internal as *const _ as *mut nk_context) }
3945    }
3946
3947    pub fn window_get_content_region_size(&self) -> Vec2 {
3948        unsafe { nk_window_get_content_region_size(&self.internal as *const _ as *mut nk_context) }
3949    }
3950
3951    pub fn window_get_canvas_mut(&mut self) -> Option<&mut CommandBuffer> {
3952        let b = unsafe { nk_window_get_canvas(&mut self.internal as *mut nk_context) };
3953        unsafe {
3954            if b.is_null() {
3955                None
3956            } else {
3957                Some(::std::mem::transmute(b))
3958            }
3959        }
3960    }
3961    pub fn window_get_canvas(&self) -> Option<&CommandBuffer> {
3962        let b = unsafe { nk_window_get_canvas(&self.internal as *const _ as *mut nk_context) };
3963        unsafe {
3964            if b.is_null() {
3965                None
3966            } else {
3967                Some(::std::mem::transmute(b))
3968            }
3969        }
3970    }
3971
3972    pub fn window_has_focus(&self) -> bool {
3973        unsafe { nk_window_has_focus(&self.internal as *const nk_context) > 0 }
3974    }
3975
3976    pub fn window_is_collapsed(&self, name: String) -> bool {
3977        unsafe { nk_window_is_collapsed(&self.internal as *const _ as *mut nk_context, name.as_ptr()) > 0 }
3978    }
3979
3980    pub fn window_is_closed(&self, name: String) -> bool {
3981        unsafe { nk_window_is_closed(&self.internal as *const _ as *mut nk_context, name.as_ptr()) > 0 }
3982    }
3983
3984    pub fn window_is_hidden(&self, name: String) -> bool {
3985        unsafe { nk_window_is_hidden(&self.internal as *const _ as *mut nk_context, name.as_ptr()) > 0 }
3986    }
3987
3988    pub fn window_is_active(&self, name: String) -> bool {
3989        unsafe { nk_window_is_active(&self.internal as *const _ as *mut nk_context, name.as_ptr()) > 0 }
3990    }
3991
3992    pub fn window_is_hovered(&self) -> bool {
3993        unsafe { nk_window_is_hovered(&self.internal as *const _ as *mut nk_context) > 0 }
3994    }
3995
3996    pub fn window_is_any_hovered(&self) -> bool {
3997        unsafe { nk_window_is_any_hovered(&self.internal as *const _ as *mut nk_context) > 0 }
3998    }
3999
4000    pub fn item_is_any_active(&self) -> bool {
4001        unsafe { nk_item_is_any_active(&self.internal as *const _ as *mut nk_context) > 0 }
4002    }
4003
4004    pub fn window_set_bounds<S: AsRef<str>>(&mut self, name: S, bounds: Rect) {
4005        unsafe {
4006            nk_window_set_bounds(&mut self.internal as *mut nk_context, name.as_ref().as_ptr() as *const i8, bounds);
4007        }
4008    }
4009
4010    pub fn window_set_position<S: AsRef<str>>(&mut self, name: S, pos: Vec2) {
4011        unsafe {
4012            nk_window_set_position(&mut self.internal as *mut nk_context, name.as_ref().as_ptr() as *const i8, pos);
4013        }
4014    }
4015
4016    pub fn window_set_size<S: AsRef<str>>(&mut self, name: S, size: Vec2) {
4017        unsafe {
4018            nk_window_set_size(&mut self.internal as *mut nk_context, name.as_ref().as_ptr() as *const i8, size);
4019        }
4020    }
4021
4022    pub fn window_set_focus(&mut self, name: String) {
4023        unsafe {
4024            nk_window_set_focus(&mut self.internal as *mut nk_context, name.as_ptr());
4025        }
4026    }
4027
4028    pub fn window_close(&mut self, name: String) {
4029        unsafe {
4030            nk_window_close(&mut self.internal as *mut nk_context, name.as_ptr());
4031        }
4032    }
4033
4034    pub fn window_collapse(&mut self, name: String, state: CollapseState) {
4035        unsafe {
4036            nk_window_collapse(&mut self.internal as *mut nk_context, name.as_ptr(), state.into());
4037        }
4038    }
4039
4040    pub fn window_collapse_if(&mut self, name: String, state: CollapseState, cond: bool) {
4041        unsafe {
4042            nk_window_collapse_if(&mut self.internal as *mut nk_context, name.as_ptr(), state.into(), if cond { 1 } else { 0 });
4043        }
4044    }
4045
4046    pub fn window_show(&mut self, name: String, state: ShowState) {
4047        unsafe {
4048            nk_window_show(&mut self.internal as *mut nk_context, name.as_ptr(), state.into());
4049        }
4050    }
4051
4052    pub fn window_show_if(&mut self, name: String, state: ShowState, cond: bool) {
4053        unsafe {
4054            nk_window_show_if(&mut self.internal as *mut nk_context, name.as_ptr(), state.into(), if cond { 1 } else { 0 });
4055        }
4056    }
4057
4058    pub fn layout_row_dynamic(&mut self, height: f32, cols: i32) {
4059        unsafe {
4060            nk_layout_row_dynamic(&mut self.internal as *mut nk_context, height, cols);
4061        }
4062    }
4063
4064    pub fn layout_row_static(&mut self, height: f32, item_width: i32, cols: i32) {
4065        unsafe {
4066            nk_layout_row_static(&mut self.internal as *mut nk_context, height, item_width, cols);
4067        }
4068    }
4069
4070    pub fn layout_row_begin(&mut self, fmt: LayoutFormat, row_height: f32, cols: i32) {
4071        unsafe {
4072            nk_layout_row_begin(&mut self.internal as *mut nk_context, fmt.into(), row_height, cols);
4073        }
4074    }
4075
4076    pub fn layout_row_push(&mut self, value: f32) {
4077        unsafe {
4078            nk_layout_row_push(&mut self.internal as *mut nk_context, value);
4079        }
4080    }
4081
4082    pub fn layout_row_end(&mut self) {
4083        unsafe {
4084            nk_layout_row_end(&mut self.internal as *mut nk_context);
4085        }
4086    }
4087
4088    pub fn layout_row(&mut self, fmt: LayoutFormat, height: f32, cols_ratio: &[f32]) {
4089        unsafe {
4090            nk_layout_row(&mut self.internal as *mut nk_context, fmt.into(), height, cols_ratio.len() as i32, cols_ratio.as_ptr());
4091        }
4092    }
4093
4094    pub fn layout_space_begin(&mut self, fmt: LayoutFormat, height: f32, widget_count: i32) {
4095        unsafe {
4096            nk_layout_space_begin(&mut self.internal as *mut nk_context, fmt.into(), height, widget_count);
4097        }
4098    }
4099
4100    pub fn layout_space_push(&mut self, space: Rect) {
4101        unsafe {
4102            nk_layout_space_push(&mut self.internal as *mut nk_context, space);
4103        }
4104    }
4105
4106    pub fn layout_space_end(&mut self) {
4107        unsafe {
4108            nk_layout_space_end(&mut self.internal as *mut nk_context);
4109        }
4110    }
4111
4112    pub fn layout_space_bounds(&mut self) -> Rect {
4113        unsafe { nk_layout_space_bounds(&mut self.internal as *mut nk_context) }
4114    }
4115
4116    pub fn layout_space_to_screen(&mut self, space: Vec2) -> Vec2 {
4117        unsafe { nk_layout_space_to_screen(&mut self.internal as *mut nk_context, space) }
4118    }
4119
4120    pub fn layout_space_to_local(&mut self, space: Vec2) -> Vec2 {
4121        unsafe { nk_layout_space_to_local(&mut self.internal as *mut nk_context, space) }
4122    }
4123
4124    pub fn layout_space_rect_to_screen(&mut self, space: Rect) -> Rect {
4125        unsafe { nk_layout_space_rect_to_screen(&mut self.internal as *mut nk_context, space) }
4126    }
4127
4128    pub fn layout_space_rect_to_local(&mut self, space: Rect) -> Rect {
4129        unsafe { nk_layout_space_rect_to_local(&mut self.internal as *mut nk_context, space) }
4130    }
4131
4132    pub fn layout_ratio_from_pixel(&mut self, pixel_width: f32) -> f32 {
4133        unsafe { nk_layout_ratio_from_pixel(&mut self.internal as *mut nk_context, pixel_width) }
4134    }
4135
4136    pub fn group_begin(&mut self, title: String, flags: Flags) -> i32 {
4137        unsafe { nk_group_begin(&mut self.internal as *mut nk_context, title.as_ptr(), flags) }
4138    }
4139
4140    pub fn group_end(&mut self) {
4141        unsafe {
4142            nk_group_end(&mut self.internal as *mut nk_context);
4143        }
4144    }
4145
4146    pub fn tree_push_hashed(&mut self, ty: TreeType, title: String, initial_state: CollapseState, hash: String, len: i32, seed: i32) -> i32 {
4147        unsafe { nk_tree_push_hashed(&mut self.internal as *mut nk_context, ty.into(), title.as_ptr(), initial_state.into(), hash.as_ptr(), len, seed) }
4148    }
4149
4150    pub fn tree_image_push_hashed(&mut self, ty: TreeType, i: Image, title: String, initial_state: CollapseState, hash: String, len: i32, seed: i32) -> i32 {
4151        unsafe { nk_tree_image_push_hashed(&mut self.internal as *mut nk_context, ty.into(), i.internal, title.as_ptr(), initial_state.into(), hash.as_ptr(), len, seed) }
4152    }
4153
4154    pub fn tree_pop(&mut self) {
4155        unsafe {
4156            nk_tree_pop(&mut self.internal as *mut nk_context);
4157        }
4158    }
4159
4160    pub fn text(&mut self, text: &str, flags: Flags) {
4161        unsafe {
4162            nk_text(&mut self.internal as *mut nk_context, text.as_ptr() as *const i8, text.as_bytes().len() as i32, flags);
4163        }
4164    }
4165
4166    pub fn text_colored(&mut self, text: &str, flags: Flags, color: Color) {
4167        unsafe {
4168            nk_text_colored(&mut self.internal as *mut nk_context, text.as_ptr() as *const i8, text.as_bytes().len() as i32, flags, color);
4169        }
4170    }
4171
4172    pub fn text_wrap(&mut self, text: &str) {
4173        unsafe {
4174            nk_text_wrap(&mut self.internal as *mut nk_context, text.as_ptr() as *const i8, text.as_bytes().len() as i32);
4175        }
4176    }
4177
4178    pub fn text_wrap_colored(&mut self, text: &str, color: Color) {
4179        unsafe {
4180            nk_text_wrap_colored(&mut self.internal as *mut nk_context, text.as_ptr() as *const i8, text.as_bytes().len() as i32, color);
4181        }
4182    }
4183
4184    pub fn label(&mut self, text: String, flags: Flags) {
4185        unsafe {
4186            nk_label(&mut self.internal as *mut nk_context, text.as_ptr(), flags);
4187        }
4188    }
4189
4190    pub fn label_colored(&mut self, text: String, flags: Flags, color: Color) {
4191        unsafe {
4192            nk_label_colored(&mut self.internal as *mut nk_context, text.as_ptr(), flags, color);
4193        }
4194    }
4195
4196    pub fn label_wrap(&mut self, text: String) {
4197        unsafe {
4198            nk_label_wrap(&mut self.internal as *mut nk_context, text.as_ptr());
4199        }
4200    }
4201
4202    pub fn label_colored_wrap(&mut self, text: String, color: Color) {
4203        unsafe {
4204            nk_label_colored_wrap(&mut self.internal as *mut nk_context, text.as_ptr(), color);
4205        }
4206    }
4207
4208    pub fn image(&mut self, img: Image) {
4209        unsafe {
4210            nk_image(&mut self.internal as *mut nk_context, img.internal);
4211        }
4212    }
4213
4214    pub fn button_text(&mut self, text: &str) -> bool {
4215        unsafe { nk_button_text(&mut self.internal as *mut nk_context, text.as_ptr() as *const i8, text.as_bytes().len() as i32) != 0 }
4216    }
4217
4218    pub fn button_label(&mut self, title: String) -> bool {
4219        unsafe { nk_button_label(&mut self.internal as *mut nk_context, title.as_ptr()) != 0 }
4220    }
4221
4222    pub fn button_color(&mut self, color: Color) -> bool {
4223        unsafe { nk_button_color(&mut self.internal as *mut nk_context, color) != 0 }
4224    }
4225
4226    pub fn button_symbol(&mut self, ty: SymbolType) -> bool {
4227        unsafe { nk_button_symbol(&mut self.internal as *mut nk_context, ty.into()) != 0 }
4228    }
4229
4230    pub fn button_image(&mut self, img: Image) -> bool {
4231        unsafe { nk_button_image(&mut self.internal as *mut nk_context, img.internal) != 0 }
4232    }
4233
4234    pub fn button_symbol_label(&mut self, ty: SymbolType, title: String, text_alignment: Flags) -> bool {
4235        unsafe { nk_button_symbol_label(&mut self.internal as *mut nk_context, ty.into(), title.as_ptr(), text_alignment) != 0 }
4236    }
4237
4238    pub fn button_symbol_text(&mut self, ty: SymbolType, title: &str, text_alignment: Flags) -> bool {
4239        unsafe { nk_button_symbol_text(&mut self.internal as *mut nk_context, ty.into(), title.as_ptr() as *const i8, title.as_bytes().len() as i32, text_alignment) != 0 }
4240    }
4241
4242    pub fn button_image_label(&mut self, img: Image, title: String, text_alignment: Flags) -> bool {
4243        unsafe { nk_button_image_label(&mut self.internal as *mut nk_context, img.internal, title.as_ptr(), text_alignment) != 0 }
4244    }
4245
4246    pub fn button_image_text(&mut self, img: Image, title: &str, text_alignment: Flags) -> bool {
4247        unsafe { nk_button_image_text(&mut self.internal as *mut nk_context, img.internal, title.as_ptr() as *const i8, title.as_bytes().len() as i32, text_alignment) != 0 }
4248    }
4249
4250    pub fn button_set_behavior(&mut self, b: ButtonBehavior) {
4251        unsafe {
4252            nk_button_set_behavior(&mut self.internal as *mut nk_context, b.into());
4253        }
4254    }
4255
4256    pub fn button_push_behavior(&mut self, b: ButtonBehavior) -> i32 {
4257        unsafe { nk_button_push_behavior(&mut self.internal as *mut nk_context, b.into()) }
4258    }
4259
4260    pub fn button_pop_behavior(&mut self) -> i32 {
4261        unsafe { nk_button_pop_behavior(&mut self.internal as *mut nk_context) }
4262    }
4263
4264    pub fn check_label(&mut self, title: String, active: bool) -> i32 {
4265        unsafe { nk_check_label(&mut self.internal as *mut nk_context, title.as_ptr(), if active { 1 } else { 0 }) }
4266    }
4267
4268    pub fn check_text(&mut self, title: &str, active: bool) -> i32 {
4269        unsafe { nk_check_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, if active { 1 } else { 0 }) }
4270    }
4271
4272    pub fn check_flags_label(&mut self, title: String, flags: u32, value: u32) -> u32 {
4273        unsafe { nk_check_flags_label(&mut self.internal as *mut nk_context, title.as_ptr(), flags, value) }
4274    }
4275
4276    pub fn check_flags_text(&mut self, title: &str, flags: u32, value: u32) -> u32 {
4277        unsafe { nk_check_flags_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, flags, value) }
4278    }
4279
4280    pub fn checkbox_label(&mut self, title: String, active: &mut bool) -> bool {
4281        let mut i = if *active { 1 } else { 0 };
4282        let r = unsafe { nk_checkbox_label(&mut self.internal as *mut nk_context, title.as_ptr(), &mut i as *mut i32) != 0 };
4283
4284        *active = i != 0;
4285        r
4286    }
4287
4288    pub fn checkbox_text(&mut self, title: &str, active: &mut bool) -> bool {
4289        let mut i = if *active { 1 } else { 0 };
4290        let r = unsafe { nk_checkbox_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, &mut i as *mut i32) != 0 };
4291
4292        *active = i != 0;
4293        r
4294    }
4295
4296    pub fn checkbox_flags_label(&mut self, title: String, flags: &mut u32, value: u32) -> bool {
4297        unsafe { nk_checkbox_flags_label(&mut self.internal as *mut nk_context, title.as_ptr(), flags, value) != 0 }
4298    }
4299
4300    pub fn checkbox_flags_text(&mut self, title: &str, flags: &mut u32, value: u32) -> bool {
4301        unsafe { nk_checkbox_flags_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, flags, value) != 0 }
4302    }
4303
4304    pub fn radio_label(&mut self, title: String, active: &mut bool) -> bool {
4305        let mut i = if *active { 1 } else { 0 };
4306        let r = unsafe { nk_radio_label(&mut self.internal as *mut nk_context, title.as_ptr(), &mut i as *mut i32) != 0 };
4307
4308        *active = i != 0;
4309        r
4310    }
4311
4312    pub fn radio_text(&mut self, title: &str, active: &mut bool) -> bool {
4313        let mut i = if *active { 1 } else { 0 };
4314        let r = unsafe { nk_radio_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, &mut i as *mut i32) != 0 };
4315
4316        *active = i != 0;
4317        r
4318    }
4319
4320    pub fn option_label(&mut self, title: String, active: bool) -> bool {
4321        unsafe { nk_option_label(&mut self.internal as *mut nk_context, title.as_ptr(), if active { 1 } else { 0 }) > 0 }
4322    }
4323
4324    pub fn option_text(&mut self, title: &str, active: bool) -> bool {
4325        unsafe { nk_option_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, if active { 1 } else { 0 }) > 0 }
4326    }
4327
4328    pub fn selectable_label(&mut self, title: String, align: Flags, value: &mut i32) -> bool {
4329        unsafe { nk_selectable_label(&mut self.internal as *mut nk_context, title.as_ptr(), align, value) != 0 }
4330    }
4331
4332    pub fn selectable_text(&mut self, title: &str, align: Flags, value: &mut i32) -> bool {
4333        unsafe { nk_selectable_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, align, value) != 0 }
4334    }
4335
4336    pub fn selectable_image_label(&mut self, img: Image, title: String, align: Flags, value: &mut i32) -> bool {
4337        unsafe { nk_selectable_image_label(&mut self.internal as *mut nk_context, img.internal, title.as_ptr(), align, value) != 0 }
4338    }
4339
4340    pub fn selectable_image_text(&mut self, img: Image, title: &str, align: Flags, value: &mut i32) -> bool {
4341        unsafe { nk_selectable_image_text(&mut self.internal as *mut nk_context, img.internal, title.as_ptr() as *const i8, title.as_bytes().len() as i32, align, value) != 0 }
4342    }
4343
4344    pub fn select_label(&mut self, title: String, align: Flags, value: i32) -> i32 {
4345        unsafe { nk_select_label(&mut self.internal as *mut nk_context, title.as_ptr(), align, value) }
4346    }
4347
4348    pub fn select_text(&mut self, title: &str, align: Flags, value: i32) -> i32 {
4349        unsafe { nk_select_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.as_bytes().len() as i32, align, value) }
4350    }
4351
4352    pub fn select_image_label(&mut self, img: Image, title: String, align: Flags, value: i32) -> i32 {
4353        unsafe { nk_select_image_label(&mut self.internal as *mut nk_context, img.internal, title.as_ptr(), align, value) }
4354    }
4355
4356    pub fn select_image_text(&mut self, img: Image, title: &str, align: Flags, value: i32) -> i32 {
4357        unsafe { nk_select_image_text(&mut self.internal as *mut nk_context, img.internal, title.as_ptr() as *const i8, title.as_bytes().len() as i32, align, value) }
4358    }
4359
4360    pub fn slide_float(&mut self, min: f32, val: f32, max: f32, step: f32) -> f32 {
4361        unsafe { nk_slide_float(&mut self.internal as *mut nk_context, min, val, max, step) }
4362    }
4363
4364    pub fn slide_int(&mut self, min: i32, val: i32, max: i32, step: i32) -> i32 {
4365        unsafe { nk_slide_int(&mut self.internal as *mut nk_context, min, val, max, step) }
4366    }
4367
4368    pub fn slider_float(&mut self, min: f32, val: &mut f32, max: f32, step: f32) -> bool {
4369        unsafe { nk_slider_float(&mut self.internal as *mut nk_context, min, val, max, step) != 0 }
4370    }
4371
4372    pub fn slider_int(&mut self, min: i32, val: &mut i32, max: i32, step: i32) -> bool {
4373        unsafe { nk_slider_int(&mut self.internal as *mut nk_context, min, val, max, step) != 0 }
4374    }
4375
4376    pub fn progress(&mut self, cur: &mut Size, max: Size, is_modifyable: bool) -> bool {
4377        unsafe { nk_progress(&mut self.internal as *mut nk_context, cur, max, if is_modifyable { 1 } else { 0 }) != 0 }
4378    }
4379
4380    pub fn prog(&mut self, cur: Size, max: Size, is_modifyable: bool) -> usize {
4381        unsafe { nk_prog(&mut self.internal as *mut nk_context, cur, max, if is_modifyable { 1 } else { 0 }) as usize }
4382    }
4383
4384    pub fn color_picker(&mut self, color: ColorF, fmt: ColorFormat) -> ColorF {
4385        unsafe { nk_color_picker(&mut self.internal as *mut nk_context, color, fmt.into()) }
4386    }
4387
4388    pub fn color_pick(&mut self, fmt: ColorFormat) -> (bool, ColorF) {
4389        let mut c = ColorF::default();
4390        let changed = unsafe { nk_color_pick(&mut self.internal as *mut nk_context, &mut c as *mut nk_colorf, fmt.into()) };
4391        (changed != 0, c)
4392    }
4393
4394    pub fn property_int(&mut self, name: String, min: i32, val: &mut i32, max: i32, step: i32, inc_per_pixel: f32) {
4395        unsafe {
4396            nk_property_int(&mut self.internal as *mut nk_context, name.as_ptr(), min, val, max, step, inc_per_pixel);
4397        }
4398    }
4399
4400    pub fn property_float(&mut self, name: String, min: f32, val: &mut f32, max: f32, step: f32, inc_per_pixel: f32) {
4401        unsafe { nk_property_float(&mut self.internal as *mut nk_context, name.as_ptr(), min, val, max, step, inc_per_pixel) }
4402    }
4403
4404    pub fn property_double(&mut self, name: String, min: f64, val: &mut f64, max: f64, step: f64, inc_per_pixel: f32) {
4405        unsafe { nk_property_double(&mut self.internal as *mut nk_context, name.as_ptr(), min, val, max, step, inc_per_pixel) }
4406    }
4407
4408    pub fn propertyi(&mut self, name: String, min: i32, val: i32, max: i32, step: i32, inc_per_pixel: f32) -> i32 {
4409        unsafe { nk_propertyi(&mut self.internal as *mut nk_context, name.as_ptr(), min, val, max, step, inc_per_pixel) }
4410    }
4411
4412    pub fn propertyf(&mut self, name: String, min: f32, val: f32, max: f32, step: f32, inc_per_pixel: f32) -> f32 {
4413        unsafe { nk_propertyf(&mut self.internal as *mut nk_context, name.as_ptr(), min, val, max, step, inc_per_pixel) }
4414    }
4415
4416    pub fn propertyd(&mut self, name: String, min: f64, val: f64, max: f64, step: f64, inc_per_pixel: f32) -> f64 {
4417        unsafe { nk_propertyd(&mut self.internal as *mut nk_context, name.as_ptr(), min, val, max, step, inc_per_pixel) }
4418    }
4419
4420    pub fn edit_string_custom_filter(&mut self, flags: Flags, buffer: &mut [u8], len: &mut i32, filter: fn(&TextEdit, char) -> bool) -> Flags {
4421        unsafe {
4422            CUSTOM_EDIT_FILTER = Some(filter);
4423            nk_edit_string(&mut self.internal as *mut nk_context, flags, &mut buffer[0] as *mut _ as *mut i8, len, buffer.len() as i32, Some(nk_filter_custom))
4424        }
4425    }
4426
4427    pub fn edit_string(&mut self, flags: Flags, buffer: &mut [u8], len: &mut i32, filter: PluginFilter) -> Flags {
4428        unsafe { nk_edit_string(&mut self.internal as *mut nk_context, flags, &mut buffer[0] as *mut _ as *mut i8, len, buffer.len() as i32, filter) }
4429    }
4430
4431    pub fn edit_buffer(&mut self, flags: Flags, editor: &mut TextEdit, filter: PluginFilter) -> Flags {
4432        unsafe { nk_edit_buffer(&mut self.internal as *mut nk_context, flags, &mut editor.internal, filter) }
4433    }
4434
4435    pub fn chart_begin(&mut self, ty: ChartType, num: i32, min: f32, max: f32) -> bool {
4436        unsafe { nk_chart_begin(&mut self.internal as *mut nk_context, ty.into(), num, min, max) > 0 }
4437    }
4438
4439    pub fn chart_begin_colored(&mut self, ty: ChartType, color: Color, active: Color, num: i32, min: f32, max: f32) -> bool {
4440        unsafe { nk_chart_begin_colored(&mut self.internal as *mut nk_context, ty.into(), color, active, num, min, max) > 0 }
4441    }
4442
4443    pub fn chart_add_slot(&mut self, ty: ChartType, count: i32, min_value: f32, max_value: f32) {
4444        unsafe {
4445            nk_chart_add_slot(&mut self.internal as *mut nk_context, ty.into(), count, min_value, max_value);
4446        }
4447    }
4448
4449    pub fn chart_add_slot_colored(&mut self, ty: ChartType, color: Color, active: Color, count: i32, min_value: f32, max_value: f32) {
4450        unsafe {
4451            nk_chart_add_slot_colored(&mut self.internal as *mut nk_context, ty.into(), color, active, count, min_value, max_value);
4452        }
4453    }
4454
4455    pub fn chart_push(&mut self, value: f32) -> Flags {
4456        unsafe { nk_chart_push(&mut self.internal as *mut nk_context, value) }
4457    }
4458
4459    pub fn chart_push_slot(&mut self, value: f32, count: i32) -> Flags {
4460        unsafe { nk_chart_push_slot(&mut self.internal as *mut nk_context, value, count) }
4461    }
4462
4463    pub fn chart_end(&mut self) {
4464        unsafe {
4465            nk_chart_end(&mut self.internal as *mut nk_context);
4466        }
4467    }
4468
4469    pub fn plot(&mut self, ty: ChartType, values: &[f32]) {
4470        unsafe {
4471            nk_plot(&mut self.internal as *mut nk_context, ty.into(), values.as_ptr(), values.len() as i32, 0);
4472        }
4473    }
4474
4475    // pub fn plot_function(&mut self, ty: ChartType, userdata: &[f32], offset: i32) {
4476    // unsafe {
4477    // nk_plot_function(&mut self.internal as *mut nk_context, ty, userdata as *const _ as *mut ::std::os::raw::c_void, Some(nk_plot_value_getter_custom), userdata.len() as i32, offset);
4478    // }
4479    // }
4480
4481    pub fn popup_begin(&mut self, ty: PopupType, title: String, flags: Flags, bounds: Rect) -> bool {
4482        unsafe { nk_popup_begin(&mut self.internal as *mut nk_context, ty.into(), title.as_ptr(), flags, bounds) > 0 }
4483    }
4484
4485    pub fn popup_close(&mut self) {
4486        unsafe {
4487            nk_popup_close(&mut self.internal as *mut nk_context);
4488        }
4489    }
4490
4491    pub fn popup_end(&mut self) {
4492        unsafe {
4493            nk_popup_end(&mut self.internal as *mut nk_context);
4494        }
4495    }
4496
4497    pub fn combo(&mut self, items: &mut StringArray, selected: i32, item_height: i32, size: Vec2) -> i32 {
4498        unsafe { nk_combo(&mut self.internal as *mut nk_context, items.as_mut(), items.len() as i32, selected, item_height, size) }
4499    }
4500
4501    pub fn combo_separator(&mut self, items_separated_by_separator: String, separator: char, selected: i32, item_height: i32, size: Vec2) -> i32 {
4502        let len = ::std::string::String::from_utf8_lossy(items_separated_by_separator.bytes.as_ref()).as_ref().split(separator).count();
4503        unsafe { nk_combo_separator(&mut self.internal as *mut nk_context, items_separated_by_separator.as_ptr(), separator as i32, selected, len as i32, item_height, size) }
4504    }
4505
4506    pub fn combo_begin_label(&mut self, selected: String, size: Vec2) -> bool {
4507        unsafe { nk_combo_begin_label(&mut self.internal as *mut nk_context, selected.as_ptr(), size) > 0 }
4508    }
4509
4510    pub fn combo_begin_text(&mut self, selected: &str, size: Vec2) -> bool {
4511        unsafe { nk_combo_begin_text(&mut self.internal as *mut nk_context, selected.as_ptr() as *const i8, selected.as_bytes().len() as i32, size) > 0 }
4512    }
4513
4514    pub fn combo_begin_color(&mut self, color: Color, size: Vec2) -> bool {
4515        unsafe { nk_combo_begin_color(&mut self.internal as *mut nk_context, color, size) > 0 }
4516    }
4517
4518    pub fn combo_begin_symbol(&mut self, sym: SymbolType, size: Vec2) -> bool {
4519        unsafe { nk_combo_begin_symbol(&mut self.internal as *mut nk_context, sym.into(), size) > 0 }
4520    }
4521
4522    pub fn combo_begin_symbol_label(&mut self, label: String, sym: SymbolType, size: Vec2) -> bool {
4523        unsafe { nk_combo_begin_symbol_label(&mut self.internal as *mut nk_context, label.as_ptr(), sym.into(), size) > 0 }
4524    }
4525
4526    pub fn combo_begin_symbol_text(&mut self, label: &str, sym: SymbolType, size: Vec2) -> bool {
4527        unsafe { nk_combo_begin_symbol_text(&mut self.internal as *mut nk_context, label.as_ptr() as *const i8, label.as_bytes().len() as i32, sym.into(), size) > 0 }
4528    }
4529
4530    pub fn combo_begin_image(&mut self, img: Image, size: Vec2) -> bool {
4531        unsafe { nk_combo_begin_image(&mut self.internal as *mut nk_context, img.internal, size) > 0 }
4532    }
4533
4534    pub fn combo_begin_image_label(&mut self, label: String, img: Image, size: Vec2) -> bool {
4535        unsafe { nk_combo_begin_image_label(&mut self.internal as *mut nk_context, label.as_ptr(), img.internal, size) > 0 }
4536    }
4537
4538    pub fn combo_begin_image_text(&mut self, label: &str, img: Image, size: Vec2) -> bool {
4539        unsafe { nk_combo_begin_image_text(&mut self.internal as *mut nk_context, label.as_ptr() as *const i8, label.as_bytes().len() as i32, img.internal, size) > 0 }
4540    }
4541
4542    pub fn combo_item_label(&mut self, label: String, alignment: Flags) -> bool {
4543        unsafe { nk_combo_item_label(&mut self.internal as *mut nk_context, label.as_ptr(), alignment) > 0 }
4544    }
4545
4546    pub fn combo_item_text(&mut self, label: &str, alignment: Flags) -> bool {
4547        unsafe { nk_combo_item_text(&mut self.internal as *mut nk_context, label.as_ptr() as *const i8, label.as_bytes().len() as i32, alignment) > 0 }
4548    }
4549
4550    pub fn combo_item_image_label(&mut self, img: Image, label: String, alignment: Flags) -> bool {
4551        unsafe { nk_combo_item_image_label(&mut self.internal as *mut nk_context, img.internal, label.as_ptr(), alignment) > 0 }
4552    }
4553
4554    pub fn combo_item_image_text(&mut self, img: Image, label: &str, alignment: Flags) -> bool {
4555        unsafe { nk_combo_item_image_text(&mut self.internal as *mut nk_context, img.internal, label.as_ptr() as *const i8, label.as_bytes().len() as i32, alignment) > 0 }
4556    }
4557
4558    pub fn combo_item_symbol_label(&mut self, sym: SymbolType, label: String, alignment: Flags) -> bool {
4559        unsafe { nk_combo_item_symbol_label(&mut self.internal as *mut nk_context, sym.into(), label.as_ptr(), alignment) > 0 }
4560    }
4561
4562    pub fn combo_item_symbol_text(&mut self, sym: SymbolType, label: &str, alignment: Flags) -> bool {
4563        unsafe { nk_combo_item_symbol_text(&mut self.internal as *mut nk_context, sym.into(), label.as_ptr() as *const i8, label.as_bytes().len() as i32, alignment) > 0 }
4564    }
4565
4566    pub fn combo_close(&mut self) {
4567        unsafe {
4568            nk_combo_close(&mut self.internal as *mut nk_context);
4569        }
4570    }
4571
4572    pub fn combo_end(&mut self) {
4573        unsafe {
4574            nk_combo_end(&mut self.internal as *mut nk_context);
4575        }
4576    }
4577
4578    pub fn contextual_begin(&mut self, flags: Flags, bounds: Vec2, trigger_bounds: Rect) -> bool {
4579        unsafe { nk_contextual_begin(&mut self.internal as *mut nk_context, flags, bounds, trigger_bounds) > 0 }
4580    }
4581
4582    pub fn contextual_item_label(&mut self, label: String, align: Flags) -> bool {
4583        unsafe { nk_contextual_item_label(&mut self.internal as *mut nk_context, label.as_ptr(), align) > 0 }
4584    }
4585
4586    pub fn contextual_item_text(&mut self, label: &str, align: Flags) -> bool {
4587        unsafe { nk_contextual_item_text(&mut self.internal as *mut nk_context, label.as_ptr() as *const i8, label.as_bytes().len() as i32, align) > 0 }
4588    }
4589
4590    pub fn contextual_item_image_label(&mut self, img: Image, label: String, align: Flags) -> bool {
4591        unsafe { nk_contextual_item_image_label(&mut self.internal as *mut nk_context, img.internal, label.as_ptr(), align) > 0 }
4592    }
4593
4594    pub fn contextual_item_image_text(&mut self, img: Image, label: &str, align: Flags) -> bool {
4595        unsafe { nk_contextual_item_image_text(&mut self.internal as *mut nk_context, img.internal, label.as_ptr() as *const i8, label.as_bytes().len() as i32, align) > 0 }
4596    }
4597
4598    pub fn contextual_item_symbol_label(&mut self, sym: SymbolType, label: String, align: Flags) -> bool {
4599        unsafe { nk_contextual_item_symbol_label(&mut self.internal as *mut nk_context, sym.into(), label.as_ptr(), align) > 0 }
4600    }
4601
4602    pub fn contextual_item_symbol_text(&mut self, sym: SymbolType, label: &str, align: Flags) -> bool {
4603        unsafe { nk_contextual_item_symbol_text(&mut self.internal as *mut nk_context, sym.into(), label.as_ptr() as *const i8, label.as_bytes().len() as i32, align) > 0 }
4604    }
4605
4606    pub fn contextual_close(&mut self) {
4607        unsafe {
4608            nk_contextual_close(&mut self.internal as *mut nk_context);
4609        }
4610    }
4611
4612    pub fn contextual_end(&mut self) {
4613        unsafe {
4614            nk_contextual_end(&mut self.internal as *mut nk_context);
4615        }
4616    }
4617
4618    pub fn tooltip(&mut self, text: String) {
4619        unsafe {
4620            nk_tooltip(&mut self.internal as *mut nk_context, text.as_ptr());
4621        }
4622    }
4623
4624    pub fn tooltip_begin(&mut self, width: f32) -> bool {
4625        unsafe { nk_tooltip_begin(&mut self.internal as *mut nk_context, width) > 0 }
4626    }
4627
4628    pub fn tooltip_end(&mut self) {
4629        unsafe {
4630            nk_tooltip_end(&mut self.internal as *mut nk_context);
4631        }
4632    }
4633
4634    pub fn menubar_begin(&mut self) {
4635        unsafe {
4636            nk_menubar_begin(&mut self.internal as *mut nk_context);
4637        }
4638    }
4639
4640    pub fn menubar_end(&mut self) {
4641        unsafe {
4642            nk_menubar_end(&mut self.internal as *mut nk_context);
4643        }
4644    }
4645
4646    pub fn menu_begin_label(&mut self, title: String, align: Flags, size: Vec2) -> bool {
4647        unsafe { nk_menu_begin_label(&mut self.internal as *mut nk_context, title.as_ptr(), align, size) > 0 }
4648    }
4649
4650    pub fn menu_begin_text(&mut self, title: &str, align: Flags, size: Vec2) -> bool {
4651        unsafe { nk_menu_begin_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.len() as i32, align, size) > 0 }
4652    }
4653
4654    pub fn menu_begin_image(&mut self, title: String, img: Image, size: Vec2) -> bool {
4655        unsafe { nk_menu_begin_image(&mut self.internal as *mut nk_context, title.as_ptr(), img.internal, size) > 0 }
4656    }
4657
4658    pub fn menu_begin_image_label(&mut self, title: String, align: Flags, img: Image, size: Vec2) -> bool {
4659        unsafe { nk_menu_begin_image_label(&mut self.internal as *mut nk_context, title.as_ptr(), align, img.internal, size) > 0 }
4660    }
4661
4662    pub fn menu_begin_image_text(&mut self, title: &str, align: Flags, img: Image, size: Vec2) -> bool {
4663        unsafe { nk_menu_begin_image_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.len() as i32, align, img.internal, size) > 0 }
4664    }
4665
4666    pub fn menu_begin_symbol(&mut self, title: String, sym: SymbolType, size: Vec2) -> bool {
4667        unsafe { nk_menu_begin_symbol(&mut self.internal as *mut nk_context, title.as_ptr(), sym.into(), size) > 0 }
4668    }
4669
4670    pub fn menu_begin_symbol_label(&mut self, title: String, align: Flags, sym: SymbolType, size: Vec2) -> bool {
4671        unsafe { nk_menu_begin_symbol_label(&mut self.internal as *mut nk_context, title.as_ptr(), align, sym.into(), size) > 0 }
4672    }
4673
4674    pub fn menu_begin_symbol_text(&mut self, title: &str, align: Flags, sym: SymbolType, size: Vec2) -> bool {
4675        unsafe { nk_menu_begin_symbol_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.len() as i32, align, sym.into(), size) > 0 }
4676    }
4677
4678    pub fn menu_item_label(&mut self, title: String, align: Flags) -> bool {
4679        unsafe { nk_menu_item_label(&mut self.internal as *mut nk_context, title.as_ptr(), align) > 0 }
4680    }
4681
4682    pub fn menu_item_text(&mut self, title: &str, align: Flags) -> bool {
4683        unsafe { nk_menu_item_text(&mut self.internal as *mut nk_context, title.as_ptr() as *const i8, title.len() as i32, align) > 0 }
4684    }
4685
4686    pub fn menu_item_image_label(&mut self, img: Image, title: String, align: Flags) -> bool {
4687        unsafe { nk_menu_item_image_label(&mut self.internal as *mut nk_context, img.internal, title.as_ptr(), align) > 0 }
4688    }
4689
4690    pub fn menu_item_image_text(&mut self, img: Image, title: &str, align: Flags) -> bool {
4691        unsafe { nk_menu_item_image_text(&mut self.internal as *mut nk_context, img.internal, title.as_ptr() as *const i8, title.len() as i32, align) > 0 }
4692    }
4693
4694    pub fn menu_item_symbol_label(&mut self, sym: SymbolType, title: String, align: Flags) -> bool {
4695        unsafe { nk_menu_item_symbol_label(&mut self.internal as *mut nk_context, sym.into(), title.as_ptr(), align) > 0 }
4696    }
4697
4698    pub fn menu_item_symbol_text(&mut self, sym: SymbolType, title: &str, align: Flags) -> bool {
4699        unsafe { nk_menu_item_symbol_text(&mut self.internal as *mut nk_context, sym.into(), title.as_ptr() as *const i8, title.len() as i32, align) > 0 }
4700    }
4701
4702    pub fn menu_close(&mut self) {
4703        unsafe {
4704            nk_menu_close(&mut self.internal as *mut nk_context);
4705        }
4706    }
4707
4708    pub fn menu_end(&mut self) {
4709        unsafe {
4710            nk_menu_end(&mut self.internal as *mut nk_context);
4711        }
4712    }
4713
4714    pub fn convert(&mut self, cmds: &mut Buffer, vertices: &mut Buffer, elements: &mut Buffer, config: &ConvertConfig) {
4715        unsafe {
4716            nk_convert(
4717                &mut self.internal as *mut nk_context,
4718                &mut cmds.internal as *mut nk_buffer,
4719                &mut vertices.internal as *mut nk_buffer,
4720                &mut elements.internal as *mut nk_buffer,
4721                &config.internal as *const nk_convert_config,
4722            );
4723        }
4724    }
4725
4726    pub fn input_begin(&mut self) {
4727        unsafe {
4728            nk_input_begin(&mut self.internal as *mut nk_context);
4729        }
4730    }
4731
4732    pub fn input_motion(&mut self, x: i32, y: i32) {
4733        unsafe {
4734            nk_input_motion(&mut self.internal as *mut nk_context, x, y);
4735        }
4736    }
4737
4738    pub fn input_key(&mut self, key: Key, down: bool) {
4739        unsafe {
4740            nk_input_key(&mut self.internal as *mut nk_context, key.into(), if down { 1 } else { 0 });
4741        }
4742    }
4743
4744    pub fn input_button(&mut self, b: Button, x: i32, y: i32, down: bool) {
4745        unsafe {
4746            nk_input_button(&mut self.internal as *mut nk_context, b.into(), x, y, if down { 1 } else { 0 });
4747        }
4748    }
4749
4750    pub fn input_scroll(&mut self, y: Vec2) {
4751        unsafe {
4752            nk_input_scroll(&mut self.internal as *mut nk_context, y);
4753        }
4754    }
4755
4756    pub fn input_char(&mut self, c: u8) {
4757        unsafe {
4758            nk_input_char(&mut self.internal as *mut nk_context, c as i8);
4759        }
4760    }
4761
4762    pub fn input_glyph(&mut self, g: Glyph) {
4763        unsafe {
4764            nk_input_glyph(&mut self.internal as *mut nk_context, &g[0] as *const _ as *mut i8);
4765        }
4766    }
4767
4768    pub fn input_unicode(&mut self, r: char) {
4769        unsafe {
4770            nk_input_unicode(&mut self.internal as *mut nk_context, r as u32);
4771        }
4772    }
4773
4774    pub fn input_end(&mut self) {
4775        unsafe {
4776            nk_input_end(&mut self.internal as *mut nk_context);
4777        }
4778    }
4779
4780    pub fn style_default(&mut self) {
4781        unsafe {
4782            nk_style_default(&mut self.internal as *mut nk_context);
4783        }
4784    }
4785
4786    pub fn style_from_table(&mut self, table: &ColorMap) {
4787        unsafe {
4788            nk_style_from_table(&mut self.internal as *mut nk_context, &table.internal[0] as *const nk_color);
4789        }
4790    }
4791
4792    pub fn style_load_cursor(&mut self, cur: StyleCursor, res: &Cursor) {
4793        unsafe {
4794            nk_style_load_cursor(&mut self.internal as *mut nk_context, cur, &res.internal);
4795        }
4796    }
4797
4798    pub fn style_load_all_cursors(&mut self, table: &mut CursorMap) {
4799        unsafe {
4800            nk_style_load_all_cursors(&mut self.internal as *mut nk_context, table.internal.as_mut_ptr() as *mut nk_cursor);
4801        }
4802    }
4803
4804    pub fn style_set_font(&mut self, font: &UserFont) {
4805        unsafe {
4806            nk_style_set_font(&mut self.internal as *mut nk_context, &font.internal);
4807        }
4808    }
4809
4810    pub fn style_set_cursor(&mut self, cur: StyleCursor) -> bool {
4811        unsafe { nk_style_set_cursor(&mut self.internal as *mut nk_context, cur) > 0 }
4812    }
4813
4814    pub fn style_show_cursor(&mut self) {
4815        unsafe {
4816            nk_style_show_cursor(&mut self.internal as *mut nk_context);
4817        }
4818    }
4819
4820    pub fn style_hide_cursor(&mut self) {
4821        unsafe {
4822            nk_style_hide_cursor(&mut self.internal as *mut nk_context);
4823        }
4824    }
4825
4826    pub fn style_push_font(&mut self, font: &mut UserFont) -> bool {
4827        unsafe { nk_style_push_font(&mut self.internal as *mut nk_context, &mut font.internal) > 0 }
4828    }
4829
4830    pub fn style_push_float(&mut self, addr: &mut f32, val: f32) -> bool {
4831        unsafe { nk_style_push_float(&mut self.internal as *mut nk_context, addr as *mut f32, val) > 0 }
4832    }
4833
4834    pub fn style_push_vec2(&mut self, addr: &mut Vec2, val: Vec2) -> bool {
4835        unsafe { nk_style_push_vec2(&mut self.internal as *mut nk_context, addr as *mut nk_vec2, val) > 0 }
4836    }
4837
4838    pub fn style_push_style_item(&mut self, addr: &mut StyleItem, val: StyleItem) -> bool {
4839        unsafe { nk_style_push_style_item(&mut self.internal as *mut nk_context, &mut addr.internal as *mut nk_style_item, val.internal) > 0 }
4840    }
4841
4842    pub fn style_push_flags(&mut self, addr: &mut Flags, val: Flags) -> bool {
4843        unsafe { nk_style_push_flags(&mut self.internal as *mut nk_context, addr as *mut nk_flags, val) > 0 }
4844    }
4845
4846    pub fn style_push_color(&mut self, addr: &mut Color, val: Color) -> bool {
4847        unsafe { nk_style_push_color(&mut self.internal as *mut nk_context, addr as *mut nk_color, val) > 0 }
4848    }
4849
4850    pub fn style_pop_font(&mut self) -> bool {
4851        unsafe { nk_style_pop_font(&mut self.internal as *mut nk_context) > 0 }
4852    }
4853
4854    pub fn style_pop_float(&mut self) -> bool {
4855        unsafe { nk_style_pop_float(&mut self.internal as *mut nk_context) > 0 }
4856    }
4857
4858    pub fn style_pop_vec2(&mut self) -> bool {
4859        unsafe { nk_style_pop_vec2(&mut self.internal as *mut nk_context) > 0 }
4860    }
4861
4862    pub fn style_pop_style_item(&mut self) -> bool {
4863        unsafe { nk_style_pop_style_item(&mut self.internal as *mut nk_context) > 0 }
4864    }
4865
4866    pub fn style_pop_flags(&mut self) -> bool {
4867        unsafe { nk_style_pop_flags(&mut self.internal as *mut nk_context) > 0 }
4868    }
4869
4870    pub fn style_pop_color(&mut self) -> bool {
4871        unsafe { nk_style_pop_color(&mut self.internal as *mut nk_context) > 0 }
4872    }
4873
4874    pub fn widget_bounds(&mut self) -> Rect {
4875        unsafe { nk_widget_bounds(&mut self.internal as *mut nk_context) }
4876    }
4877
4878    pub fn widget_position(&mut self) -> Vec2 {
4879        unsafe { nk_widget_position(&mut self.internal as *mut nk_context) }
4880    }
4881
4882    pub fn widget_size(&mut self) -> Vec2 {
4883        unsafe { nk_widget_size(&mut self.internal as *mut nk_context) }
4884    }
4885
4886    pub fn widget_width(&mut self) -> f32 {
4887        unsafe { nk_widget_width(&mut self.internal as *mut nk_context) }
4888    }
4889    pub fn widget_height(&mut self) -> f32 {
4890        unsafe { nk_widget_height(&mut self.internal as *mut nk_context) }
4891    }
4892
4893    pub fn widget_is_hovered(&mut self) -> bool {
4894        unsafe { nk_widget_is_hovered(&mut self.internal as *mut nk_context) > 0 }
4895    }
4896
4897    pub fn widget_is_mouse_clicked(&mut self, b: Button) -> bool {
4898        unsafe { nk_widget_is_mouse_clicked(&mut self.internal as *mut nk_context, b.into()) > 0 }
4899    }
4900
4901    pub fn widget_has_mouse_click_down(&mut self, b: Button, down: bool) -> bool {
4902        unsafe { nk_widget_has_mouse_click_down(&mut self.internal as *mut nk_context, b.into(), if down { 1 } else { 0 }) > 0 }
4903    }
4904
4905    pub fn widget(&self, arg1: &mut Rect) -> WidgetLayoutState {
4906        unsafe { nk_widget(arg1, &self.internal as *const nk_context) }
4907    }
4908
4909    pub fn spacing(&mut self, cols: i32) {
4910        unsafe {
4911            nk_spacing(&mut self.internal as *mut nk_context, cols);
4912        }
4913    }
4914
4915    pub fn draw_begin(&self, buf: &Buffer) -> Option<&DrawCommand> {
4916        let n = unsafe { nk__draw_begin(&self.internal, &buf.internal) };
4917
4918        unsafe {
4919            if n.is_null() {
4920                None
4921            } else {
4922                Some(::std::mem::transmute(n))
4923            }
4924        }
4925    }
4926    pub fn draw_next<'a>(&self, prev: &DrawCommand, buf: &Buffer) -> Option<&'a DrawCommand> {
4927        let n = unsafe { nk__draw_next(&prev.internal, &buf.internal, &self.internal) };
4928
4929        unsafe {
4930            if n.is_null() {
4931                None
4932            } else {
4933                Some(::std::mem::transmute(n))
4934            }
4935        }
4936    }
4937
4938    pub fn next_cmd<'a, 'b>(&self, arg2: &'b Command) -> Option<&'a Command> {
4939        let r = unsafe { nk__next(&self.internal as *const _ as *mut nk_context, &arg2.internal) };
4940        unsafe {
4941            if r.is_null() {
4942                None
4943            } else {
4944                Some(::std::mem::transmute(r))
4945            }
4946        }
4947    }
4948
4949    pub fn begin_cmd(&self) -> Option<&Command> {
4950        let r = unsafe { nk__begin(&self.internal as *const _ as *mut nk_context) };
4951        unsafe {
4952            if r.is_null() {
4953                None
4954            } else {
4955                Some(::std::mem::transmute(r))
4956            }
4957        }
4958    }
4959
4960    pub fn draw_command_iterator<'a>(&'a mut self, buf: &'a Buffer) -> DrawCommandIterator<'a> {
4961        DrawCommandIterator { ctx: self, buf }
4962    }
4963
4964    pub fn command_iterator(&mut self) -> CommandIterator {
4965        CommandIterator { ctx: self }
4966    }
4967}
4968
4969// ============================================================================================
4970
4971pub struct CommandIterator<'a> {
4972    ctx: &'a Context,
4973}
4974
4975impl<'a> IntoIterator for CommandIterator<'a> {
4976    type Item = &'a Command;
4977    type IntoIter = CommandIntoIter<'a>;
4978
4979    fn into_iter(self) -> Self::IntoIter {
4980        let cmd = self.ctx.begin_cmd();
4981        CommandIntoIter { ctx: self.ctx, cmd }
4982    }
4983}
4984
4985pub struct CommandIntoIter<'a> {
4986    ctx: &'a Context,
4987    cmd: Option<&'a Command>,
4988}
4989
4990impl<'a> Iterator for CommandIntoIter<'a> {
4991    type Item = &'a Command;
4992    fn next(&mut self) -> Option<&'a Command> {
4993        let r = self.cmd;
4994
4995        self.cmd = if let Some(p) = self.cmd { self.ctx.next_cmd(p) } else { None };
4996
4997        r
4998    }
4999}
5000
5001// ============================================================================================
5002
5003pub struct DrawCommandIterator<'a> {
5004    ctx: &'a mut Context,
5005    buf: &'a Buffer,
5006}
5007
5008impl<'a> IntoIterator for DrawCommandIterator<'a> {
5009    type Item = &'a DrawCommand;
5010    type IntoIter = DrawCommandIntoIter<'a>;
5011
5012    fn into_iter(self) -> Self::IntoIter {
5013        let cmd = self.ctx.draw_begin(self.buf);
5014        DrawCommandIntoIter { ctx: self.ctx, buf: self.buf, cmd }
5015    }
5016}
5017
5018pub struct DrawCommandIntoIter<'a> {
5019    ctx: &'a Context,
5020    buf: &'a Buffer,
5021    cmd: Option<&'a DrawCommand>,
5022}
5023
5024impl<'a> Iterator for DrawCommandIntoIter<'a> {
5025    type Item = &'a DrawCommand;
5026    fn next(&mut self) -> Option<&'a DrawCommand> {
5027        let r = self.cmd;
5028
5029        self.cmd = if let Some(ref p) = self.cmd { self.ctx.draw_next(p, self.buf) } else { None };
5030
5031        r
5032    }
5033}
5034
5035// =============================================================================================
5036
5037wrapper_type_no_clone!(Window, nk_window);
5038
5039impl Window {
5040    pub fn seq(&self) -> u32 {
5041        self.internal.seq
5042    }
5043    pub fn name(&self) -> &str {
5044        unsafe {
5045            let name = ::std::mem::transmute::<&[i8], &[u8]>(&self.internal.name_string);
5046            let mut len = name.len();
5047            let mut ch = 0;
5048            while ch == 0 && len > 0 {
5049                len -= 1;
5050                ch = name[len];
5051            }
5052            if len < name.len() {
5053                len += 1;
5054            }
5055            ::std::str::from_utf8_unchecked(&name[0..len])
5056        }
5057    }
5058    pub fn flags(&self) -> &Flags {
5059        &self.internal.flags
5060    }
5061    pub fn bounds(&self) -> &Rect {
5062        &self.internal.bounds
5063    }
5064    pub fn scrollbar(&self) -> &Scroll {
5065        &self.internal.scrollbar
5066    }
5067    pub fn scrollbar_hiding_timer(&self) -> f32 {
5068        self.internal.scrollbar_hiding_timer
5069    }
5070    pub fn buffer(&self) -> &CommandBuffer {
5071        unsafe { ::std::mem::transmute(&self.internal.buffer) }
5072    }
5073    pub fn layout(&self) -> &Panel {
5074        unsafe { ::std::mem::transmute(self.internal.layout) }
5075    }
5076    pub fn layout_mut(&mut self) -> &mut Panel {
5077        unsafe { ::std::mem::transmute(self.internal.layout) }
5078    }
5079    pub fn property(&self) -> &PropertyState {
5080        unsafe { ::std::mem::transmute(&self.internal.property) }
5081    }
5082    pub fn popup(&self) -> &PopupState {
5083        unsafe { ::std::mem::transmute(&self.internal.popup) }
5084    }
5085    pub fn edit(&self) -> &EditState {
5086        unsafe { ::std::mem::transmute(&self.internal.edit) }
5087    }
5088    pub fn scrolled(&self) -> u32 {
5089        self.internal.scrolled
5090    }
5091    pub fn tables(&self) -> &[Table] {
5092        unsafe { ::std::slice::from_raw_parts(self.internal.tables as *mut _ as *const Table, self.internal.table_count as usize) }
5093    }
5094    pub fn prev(&self) -> &Window {
5095        unsafe { ::std::mem::transmute(self.internal.prev) }
5096    }
5097    pub fn next(&self) -> &Window {
5098        unsafe { ::std::mem::transmute(self.internal.next) }
5099    }
5100    pub fn parent(&self) -> &Window {
5101        unsafe { ::std::mem::transmute(self.internal.parent) }
5102    }
5103
5104    pub fn set_flags(&mut self, flags: Flags) {
5105        self.internal.flags = flags;
5106    }
5107    pub fn set_bounds(&mut self, rect: Rect) {
5108        self.internal.bounds = rect;
5109    }
5110    pub fn set_scrollbar(&mut self, scroll: Scroll) {
5111        self.internal.scrollbar = scroll;
5112    }
5113    pub fn set_scrollbar_hiding_timer(&mut self, value: f32) {
5114        self.internal.scrollbar_hiding_timer = value;
5115    }
5116}
5117
5118wrapper_type_no_clone!(PropertyState, nk_property_state);
5119wrapper_type!(PopupState, nk_popup_state);
5120wrapper_type!(EditState, nk_edit_state);
5121wrapper_type_no_clone!(Table, nk_table);
5122
5123// =============================================================================================
5124
5125wrapper_type!(RowLayout, nk_row_layout);
5126
5127impl RowLayout {
5128    pub fn layout_type(&self) -> &PanelRowLayoutType {
5129        &self.internal.type_
5130    }
5131    pub fn layout_type_mut(&mut self) -> &mut PanelRowLayoutType {
5132        &mut self.internal.type_
5133    }
5134
5135    pub fn index(&self) -> i32 {
5136        self.internal.index
5137    }
5138    pub fn set_index(&mut self, i: i32) {
5139        self.internal.index = i
5140    }
5141
5142    pub fn height(&self) -> f32 {
5143        self.internal.height
5144    }
5145    pub fn set_height(&mut self, i: f32) {
5146        self.internal.height = i
5147    }
5148
5149    pub fn columns(&self) -> i32 {
5150        self.internal.columns
5151    }
5152    pub fn set_columns(&mut self, i: i32) {
5153        self.internal.columns = i
5154    }
5155
5156    pub fn ratio(&self) -> &f32 {
5157        unsafe { &*self.internal.ratio }
5158    }
5159
5160    pub fn item_width(&self) -> f32 {
5161        self.internal.item_width
5162    }
5163    pub fn set_item_width(&mut self, i: f32) {
5164        self.internal.item_width = i
5165    }
5166
5167    pub fn item_height(&self) -> f32 {
5168        self.internal.item_height
5169    }
5170    pub fn set_item_height(&mut self, i: f32) {
5171        self.internal.item_height = i
5172    }
5173
5174    pub fn item_offset(&self) -> f32 {
5175        self.internal.item_offset
5176    }
5177    pub fn set_item_offset(&mut self, i: f32) {
5178        self.internal.item_offset = i
5179    }
5180
5181    pub fn filled(&self) -> f32 {
5182        self.internal.filled
5183    }
5184    pub fn set_filled(&mut self, i: f32) {
5185        self.internal.filled = i
5186    }
5187
5188    pub fn item(&self) -> &Rect {
5189        &self.internal.item
5190    }
5191    pub fn item_mut(&mut self) -> &mut Rect {
5192        &mut self.internal.item
5193    }
5194
5195    pub fn tree_depth(&self) -> i32 {
5196        self.internal.tree_depth
5197    }
5198    pub fn set_tree_depth(&mut self, i: i32) {
5199        self.internal.tree_depth = i
5200    }
5201
5202    pub fn templates(&self) -> &[f32] {
5203        &self.internal.templates
5204    }
5205    pub fn templates_mut(&mut self) -> &mut [f32] {
5206        &mut self.internal.templates
5207    }
5208}
5209
5210// =============================================================================================
5211
5212wrapper_type!(Panel, nk_panel);
5213
5214impl Panel {
5215    pub fn bounds(&self) -> &Rect {
5216        &self.internal.bounds
5217    }
5218    pub fn bounds_mut(&mut self) -> &mut Rect {
5219        &mut self.internal.bounds
5220    }
5221    pub fn set_bounds(&mut self, b: Rect) {
5222        self.internal.bounds = b
5223    }
5224
5225    pub fn panel_type(&self) -> &PanelType {
5226        &self.internal.type_
5227    }
5228    pub fn panel_type_mut(&mut self) -> &mut PanelType {
5229        &mut self.internal.type_
5230    }
5231    pub fn set_panel_type(&mut self, t: PanelType) {
5232        self.internal.type_ = t
5233    }
5234
5235    pub fn flags(&self) -> &Flags {
5236        &self.internal.flags
5237    }
5238    pub fn flags_mut(&mut self) -> &mut Flags {
5239        &mut self.internal.flags
5240    }
5241    pub fn set_flags(&mut self, f: Flags) {
5242        self.internal.flags = f
5243    }
5244
5245    pub fn offset_x(&self) -> u32 {
5246        unsafe { *self.internal.offset_x }
5247    }
5248    pub fn set_offset_x(&mut self, o: u32) {
5249        unsafe { *self.internal.offset_x = o }
5250    }
5251
5252    pub fn offset_y(&self) -> u32 {
5253        unsafe { *self.internal.offset_y }
5254    }
5255    pub fn set_offset_y(&mut self, o: u32) {
5256        unsafe { *self.internal.offset_y = o }
5257    }
5258
5259    pub fn at_x(&self) -> f32 {
5260        self.internal.at_x
5261    }
5262    pub fn set_at_x(&mut self, f: f32) {
5263        self.internal.at_x = f
5264    }
5265
5266    pub fn at_y(&self) -> f32 {
5267        self.internal.at_y
5268    }
5269    pub fn set_at_y(&mut self, f: f32) {
5270        self.internal.at_y = f
5271    }
5272
5273    pub fn max_x(&self) -> f32 {
5274        self.internal.max_x
5275    }
5276    pub fn set_max_x(&mut self, f: f32) {
5277        self.internal.max_x = f
5278    }
5279
5280    pub fn footer_height(&self) -> f32 {
5281        self.internal.footer_height
5282    }
5283    pub fn set_footer_height(&mut self, f: f32) {
5284        self.internal.footer_height = f
5285    }
5286
5287    pub fn header_height(&self) -> f32 {
5288        self.internal.header_height
5289    }
5290    pub fn set_header_height(&mut self, f: f32) {
5291        self.internal.header_height = f
5292    }
5293
5294    pub fn border(&self) -> f32 {
5295        self.internal.border
5296    }
5297    pub fn set_border(&mut self, f: f32) {
5298        self.internal.border = f
5299    }
5300
5301    pub fn has_scrolling(&self) -> bool {
5302        self.internal.has_scrolling == nk_true as u32
5303    }
5304    pub fn set_has_scrolling(&mut self, f: bool) {
5305        self.internal.has_scrolling = if f { nk_true as u32 } else { nk_false as u32 }
5306    }
5307
5308    pub fn clip(&self) -> &Rect {
5309        &self.internal.clip
5310    }
5311    pub fn clip_mut(&mut self) -> &mut Rect {
5312        &mut self.internal.clip
5313    }
5314    pub fn set_clip(&mut self, f: Rect) {
5315        self.internal.clip = f
5316    }
5317
5318    pub fn menu(&self) -> &MenuState {
5319        &self.internal.menu
5320    }
5321    pub fn menu_mut(&mut self) -> &mut MenuState {
5322        &mut self.internal.menu
5323    }
5324    pub fn set_menu(&mut self, f: MenuState) {
5325        self.internal.menu = f
5326    }
5327
5328    pub fn row(&self) -> &RowLayout {
5329        unsafe { ::std::mem::transmute(&self.internal.row) }
5330    }
5331
5332    pub fn chart(&self) -> &Chart {
5333        unsafe { ::std::mem::transmute(&self.internal.chart) }
5334    }
5335
5336    pub fn buffer(&self) -> Option<&CommandBuffer> {
5337        unsafe {
5338            let ptr = self.internal.buffer;
5339            if !ptr.is_null() {
5340                Some(::std::mem::transmute(ptr))
5341            } else {
5342                None
5343            }
5344        }
5345    }
5346
5347    pub fn parent(&self) -> Option<&Panel> {
5348        unsafe {
5349            let ptr = self.internal.parent;
5350            if !ptr.is_null() {
5351                Some(::std::mem::transmute(ptr))
5352            } else {
5353                None
5354            }
5355        }
5356    }
5357}
5358
5359// =============================================================================================
5360
5361wrapper_type!(Chart, nk_chart);
5362
5363impl Chart {
5364    pub fn x(&self) -> f32 {
5365        self.internal.x
5366    }
5367    pub fn set_x(&mut self, f: f32) {
5368        self.internal.x = f
5369    }
5370
5371    pub fn y(&self) -> f32 {
5372        self.internal.y
5373    }
5374    pub fn set_y(&mut self, f: f32) {
5375        self.internal.y = f
5376    }
5377
5378    pub fn w(&self) -> f32 {
5379        self.internal.w
5380    }
5381    pub fn set_w(&mut self, f: f32) {
5382        self.internal.w = f
5383    }
5384
5385    pub fn h(&self) -> f32 {
5386        self.internal.h
5387    }
5388    pub fn set_h(&mut self, f: f32) {
5389        self.internal.h = f
5390    }
5391
5392    pub fn slot(&self) -> u32 {
5393        self.internal.slot as u32
5394    }
5395
5396    pub fn slots(&self) -> &[ChartSlot] {
5397        &self.internal.slots
5398    }
5399}
5400
5401// =============================================================================================
5402
5403macro_rules! emit_nk_command {
5404    ($rs_ty:ident, $nat_ty:ty) => {
5405        wrapper_type!($rs_ty, $nat_ty);
5406
5407        impl AsRef<$rs_ty> for Command {
5408            fn as_ref(&self) -> &$rs_ty {
5409                unsafe { ::std::mem::transmute(&self.internal) }
5410            }
5411        }
5412
5413        impl $rs_ty {
5414            pub fn header(&self) -> &Command {
5415                unsafe { ::std::mem::transmute(&self.internal.header) }
5416            }
5417        }
5418    };
5419}
5420
5421wrapper_type!(Command, nk_command);
5422
5423impl Command {
5424    pub fn get_type(&self) -> CommandType {
5425        self.internal.type_.into()
5426    }
5427}
5428
5429emit_nk_command!(CommandScissor, nk_command_scissor);
5430impl CommandScissor {
5431    pub fn x(&self) -> i16 {
5432        self.internal.x
5433    }
5434    pub fn y(&self) -> i16 {
5435        self.internal.y
5436    }
5437    pub fn w(&self) -> u16 {
5438        self.internal.w
5439    }
5440    pub fn h(&self) -> u16 {
5441        self.internal.h
5442    }
5443}
5444
5445emit_nk_command!(CommandLine, nk_command_line);
5446impl CommandLine {
5447    pub fn line_thickness(&self) -> u16 {
5448        self.internal.line_thickness
5449    }
5450    pub fn begin(&self) -> Vec2i {
5451        self.internal.begin
5452    }
5453    pub fn end(&self) -> Vec2i {
5454        self.internal.end
5455    }
5456    pub fn color(&self) -> Color {
5457        self.internal.color
5458    }
5459}
5460
5461emit_nk_command!(CommandCurve, nk_command_curve);
5462impl CommandCurve {
5463    pub fn line_thickness(&self) -> u16 {
5464        self.internal.line_thickness
5465    }
5466    pub fn begin(&self) -> Vec2i {
5467        self.internal.begin
5468    }
5469    pub fn end(&self) -> Vec2i {
5470        self.internal.end
5471    }
5472    pub fn color(&self) -> Color {
5473        self.internal.color
5474    }
5475    pub fn ctrl(&self) -> &[Vec2i] {
5476        &self.internal.ctrl
5477    }
5478}
5479
5480emit_nk_command!(CommandRect, nk_command_rect);
5481impl CommandRect {
5482    pub fn line_thickness(&self) -> u16 {
5483        self.internal.line_thickness
5484    }
5485    pub fn rounding(&self) -> u16 {
5486        self.internal.rounding
5487    }
5488    pub fn color(&self) -> Color {
5489        self.internal.color
5490    }
5491    pub fn x(&self) -> i16 {
5492        self.internal.x
5493    }
5494    pub fn y(&self) -> i16 {
5495        self.internal.y
5496    }
5497    pub fn w(&self) -> u16 {
5498        self.internal.w
5499    }
5500    pub fn h(&self) -> u16 {
5501        self.internal.h
5502    }
5503}
5504
5505emit_nk_command!(CommandRectFilled, nk_command_rect_filled);
5506impl CommandRectFilled {
5507    pub fn rounding(&self) -> u16 {
5508        self.internal.rounding
5509    }
5510    pub fn color(&self) -> Color {
5511        self.internal.color
5512    }
5513    pub fn x(&self) -> i16 {
5514        self.internal.x
5515    }
5516    pub fn y(&self) -> i16 {
5517        self.internal.y
5518    }
5519    pub fn w(&self) -> u16 {
5520        self.internal.w
5521    }
5522    pub fn h(&self) -> u16 {
5523        self.internal.h
5524    }
5525}
5526
5527emit_nk_command!(CommandRectMultiColor, nk_command_rect_multi_color);
5528impl CommandRectMultiColor {
5529    pub fn left(&self) -> Color {
5530        self.internal.left
5531    }
5532    pub fn top(&self) -> Color {
5533        self.internal.top
5534    }
5535    pub fn right(&self) -> Color {
5536        self.internal.right
5537    }
5538    pub fn bottom(&self) -> Color {
5539        self.internal.bottom
5540    }
5541    pub fn x(&self) -> i16 {
5542        self.internal.x
5543    }
5544    pub fn y(&self) -> i16 {
5545        self.internal.y
5546    }
5547    pub fn w(&self) -> u16 {
5548        self.internal.w
5549    }
5550    pub fn h(&self) -> u16 {
5551        self.internal.h
5552    }
5553}
5554
5555emit_nk_command!(CommandTriangle, nk_command_triangle);
5556impl CommandTriangle {
5557    pub fn line_thickness(&self) -> u16 {
5558        self.internal.line_thickness
5559    }
5560    pub fn a(&self) -> Vec2i {
5561        self.internal.a
5562    }
5563    pub fn b(&self) -> Vec2i {
5564        self.internal.b
5565    }
5566    pub fn c(&self) -> Vec2i {
5567        self.internal.c
5568    }
5569    pub fn color(&self) -> Color {
5570        self.internal.color
5571    }
5572}
5573
5574emit_nk_command!(CommandTriangleFilled, nk_command_triangle_filled);
5575impl CommandTriangleFilled {
5576    pub fn a(&self) -> Vec2i {
5577        self.internal.a
5578    }
5579    pub fn b(&self) -> Vec2i {
5580        self.internal.b
5581    }
5582    pub fn c(&self) -> Vec2i {
5583        self.internal.c
5584    }
5585    pub fn color(&self) -> Color {
5586        self.internal.color
5587    }
5588}
5589
5590emit_nk_command!(CommandCircle, nk_command_circle);
5591impl CommandCircle {
5592    pub fn line_thickness(&self) -> u16 {
5593        self.internal.line_thickness
5594    }
5595    pub fn x(&self) -> i16 {
5596        self.internal.x
5597    }
5598    pub fn y(&self) -> i16 {
5599        self.internal.y
5600    }
5601    pub fn w(&self) -> u16 {
5602        self.internal.w
5603    }
5604    pub fn h(&self) -> u16 {
5605        self.internal.h
5606    }
5607    pub fn color(&self) -> Color {
5608        self.internal.color
5609    }
5610}
5611
5612emit_nk_command!(CommandCircleFilled, nk_command_circle_filled);
5613impl CommandCircleFilled {
5614    pub fn x(&self) -> i16 {
5615        self.internal.x
5616    }
5617    pub fn y(&self) -> i16 {
5618        self.internal.y
5619    }
5620    pub fn w(&self) -> u16 {
5621        self.internal.w
5622    }
5623    pub fn h(&self) -> u16 {
5624        self.internal.h
5625    }
5626    pub fn color(&self) -> Color {
5627        self.internal.color
5628    }
5629}
5630
5631emit_nk_command!(CommandArc, nk_command_arc);
5632impl CommandArc {
5633    pub fn cx(&self) -> i16 {
5634        self.internal.cx
5635    }
5636    pub fn cy(&self) -> i16 {
5637        self.internal.cy
5638    }
5639    pub fn r(&self) -> u16 {
5640        self.internal.r
5641    }
5642    pub fn line_thickness(&self) -> u16 {
5643        self.internal.line_thickness
5644    }
5645    pub fn a(&self) -> &[f32] {
5646        &self.internal.a
5647    }
5648    pub fn color(&self) -> Color {
5649        self.internal.color
5650    }
5651}
5652
5653emit_nk_command!(CommandArcFilled, nk_command_arc_filled);
5654impl CommandArcFilled {
5655    pub fn cx(&self) -> i16 {
5656        self.internal.cx
5657    }
5658    pub fn cy(&self) -> i16 {
5659        self.internal.cy
5660    }
5661    pub fn r(&self) -> u16 {
5662        self.internal.r
5663    }
5664    pub fn a(&self) -> &[f32] {
5665        &self.internal.a
5666    }
5667    pub fn color(&self) -> Color {
5668        self.internal.color
5669    }
5670}
5671
5672emit_nk_command!(CommandPolygon, nk_command_polygon);
5673impl CommandPolygon {
5674    pub fn line_thickness(&self) -> u16 {
5675        self.internal.line_thickness
5676    }
5677    pub fn points(&self) -> &[Vec2i] {
5678        unsafe { ::std::slice::from_raw_parts(self.internal.points.as_ptr(), self.internal.point_count as usize) }
5679    }
5680    pub fn color(&self) -> Color {
5681        self.internal.color
5682    }
5683}
5684
5685emit_nk_command!(CommandPolygonFilled, nk_command_polygon_filled);
5686impl CommandPolygonFilled {
5687    pub fn points(&self) -> &[Vec2i] {
5688        unsafe { ::std::slice::from_raw_parts(self.internal.points.as_ptr(), self.internal.point_count as usize) }
5689    }
5690    pub fn color(&self) -> Color {
5691        self.internal.color
5692    }
5693}
5694
5695emit_nk_command!(CommandPolyline, nk_command_polyline);
5696impl CommandPolyline {
5697    pub fn line_thickness(&self) -> u16 {
5698        self.internal.line_thickness
5699    }
5700    pub fn points(&self) -> &[Vec2i] {
5701        unsafe { ::std::slice::from_raw_parts(self.internal.points.as_ptr(), self.internal.point_count as usize) }
5702    }
5703    pub fn color(&self) -> Color {
5704        self.internal.color
5705    }
5706}
5707
5708emit_nk_command!(CommandImage, nk_command_image);
5709impl CommandImage {
5710    pub fn x(&self) -> i16 {
5711        self.internal.x
5712    }
5713    pub fn y(&self) -> i16 {
5714        self.internal.y
5715    }
5716    pub fn w(&self) -> u16 {
5717        self.internal.w
5718    }
5719    pub fn h(&self) -> u16 {
5720        self.internal.h
5721    }
5722    pub fn col(&self) -> Color {
5723        self.internal.col
5724    }
5725    pub fn img(&self) -> Image {
5726        Image { internal: self.internal.img }
5727    }
5728}
5729
5730emit_nk_command!(CommandText, nk_command_text);
5731impl CommandText {
5732    pub fn x(&self) -> i16 {
5733        self.internal.x
5734    }
5735    pub fn y(&self) -> i16 {
5736        self.internal.y
5737    }
5738    pub fn w(&self) -> u16 {
5739        self.internal.w
5740    }
5741    pub fn h(&self) -> u16 {
5742        self.internal.h
5743    }
5744    pub fn height(&self) -> f32 {
5745        self.internal.height
5746    }
5747    pub fn chars(&self) -> &[u8] {
5748        unsafe { ::std::slice::from_raw_parts(self.internal.string.as_ptr() as *const u8, self.internal.length as usize) }
5749    }
5750    pub fn background(&self) -> Color {
5751        self.internal.background
5752    }
5753    pub fn foreground(&self) -> Color {
5754        self.internal.foreground
5755    }
5756    pub fn font(&self) -> &UserFont {
5757        unsafe { ::std::mem::transmute(self.internal.font) }
5758    }
5759}
5760
5761// =============================================================================================
5762
5763wrapper_type!(CommandBuffer, nk_command_buffer);
5764
5765impl CommandBuffer {
5766    pub fn stroke_line(&mut self, x0: f32, y0: f32, x1: f32, y1: f32, line_thickness: f32, color: Color) {
5767        unsafe {
5768            nk_stroke_line(&mut self.internal, x0, y0, x1, y1, line_thickness, color);
5769        }
5770    }
5771
5772    pub fn stroke_curve(&mut self, x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32, line_thickness: f32, color: Color) {
5773        unsafe {
5774            nk_stroke_curve(&mut self.internal, x0, y0, x1, y1, x2, y2, x3, y3, line_thickness, color);
5775        }
5776    }
5777
5778    pub fn stroke_rect(&mut self, bounds: Rect, rounding: f32, line_thickness: f32, color: Color) {
5779        unsafe {
5780            nk_stroke_rect(&mut self.internal, bounds, rounding, line_thickness, color);
5781        }
5782    }
5783
5784    pub fn stroke_circle(&mut self, arg2: Rect, line_thickness: f32, color: Color) {
5785        unsafe {
5786            nk_stroke_circle(&mut self.internal, arg2, line_thickness, color);
5787        }
5788    }
5789
5790    pub fn stroke_arc(&mut self, cx: f32, cy: f32, radius: f32, a_min: f32, a_max: f32, line_thickness: f32, color: Color) {
5791        unsafe {
5792            nk_stroke_arc(&mut self.internal, cx, cy, radius, a_min, a_max, line_thickness, color);
5793        }
5794    }
5795
5796    pub fn stroke_triangle(&mut self, x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32, line_thichness: f32, color: Color) {
5797        unsafe {
5798            nk_stroke_triangle(&mut self.internal, x0, y0, x1, y1, x2, y2, line_thichness, color);
5799        }
5800    }
5801
5802    pub fn stroke_polyline(&mut self, points: &mut [f32], line_thickness: f32, color: Color) {
5803        unsafe {
5804            nk_stroke_polyline(&mut self.internal, &mut points[0] as *mut f32, points.len() as ::std::os::raw::c_int, line_thickness, color);
5805        }
5806    }
5807
5808    pub fn stroke_polygon(&mut self, points: &mut [f32], line_thickness: f32, color: Color) {
5809        unsafe {
5810            nk_stroke_polygon(&mut self.internal, &mut points[0] as *mut f32, points.len() as ::std::os::raw::c_int, line_thickness, color);
5811        }
5812    }
5813
5814    pub fn fill_rect(&mut self, arg2: Rect, rounding: f32, color: Color) {
5815        unsafe {
5816            nk_fill_rect(&mut self.internal, arg2, rounding, color);
5817        }
5818    }
5819
5820    pub fn fill_rect_multi_color(&mut self, arg2: Rect, left: Color, top: Color, right: Color, bottom: Color) {
5821        unsafe {
5822            nk_fill_rect_multi_color(&mut self.internal, arg2, left, top, right, bottom);
5823        }
5824    }
5825
5826    pub fn fill_circle(&mut self, arg2: Rect, color: Color) {
5827        unsafe {
5828            nk_fill_circle(&mut self.internal, arg2, color);
5829        }
5830    }
5831
5832    pub fn fill_arc(&mut self, cx: f32, cy: f32, radius: f32, a_min: f32, a_max: f32, color: Color) {
5833        unsafe {
5834            nk_fill_arc(&mut self.internal, cx, cy, radius, a_min, a_max, color);
5835        }
5836    }
5837
5838    pub fn fill_triangle(&mut self, x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32, color: Color) {
5839        unsafe {
5840            nk_fill_triangle(&mut self.internal, x0, y0, x1, y1, x2, y2, color);
5841        }
5842    }
5843
5844    pub fn fill_polygon(&mut self, points: &mut [f32], color: Color) {
5845        unsafe {
5846            nk_fill_polygon(&mut self.internal, &mut points[0] as *mut f32, points.len() as ::std::os::raw::c_int, color);
5847        }
5848    }
5849
5850    pub fn push_scissor(&mut self, arg2: Rect) {
5851        unsafe {
5852            nk_push_scissor(&mut self.internal, arg2);
5853        }
5854    }
5855
5856    pub fn draw_image(&mut self, arg2: Rect, arg3: &Image, arg4: Color) {
5857        unsafe {
5858            nk_draw_image(&mut self.internal, arg2, &arg3.internal as *const nk_image, arg4);
5859        }
5860    }
5861
5862    pub fn draw_text(&mut self, arg2: Rect, text: &str, arg3: &UserFont, arg4: Color, arg5: Color) {
5863        unsafe {
5864            nk_draw_text(&mut self.internal, arg2, text.as_ptr() as *const i8, text.as_bytes().len() as ::std::os::raw::c_int, &arg3.internal, arg4, arg5);
5865        }
5866    }
5867}
5868
5869// =============================================================================================
5870
5871pub fn color_rgb(r: i32, g: i32, b: i32) -> Color {
5872    unsafe { nk_rgb(r, g, b) }
5873}
5874
5875pub fn color_rgb_iv(rgb: &i32) -> Color {
5876    unsafe { nk_rgb_iv(rgb as *const i32) }
5877}
5878
5879pub fn color_rgb_bv(rgb: &u8) -> Color {
5880    unsafe { nk_rgb_bv(rgb as *const u8) }
5881}
5882
5883pub fn color_rgb_fv(rgb: &f32) -> Color {
5884    unsafe { nk_rgb_fv(rgb as *const f32) }
5885}
5886
5887pub fn color_rgb_f(r: f32, g: f32, b: f32) -> Color {
5888    unsafe { nk_rgb_f(r, g, b) }
5889}
5890
5891pub fn color_rgb_hex(rgb: String) -> Color {
5892    unsafe { nk_rgb_hex(rgb.as_ptr()) }
5893}
5894
5895pub fn color_rgba(r: i32, g: i32, b: i32, a: i32) -> Color {
5896    unsafe { nk_rgba(r, g, b, a) }
5897}
5898
5899pub fn color_rgba_u32(rgba: u32) -> Color {
5900    unsafe { nk_rgba_u32(rgba) }
5901}
5902
5903pub fn color_rgba_iv(rgba: &i32) -> Color {
5904    unsafe { nk_rgba_iv(rgba as *const i32) }
5905}
5906
5907pub fn color_rgba_bv(rgb: &u8) -> Color {
5908    unsafe { nk_rgba_bv(rgb as *const u8) }
5909}
5910
5911pub fn color_rgba_fv(rgb: &f32) -> Color {
5912    unsafe { nk_rgba_fv(rgb as *const f32) }
5913}
5914
5915pub fn color_rgba_f(r: f32, g: f32, b: f32, a: f32) -> Color {
5916    unsafe { nk_rgba_f(r, g, b, a) }
5917}
5918
5919pub fn color_rgba_hex(rgba: String) -> Color {
5920    unsafe { nk_rgba_hex(rgba.as_ptr()) }
5921}
5922
5923pub fn color_hsv(h: i32, s: i32, v: i32) -> Color {
5924    unsafe { nk_hsv(h, s, v) }
5925}
5926
5927pub fn color_hsv_iv(hsv: &i32) -> Color {
5928    unsafe { nk_hsv_iv(hsv as *const i32) }
5929}
5930
5931pub fn color_hsv_bv(hsv: &u8) -> Color {
5932    unsafe { nk_hsv_bv(hsv as *const u8) }
5933}
5934
5935pub fn color_hsv_fv(hsv: &f32) -> Color {
5936    unsafe { nk_hsv_fv(hsv as *const f32) }
5937}
5938
5939pub fn color_hsv_f(h: f32, s: f32, v: f32) -> Color {
5940    unsafe { nk_hsv_f(h, s, v) }
5941}
5942
5943pub fn color_hsva(h: i32, s: i32, v: i32, a: i32) -> Color {
5944    unsafe { nk_hsva(h, s, v, a) }
5945}
5946
5947pub fn color_hsva_iv(hsva: &i32) -> Color {
5948    unsafe { nk_hsva_iv(hsva as *const i32) }
5949}
5950
5951pub fn color_hsva_bv(hsv: &u8) -> Color {
5952    unsafe { nk_hsva_bv(hsv as *const u8) }
5953}
5954
5955pub fn color_hsva_fv(hsv: &f32) -> Color {
5956    unsafe { nk_hsva_fv(hsv as *const f32) }
5957}
5958
5959pub fn color_hsva_f(h: f32, s: f32, v: f32, a: f32) -> Color {
5960    unsafe { nk_hsva_f(h, s, v, a) }
5961}
5962
5963pub fn style_get_color_by_name(c: StyleColor) -> Cow<'static, str> {
5964    unsafe {
5965        // String::from_bytes_unchecked()
5966        // CString::from_raw(nk_style_get_color_by_name(c))
5967        ::std::ffi::CStr::from_ptr(nk_style_get_color_by_name(c)).to_string_lossy()
5968    }
5969}
5970
5971// =============================================================================================
5972
5973wrapper_type!(Image, nk_image);
5974
5975impl Image {
5976    pub fn with_id(id: i32) -> Image {
5977        Image { internal: unsafe { nk_image_id(id) } }
5978    }
5979
5980    pub unsafe fn with_ptr(ptr: *mut c_void) -> Image {
5981        Image { internal: nk_image_ptr(ptr) }
5982    }
5983
5984    pub fn id(&mut self) -> i32 {
5985        unsafe { self.internal.handle.id }
5986    }
5987
5988    pub fn ptr(&mut self) -> *mut c_void {
5989        unsafe { self.internal.handle.ptr }
5990    }
5991}
5992
5993// =============================================================================================
5994
5995wrapper_type!(FontGlyph, nk_font_glyph);
5996
5997impl FontGlyph {
5998    pub fn get_codepoint(&self) -> char {
5999        ::std::char::from_u32(self.internal.codepoint).unwrap()
6000    }
6001    pub fn get_xadvance(&self) -> f32 {
6002        self.internal.xadvance
6003    }
6004    pub fn x0(&self) -> f32 {
6005        self.internal.x0
6006    }
6007    pub fn y0(&self) -> f32 {
6008        self.internal.y0
6009    }
6010    pub fn x1(&self) -> f32 {
6011        self.internal.x1
6012    }
6013    pub fn y1(&self) -> f32 {
6014        self.internal.y1
6015    }
6016    pub fn w(&self) -> f32 {
6017        self.internal.w
6018    }
6019    pub fn h(&self) -> f32 {
6020        self.internal.h
6021    }
6022    pub fn u0(&self) -> f32 {
6023        self.internal.u0
6024    }
6025    pub fn v0(&self) -> f32 {
6026        self.internal.v0
6027    }
6028    pub fn u1(&self) -> f32 {
6029        self.internal.u1
6030    }
6031    pub fn v1(&self) -> f32 {
6032        self.internal.v1
6033    }
6034}
6035
6036// =============================================================================================
6037
6038wrapper_type!(Font, nk_font);
6039
6040impl Font {
6041    pub fn find_glyph(&self, unicode: char) -> &FontGlyph {
6042        unsafe { ::std::mem::transmute(nk_font_find_glyph(&self.internal as *const _ as *mut nk_font, unicode as u32)) }
6043    }
6044
6045    pub fn handle(&self) -> &UserFont {
6046        unsafe { ::std::mem::transmute(&self.internal.handle as *const _ as *mut nk_user_font) }
6047    }
6048}
6049
6050// =============================================================================================
6051
6052wrapper_type!(UserFont, nk_user_font);
6053
6054impl UserFont {
6055    pub unsafe fn userdata_ptr(&self) -> Handle {
6056        Handle::from_ptr(self.internal.userdata.ptr)
6057    }
6058
6059    pub unsafe fn userdata_id(&self) -> Handle {
6060        Handle::from_id(self.internal.userdata.id)
6061    }
6062}
6063
6064// =============================================================================================
6065
6066fn raw_glyph_ranges_to_safe<'a>(arg: *const nk_rune) -> &'a [(u32, u32)] {
6067    unsafe {
6068        let len32 = (::std::mem::size_of::<(u32, u32)>() / ::std::mem::size_of::<u32>()) as isize;
6069
6070        let mut raw2 = arg;
6071
6072        let mut i = 0xffff;
6073        let mut len = 0;
6074        while i > 0 {
6075            i = *raw2;
6076            raw2 = raw2.offset(len32);
6077            if i > 0 {
6078                len += 1;
6079            }
6080        }
6081
6082        ::std::slice::from_raw_parts(arg as *const (u32, u32), len)
6083    }
6084}
6085
6086pub fn font_default_glyph_ranges<'a>() -> &'a [(u32, u32)] {
6087    unsafe { raw_glyph_ranges_to_safe(nk_font_default_glyph_ranges()) }
6088}
6089
6090pub fn font_chinese_glyph_ranges<'a>() -> &'a [(u32, u32)] {
6091    unsafe { raw_glyph_ranges_to_safe(nk_font_chinese_glyph_ranges()) }
6092}
6093
6094pub fn font_cyrillic_glyph_ranges<'a>() -> &'a [(u32, u32)] {
6095    unsafe { raw_glyph_ranges_to_safe(nk_font_cyrillic_glyph_ranges()) }
6096}
6097
6098pub fn font_korean_glyph_ranges<'a>() -> &'a [(u32, u32)] {
6099    unsafe { raw_glyph_ranges_to_safe(nk_font_korean_glyph_ranges()) }
6100}