summaryrefslogtreecommitdiffstats
path: root/SidebarAdd.cpp
blob: 57de3ee1d4abdaccad8014a32bcff8318ab9bd4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "SidebarAdd.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(!editor->getActiveRoom())
    return;
  
  if(editor->getActiveRoom()->size() > 2 && editor->polygonOk(*editor->getActiveRoom()))
    gtk_widget_set_sensitive(buttonAdd, TRUE);
  else
    gtk_widget_set_sensitive(buttonAdd, FALSE);
}