diff options
Diffstat (limited to 'SidebarAdd.cpp')
-rw-r--r-- | SidebarAdd.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/SidebarAdd.cpp b/SidebarAdd.cpp new file mode 100644 index 0000000..78509e0 --- /dev/null +++ b/SidebarAdd.cpp @@ -0,0 +1,43 @@ +#include "SidebarAdd.h" +#include "edit.h" + + +void SidebarAdd::buttonClicked(GtkButton *button, SidebarAdd *sidebar) { + sidebar->editor->finishRoom(); +} + +SidebarAdd::SidebarAdd(EditManager *editor) { + this->editor = editor; + + sidebar = gtk_vbox_new(FALSE, 0); + g_object_ref_sink(G_OBJECT(sidebar)); + + GtkWidget *labelRoomInfo = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "<b>Add room</b>"); + gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebar), labelRoomInfo, FALSE, FALSE, 5); + + buttonAdd = gtk_button_new_with_label("Add room"); + g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(buttonClicked), this); + gtk_box_pack_end(GTK_BOX(sidebar), buttonAdd, FALSE, FALSE, 0); + + gtk_widget_show_all(sidebar); +} + +SidebarAdd::~SidebarAdd() { + g_object_unref(G_OBJECT(sidebar)); +} + +GtkWidget* SidebarAdd::getWidget() { + return sidebar; +} + +void SidebarAdd::update() { + if(!getActiveRoom()) + return; + + if(getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) + gtk_widget_set_sensitive(buttonAdd, TRUE); + else + gtk_widget_set_sensitive(buttonAdd, FALSE); +} |