}
}
+
+
+/* -------------------------------- Tabview Container -------------------------------- */
+
+pub struct TabViewBuilder<'a> {
+ args: *mut UiTabViewArgs,
+ obj: &'a mut toolkit::UiObject
+}
+
+pub struct TabBuilder<'a> {
+ obj: &'a mut toolkit::UiObject
+}
+
+impl<'a> TabBuilder<'a> {
+ pub fn tab<F>(&mut self, title: &str, create_ui: F)
+ where
+ F: FnOnce(&mut toolkit::UiObject)
+ {
+ unsafe {
+ let title = CString::new(title).unwrap();
+ ui_tab_create(self.obj.ptr, title.as_ptr());
+ }
+ create_ui(self.obj);
+ unsafe {
+ ui_container_begin_close(self.obj.ptr);
+ ui_container_finish(self.obj.ptr);
+ }
+ }
+}
+
+impl toolkit::UiObject {
+ pub fn tabview<F, U>(&mut self, build: F, ui: U)
+ where
+ F: Fn(&mut TabViewBuilder),
+ U: FnOnce(&mut TabBuilder) {
+ let mut builder = self.tabview_builder();
+ build(&mut builder);
+ builder.create(ui);
+ }
+
+ pub fn tabview_builder(&mut self) -> TabViewBuilder<'_>
+ {
+ unsafe {
+ let args = ui_tabview_args_new();
+ TabViewBuilder {
+ args,
+ obj: self
+ }
+ }
+ }
+}
+
+impl<'a> TabViewBuilder<'a> {
+ pub fn create<F>(&mut self, create_ui: F)
+ where F: FnOnce(&mut TabBuilder) {
+ unsafe {
+ ui_tabview_create(self.obj.ptr, self.args);
+ }
+ let mut tabbuilder = TabBuilder {
+ obj: self.obj
+ };
+ create_ui(&mut tabbuilder);
+ unsafe {
+ ui_container_begin_close(self.obj.ptr);
+ ui_container_finish(self.obj.ptr);
+ }
+ }
+
+ pub fn fill(&mut self, fill: bool) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_fill(self.args, if fill { 1 } else { 0 });
+ }
+ self
+ }
+
+ pub fn hexpand(&mut self, value: bool) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_hexpand(self.args, if value { 1 } else { 0 });
+ }
+ self
+ }
+
+ pub fn vexpand(&mut self, value: bool) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_vexpand(self.args, if value { 1 } else { 0 });
+ }
+ self
+ }
+
+ pub fn hfill(&mut self, value: bool) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_hfill(self.args, if value { 1 } else { 0 });
+ }
+ self
+ }
+
+ pub fn vfill(&mut self, value: bool) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_vfill(self.args, if value { 1 } else { 0 });
+ }
+ self
+ }
+
+ pub fn override_defaults(&mut self, value: bool) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_override_defaults(self.args, if value { 1 } else { 0 });
+ }
+ self
+ }
+
+ pub fn margin(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_margin(self.args, value);
+ }
+ self
+ }
+
+ pub fn margin_left(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_margin_left(self.args, value);
+ }
+ self
+ }
+
+ pub fn margin_right(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_margin_right(self.args, value);
+ }
+ self
+ }
+
+ pub fn margin_top(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_margin_top(self.args, value);
+ }
+ self
+ }
+
+ pub fn margin_bottom(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_margin_bottom(self.args, value);
+ }
+ self
+ }
+
+ pub fn colspan(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_colspan(self.args, value);
+ }
+ self
+ }
+
+ pub fn rowspan(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_rowspan(self.args, value);
+ }
+ self
+ }
+
+ pub fn name(&mut self, value: &str) -> &mut Self {
+ let cstr = CString::new(value).unwrap();
+ unsafe {
+ ui_tabview_args_set_name(self.args, cstr.as_ptr());
+ }
+ self
+ }
+
+ pub fn style_class(&mut self, value: &str) -> &mut Self {
+ let cstr = CString::new(value).unwrap();
+ unsafe {
+ ui_tabview_args_set_style_class(self.args, cstr.as_ptr());
+ }
+ self
+ }
+
+ pub fn spacing(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_spacing(self.args, value);
+ }
+ self
+ }
+
+ pub fn columnspacing(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_columnspacing(self.args, value);
+ }
+ self
+ }
+
+ pub fn rowspacing(&mut self, value: i32) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_rowspacing(self.args, value);
+ }
+ self
+ }
+
+ // TODO
+
+ pub fn subcontainer_type(&mut self, subtype: SubContainer) -> &mut Self {
+ unsafe {
+ ui_tabview_args_set_subcontainer(self.args, subtype as c_int);
+ }
+ self
+ }
+}
+
/* -------------------------------- C functions -------------------------------- */
extern "C" {
fn ui_sidebar_create(obj: *mut UiObject, args: *const UiSidebarArgs) -> *mut c_void;
fn ui_left_panel_create(obj: *mut UiObject, args: *const UiSidebarArgs) -> *mut c_void;
fn ui_right_panel_create(obj: *mut UiObject, args: *const UiSidebarArgs) -> *mut c_void;
+ fn ui_tabview_create(obj: *mut UiObject, args: *const UiTabViewArgs) -> *mut c_void;
+ fn ui_tab_create(obj: *mut UiObject, label: *const c_char) -> *mut c_void;
fn ui_newline(obj: *mut UiObject);
fn ui_sidebar_args_set_style_class(args: *mut UiSidebarArgs, classname: *const c_char);
fn ui_sidebar_args_set_spacing(args: *mut UiSidebarArgs, spacing: c_int);
fn ui_sidebar_args_free(args: *mut UiSidebarArgs);
+
+ fn ui_tabview_args_new() -> *mut UiTabViewArgs;
+ fn ui_tabview_args_set_fill(args: *mut UiTabViewArgs, fill: c_int);
+ fn ui_tabview_args_set_hexpand(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_vexpand(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_hfill(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_vfill(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_override_defaults(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_margin(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_margin_left(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_margin_right(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_margin_top(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_margin_bottom(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_colspan(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_rowspan(args: *mut UiTabViewArgs, value: c_int);
+ fn ui_tabview_args_set_name(args: *mut UiTabViewArgs, name: *const c_char);
+ fn ui_tabview_args_set_style_class(args: *mut UiTabViewArgs, classname: *const c_char);
+ fn ui_tabview_args_set_spacing(args: *mut UiTabViewArgs, spacing: c_int);
+ fn ui_tabview_args_set_columnspacing(args: *mut UiTabViewArgs, spacing: c_int);
+ fn ui_tabview_args_set_rowspacing(args: *mut UiTabViewArgs, spacing: c_int);
+ fn ui_tabview_args_set_type(args: *mut UiTabViewArgs, tabview: c_int);
+ fn ui_tabview_args_set_onchange(args: *mut UiTabViewArgs, callback: UiCallback);
+ fn ui_tabview_args_set_onchangedata(args: *mut UiTabViewArgs, data: *mut c_void);
+ fn ui_tabview_args_set_varname(args: *mut UiTabViewArgs, varname: *const c_char);
+ fn ui_tabview_args_set_subcontainer(args: *mut UiTabViewArgs, subcontainer: c_int);
+ fn ui_tabview_args_set_value(args: *mut UiTabViewArgs, ivalue: *mut UiInteger);
+ fn ui_tabview_args_set_visibility_states(args: *mut UiTabViewArgs, states: *const c_int, numstates: c_int);
+ fn ui_tabview_args_free(args: *mut UiTabViewArgs);
}