zoomedit: R?ume haben jetzt eine H?he.
This commit is contained in:
parent
0791033f7f
commit
29ecb9c039
3 changed files with 34 additions and 5 deletions
9
Room.h
9
Room.h
|
@ -8,14 +8,19 @@
|
||||||
class Room : public Polygon {
|
class Room : public Polygon {
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
float height;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Room() {}
|
Room() {height = 10;}
|
||||||
Room(std::string name) {this->name = name;}
|
Room(std::string name) {this->name = name; height= 10;}
|
||||||
|
|
||||||
|
|
||||||
std::string &getName() {return name;}
|
std::string &getName() {return name;}
|
||||||
const std::string &getName() const {return name;}
|
const std::string &getName() const {return name;}
|
||||||
void setName(const std::string &name) {this->name = name;}
|
void setName(const std::string &name) {this->name = name;}
|
||||||
|
|
||||||
|
float getHeight() const {return height;}
|
||||||
|
void setHeight(float height) {this->height = height;}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*ROOM_H_*/
|
#endif /*ROOM_H_*/
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
#include "SidebarView.h"
|
#include "SidebarView.h"
|
||||||
|
|
||||||
|
|
||||||
|
void SidebarView::spinButtonHeightChanged(GtkSpinButton *spinbutton, SidebarView *view) {
|
||||||
|
if(!view->editor->getActiveRoom())
|
||||||
|
return;
|
||||||
|
|
||||||
|
view->editor->getActiveRoom()->setHeight(gtk_spin_button_get_value(spinbutton));
|
||||||
|
}
|
||||||
|
|
||||||
void SidebarView::buttonClicked(GtkButton *button, SidebarView *sidebar) {
|
void SidebarView::buttonClicked(GtkButton *button, SidebarView *sidebar) {
|
||||||
sidebar->editor->addRoom();
|
sidebar->editor->addRoom();
|
||||||
}
|
}
|
||||||
|
@ -28,9 +35,8 @@ SidebarView::SidebarView(EditManager *editor) {
|
||||||
//gtk_widget_add_events(entryName, GDK_FOCUS_CHANGE_MASK);
|
//gtk_widget_add_events(entryName, GDK_FOCUS_CHANGE_MASK);
|
||||||
gtk_box_pack_start(GTK_BOX(sidebar), entryName, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(sidebar), entryName, FALSE, FALSE, 0);
|
||||||
|
|
||||||
GtkWidget *tableRoomData = gtk_table_new(2, 2, FALSE);
|
GtkWidget *tableRoomData = gtk_table_new(2, 3, FALSE);
|
||||||
gtk_table_set_row_spacings(GTK_TABLE(tableRoomData), 5);
|
gtk_table_set_row_spacings(GTK_TABLE(tableRoomData), 5);
|
||||||
gtk_table_set_col_spacings(GTK_TABLE(tableRoomData), 10);
|
|
||||||
gtk_box_pack_start(GTK_BOX(sidebar), tableRoomData, FALSE, FALSE, 5);
|
gtk_box_pack_start(GTK_BOX(sidebar), tableRoomData, FALSE, FALSE, 5);
|
||||||
|
|
||||||
GtkWidget *labelAreaLabel = gtk_label_new("Room area:");
|
GtkWidget *labelAreaLabel = gtk_label_new("Room area:");
|
||||||
|
@ -49,6 +55,17 @@ SidebarView::SidebarView(EditManager *editor) {
|
||||||
gtk_misc_set_alignment(GTK_MISC(labelPerimeter), 1.0, 0.5);
|
gtk_misc_set_alignment(GTK_MISC(labelPerimeter), 1.0, 0.5);
|
||||||
gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeter, 1, 2, 1, 2);
|
gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeter, 1, 2, 1, 2);
|
||||||
|
|
||||||
|
GtkWidget *labelHeight = gtk_label_new("Height:");
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(labelHeight), 0.0, 0.5);
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelHeight, 0, 1, 2, 3);
|
||||||
|
|
||||||
|
spinButtonHeight = gtk_spin_button_new_with_range(0, 10000, 0.1f);
|
||||||
|
gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinButtonHeight), 2);
|
||||||
|
gtk_entry_set_alignment(GTK_ENTRY(spinButtonHeight), 1.0);
|
||||||
|
gtk_table_attach(GTK_TABLE(tableRoomData), spinButtonHeight, 1, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND|GTK_SHRINK|GTK_FILL),
|
||||||
|
(GtkAttachOptions)(GTK_EXPAND|GTK_FILL), 0, 0);
|
||||||
|
g_signal_connect(G_OBJECT(spinButtonHeight), "value-changed", G_CALLBACK(spinButtonHeightChanged), this);
|
||||||
|
|
||||||
buttonAdd = gtk_button_new_with_label("Add room");
|
buttonAdd = gtk_button_new_with_label("Add room");
|
||||||
g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(buttonClicked), this);
|
g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(buttonClicked), this);
|
||||||
gtk_box_pack_end(GTK_BOX(sidebar), buttonAdd, FALSE, FALSE, 0);
|
gtk_box_pack_end(GTK_BOX(sidebar), buttonAdd, FALSE, FALSE, 0);
|
||||||
|
@ -76,6 +93,9 @@ void SidebarView::update() {
|
||||||
string = g_strdup_printf("%.2f", editor->getActiveRoom()->perimeter());
|
string = g_strdup_printf("%.2f", editor->getActiveRoom()->perimeter());
|
||||||
gtk_label_set_text(GTK_LABEL(labelPerimeter), string);
|
gtk_label_set_text(GTK_LABEL(labelPerimeter), string);
|
||||||
g_free(string);
|
g_free(string);
|
||||||
|
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinButtonHeight), editor->getActiveRoom()->getHeight());
|
||||||
|
gtk_widget_set_sensitive(spinButtonHeight, TRUE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gtk_entry_set_text(GTK_ENTRY(entryName), "");
|
gtk_entry_set_text(GTK_ENTRY(entryName), "");
|
||||||
|
@ -83,5 +103,8 @@ void SidebarView::update() {
|
||||||
|
|
||||||
gtk_label_set_text(GTK_LABEL(labelArea), NULL);
|
gtk_label_set_text(GTK_LABEL(labelArea), NULL);
|
||||||
gtk_label_set_text(GTK_LABEL(labelPerimeter), NULL);
|
gtk_label_set_text(GTK_LABEL(labelPerimeter), NULL);
|
||||||
|
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinButtonHeight), 0.0);
|
||||||
|
gtk_widget_set_sensitive(spinButtonHeight, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
class SidebarView : public Sidebar {
|
class SidebarView : public Sidebar {
|
||||||
private:
|
private:
|
||||||
GtkWidget *sidebar;
|
GtkWidget *sidebar;
|
||||||
GtkWidget *entryName, *labelArea, *labelPerimeter, *buttonAdd;
|
GtkWidget *entryName, *labelArea, *labelPerimeter, *spinButtonHeight, *buttonAdd;
|
||||||
|
|
||||||
EditManager *editor;
|
EditManager *editor;
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class SidebarView : public Sidebar {
|
||||||
SidebarView(const SidebarView &w);
|
SidebarView(const SidebarView &w);
|
||||||
const SidebarView& operator=(const SidebarView &w);
|
const SidebarView& operator=(const SidebarView &w);
|
||||||
|
|
||||||
|
static void spinButtonHeightChanged(GtkSpinButton *spinbutton, SidebarView *view);
|
||||||
static void buttonClicked(GtkButton *button, SidebarView *view);
|
static void buttonClicked(GtkButton *button, SidebarView *view);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Reference in a new issue