X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fdialog.cpp;h=0323161b4dcb32682ef048502972a17926c7d4f2;hb=8705acc09238c97ba0e79094621f0d6c859a7eb1;hp=1c628ff17a3ee3c33c7e4cc856a18deae791fd74;hpb=e78f526d5fbbbf18699ec76297e4973565356c81;p=xonotic%2Fnetradiant.git diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 1c628ff1..0323161b 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -256,24 +256,28 @@ public: } }; +template +struct AddDataCustom_Wrapper { + static void Export(const native &self, const Callback &returnz) { + native *p = &const_cast(self); + auto widget = Self::from(p); + Widget::Get::thunk_(widget, returnz); + } + + static void Import(native &self, T value) { + native *p = &self; + auto widget = Self::from(p); + Widget::Set::thunk_(widget, value); + } +}; + template void AddDataCustom(DialogDataList &self, typename Widget::Type widget, Property const &property) { using Self = typename Widget::Type; using T = typename Widget::Other; using native = typename std::remove_pointer::type; - struct Wrapper { - static void Export(const native &self, const Callback &returnz) { - native *p = &const_cast(self); - auto widget = Self::from(p); - Widget::Get::thunk_(widget, returnz); - } - - static void Import(native &self, T value) { - native *p = &self; - auto widget = Self::from(p); - Widget::Set::thunk_(widget, value); - } - }; + using Wrapper = AddDataCustom_Wrapper; + self.push_back(new CallbackDialogData( make_property>(*static_cast(widget)), property @@ -442,6 +446,23 @@ EMessageBoxReturn Dialog::DoModal(){ return m_modal.ret; } +ui::VBox Dialog::addSpacer( ui::VBox vbox, int dimension ){ + auto spacer = ui::VBox( FALSE, 0 ); + gtk_widget_set_size_request( GTK_WIDGET( spacer ), dimension, dimension ); + spacer.show(); + + DialogVBox_packRow( vbox, spacer ); + return spacer; +} + +ui::Label Dialog::addLabel( ui::VBox vbox, const char* name, const char* text ){ + auto label = ui::Label( text ); + gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 ); + label.show(); + + DialogVBox_packRow( vbox, ui::Widget(DialogRow_new( name, label ) )); + return label; +} ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, Property const &cb ){ auto check = ui::CheckButton( flag );