[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3110 - in trunk/pingus/src: . display editor gui
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3110 - in trunk/pingus/src: . display editor gui |
Date: |
Sat, 8 Sep 2007 16:51:51 +0200 |
Author: grumbel
Date: 2007-09-08 16:51:50 +0200 (Sat, 08 Sep 2007)
New Revision: 3110
Added:
trunk/pingus/src/editor/button.cpp
trunk/pingus/src/editor/button.hpp
trunk/pingus/src/editor/gui_style.cpp
trunk/pingus/src/editor/gui_style.hpp
Modified:
trunk/pingus/src/SConscript
trunk/pingus/src/display/drawing_context.cpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/editor_screen.hpp
trunk/pingus/src/editor/editor_viewport.cpp
trunk/pingus/src/editor/file_list.cpp
trunk/pingus/src/editor/file_list.hpp
trunk/pingus/src/editor/file_load_dialog.cpp
trunk/pingus/src/editor/file_load_dialog.hpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/editor/object_properties.hpp
trunk/pingus/src/editor/object_selector.cpp
trunk/pingus/src/gui/group_component.cpp
trunk/pingus/src/gui/group_component.hpp
trunk/pingus/src/gui/gui_manager.cpp
trunk/pingus/src/gui/rect_component.hpp
trunk/pingus/src/system.cpp
trunk/pingus/src/system.hpp
Log:
- made the file dialog pretty
Modified: trunk/pingus/src/SConscript
===================================================================
--- trunk/pingus/src/SConscript 2007-09-08 14:51:08 UTC (rev 3109)
+++ trunk/pingus/src/SConscript 2007-09-08 14:51:50 UTC (rev 3110)
@@ -89,6 +89,8 @@
'display/drawing_context.cpp',
'display/scene_context.cpp',
+'editor/button.cpp',
+'editor/gui_style.cpp',
'editor/context_menu.cpp',
'editor/editor_level.cpp',
'editor/panel.cpp',
@@ -98,7 +100,8 @@
'editor/editor_screen.cpp',
'editor/editor_viewport.cpp',
'editor/level_objs.cpp',
-'editor/object_selector.cpp',
+'editor/object_selector.cpp',
+'editor/object_properties.cpp',
'command_line.cpp',
'command_line_generic.cpp',
Modified: trunk/pingus/src/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/display/drawing_context.cpp 2007-09-08 14:51:08 UTC
(rev 3109)
+++ trunk/pingus/src/display/drawing_context.cpp 2007-09-08 14:51:50 UTC
(rev 3110)
@@ -43,6 +43,7 @@
std::string text;
float x;
float y;
+
public:
FontDrawingRequest(Font font_, Origin origin_, const Vector3f& pos, const
std::string& text_, float z)
: DrawingRequest(Vector3f(pos.x, pos.y, z)),
@@ -368,9 +369,9 @@
}
void
-DrawingContext::set_rect(const Rect& rect)
+DrawingContext::set_rect(const Rect& rect_)
{
- std::cout << "DrawingContext::set_rect(const Rect& rect): unimplemented" <<
std::endl;
+ rect = rect_;
}
Rect
Added: trunk/pingus/src/editor/button.cpp
===================================================================
--- trunk/pingus/src/editor/button.cpp 2007-09-08 14:51:08 UTC (rev 3109)
+++ trunk/pingus/src/editor/button.cpp 2007-09-08 14:51:50 UTC (rev 3110)
@@ -0,0 +1,88 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#include "fonts.hpp"
+#include "gui_style.hpp"
+#include "button.hpp"
+
+namespace Editor {
+
+Button::Button(const Rect& rect, const std::string& text_)
+ : RectComponent(rect),
+ text(text_),
+ mouse_over(false),
+ mouse_down(false)
+{
+}
+
+void
+Button::draw (DrawingContext& gc)
+{
+ if (mouse_down && mouse_over)
+ GUIStyle::draw_lowered_box(gc, rect, Color(237, 233, 227), 2);
+ else if (mouse_over)
+ GUIStyle::draw_raised_box(gc, rect, Color(255, 255, 255), 2);
+ else
+ GUIStyle::draw_raised_box(gc, rect, Color(237, 233, 227), 2);
+
+ gc.print_center(Fonts::courier_small,
+ rect.left + rect.get_width()/2, rect.top +
rect.get_height()/2 - 6,
+ text);
+}
+
+void
+Button::update (float delta)
+{
+}
+
+void
+Button::on_pointer_enter ()
+{
+ mouse_over = true;
+}
+
+void
+Button::on_pointer_leave ()
+{
+ mouse_over = false;
+}
+
+void
+Button::on_primary_button_press (int x, int y)
+{
+ mouse_down = true;
+}
+
+void
+Button::on_primary_button_release (int x, int y)
+{
+ mouse_down = false;
+ if (mouse_over)
+ on_click();
+}
+
+} // namespace Editor
+
+/* EOF */
Property changes on: trunk/pingus/src/editor/button.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/pingus/src/editor/button.hpp
===================================================================
--- trunk/pingus/src/editor/button.hpp 2007-09-08 14:51:08 UTC (rev 3109)
+++ trunk/pingus/src/editor/button.hpp 2007-09-08 14:51:50 UTC (rev 3110)
@@ -0,0 +1,65 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#ifndef HEADER_BUTTON_HPP
+#define HEADER_BUTTON_HPP
+
+#include <boost/signal.hpp>
+#include "gui/rect_component.hpp"
+
+namespace Editor {
+
+/** */
+class Button : public GUI::RectComponent
+{
+private:
+ std::string text;
+ bool mouse_over;
+ bool mouse_down;
+
+public:
+ Button(const Rect& rect, const std::string& text);
+
+ void draw (DrawingContext& gc);
+ void update (float delta);
+ void update_layout() {}
+
+ void on_pointer_enter();
+ void on_pointer_leave();
+ void on_primary_button_press(int x, int y);
+ void on_primary_button_release(int x, int y);
+
+ boost::signal<void()> on_click;
+
+private:
+ Button (const Button&);
+ Button& operator= (const Button&);
+};
+
+} // namespace Editor
+
+#endif
+
+/* EOF */
Property changes on: trunk/pingus/src/editor/button.hpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/editor_screen.cpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -40,6 +40,7 @@
#include "editor_viewport.hpp"
#include "level_objs.hpp"
#include "object_selector.hpp"
+#include "object_properties.hpp"
namespace Editor {
@@ -59,9 +60,12 @@
panel = new Panel(this);
object_selector = new ObjectSelector(this);
-
- file_load_dialog = new FileLoadDialog(this, Rect(100, 150, 700, 450));
- file_load_dialog->set_directory("/tmp");
+ object_properties = new ObjectProperties(this, Rect(100,100,500,500));
+ gui_manager->add(object_properties, true);
+ file_load_dialog = new FileLoadDialog(this, Rect(Vector2i(50, 50),
+ Size(Display::get_width() -
100,
+ Display::get_height()
- 100)));
+ file_load_dialog->set_directory(".");
file_load_dialog->hide();
gui_manager->add(file_load_dialog, true);
}
@@ -195,7 +199,7 @@
else
{
//file_load_dialog->set_rect(Rect(Vector2i(rand() % 200, rand() % 200),
- // Size(400, 300)));
+ // Size(rand()%600+200, rand()%600+300)));
file_load_dialog->show();
}
}
Modified: trunk/pingus/src/editor/editor_screen.hpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.hpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/editor_screen.hpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -36,6 +36,7 @@
class Panel;
class EditorViewport;
class ObjectSelector;
+class ObjectProperties;
/** This class is the screen that contains all of the
editor objects */
@@ -45,10 +46,11 @@
EditorLevel* plf;
Panel* panel;
- EditorViewport* viewport;
- ObjectSelector* object_selector;
- FileLoadDialog* file_load_dialog;
-
+ EditorViewport* viewport;
+ ObjectSelector* object_selector;
+ ObjectProperties* object_properties;
+ FileLoadDialog* file_load_dialog;
+
bool show_help;
public:
Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -39,7 +39,7 @@
: rect(0,
38,
Display::get_width() - 244,
- 600),
+ Display::get_height()),
state(rect.get_width(), rect.get_height()),
drawing_context(new DrawingContext(rect)),
editor(e),
Modified: trunk/pingus/src/editor/file_list.cpp
===================================================================
--- trunk/pingus/src/editor/file_list.cpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/file_list.cpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -39,10 +39,30 @@
vspace = 20;
}
+struct DirectorySorter
+{
+ bool operator()(const System::DirectoryEntry& lhs,
+ const System::DirectoryEntry& rhs)
+ {
+ if (lhs.type == rhs.type)
+ {
+ return lhs.name < rhs.name;
+ }
+ else
+ {
+ if (lhs.type == System::DE_DIRECTORY)
+ return true;
+ else
+ return false;
+ }
+ }
+};
+
void
FileList::set_directory(const std::string& pathname, const std::string&
pattern)
{
directory = System::opendir(pathname, pattern);
+ std::sort(directory.begin(), directory.end(), DirectorySorter());
}
void
@@ -92,10 +112,10 @@
FileList::on_primary_button_release (int x, int y)
{
on_pointer_move(x,y);
- if (click_item == current_item)
+ if (click_item == current_item && current_item != -1)
{
- std::cout << directory[current_item].name << std::endl;
- on_click(directory[current_item].name);
+ //std::cout << directory[current_item].name << std::endl;
+ on_click(directory[current_item]);
}
click_item = -1;
}
Modified: trunk/pingus/src/editor/file_list.hpp
===================================================================
--- trunk/pingus/src/editor/file_list.hpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/file_list.hpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -54,7 +54,7 @@
void on_primary_button_press (int x, int y);
void on_primary_button_release (int x, int y);
- boost::signal<void (const std::string&)> on_click;
+ boost::signal<void (const System::DirectoryEntry&)> on_click;
private:
FileList (const FileList&);
Modified: trunk/pingus/src/editor/file_load_dialog.cpp
===================================================================
--- trunk/pingus/src/editor/file_load_dialog.cpp 2007-09-08 14:51:08 UTC
(rev 3109)
+++ trunk/pingus/src/editor/file_load_dialog.cpp 2007-09-08 14:51:50 UTC
(rev 3110)
@@ -28,6 +28,9 @@
#include "display/drawing_context.hpp"
#include "gui/gui_manager.hpp"
#include "editor_screen.hpp"
+#include "gui_style.hpp"
+#include "fonts.hpp"
+#include "button.hpp"
#include "file_load_dialog.hpp"
namespace Editor {
@@ -35,12 +38,44 @@
FileLoadDialog::FileLoadDialog(EditorScreen* editor_, const Rect& rect)
: GroupComponent(rect),
editor(editor_),
- file_list(Rect(10, 10,
- rect.get_width()-10, rect.get_height() - 10))
+ file_list(Rect(4, 30 + 30 + 30,
+ rect.get_width()-4 - 30, rect.get_height() - 4 - 35))
{
add(&file_list, false);
+ file_list.on_click.connect(boost::bind(&FileLoadDialog::load_file, this,
_1));
+
+ Rect file_rect = file_list.get_rect();
+ up_button = new Button(Rect(file_rect.right + 2, file_rect.top,
+ rect.get_width()-4, file_rect.top +
file_rect.get_height()/2 - 1),
+ "/\\\n|");
+ down_button = new Button(Rect(file_rect.right + 2, file_rect.top +
file_rect.get_height()/2 + 1,
+ rect.get_width()-4, file_rect.bottom),
+ "|\n\\/");
+
+ // FIXME: This could be turned into system specific hotkeys (C:, D:,
+ // etc. on windows, Home, '/', Datadir on Linux)
+ home_button = new Button(Rect(Vector2i(4, rect.get_height() - 4 - 30),
+ Size(100, 30)), "Home");
- file_list.on_click.connect(boost::bind(&FileLoadDialog::load_file, this,
_1));
+ open_button = new Button(Rect(Vector2i(rect.get_width() - 104,
rect.get_height() - 4 - 30),
+ Size(100, 30)), "Open");
+
+ cancel_button = new Button(Rect(Vector2i(rect.get_width() - 104 - 104,
rect.get_height() - 4 - 30),
+ Size(100, 30)), "Cancel");
+
+ up_button->on_click.connect(boost::bind(&FileLoadDialog::on_up, this));
+ down_button->on_click.connect(boost::bind(&FileLoadDialog::on_down, this));
+ home_button->on_click.connect(boost::bind(&FileLoadDialog::on_home, this));
+ open_button->on_click.connect(boost::bind(&FileLoadDialog::on_open, this));
+ cancel_button->on_click.connect(boost::bind(&FileLoadDialog::on_cancel,
this));
+
+ add(up_button, true);
+ add(down_button, true);
+
+ add(home_button, true);
+
+ add(open_button, true);
+ add(cancel_button, true);
}
FileLoadDialog::~FileLoadDialog()
@@ -50,23 +85,100 @@
void
FileLoadDialog::draw_background(DrawingContext& gc)
{
- gc.draw_fillrect(0, 0, rect.get_width(), rect.get_height(), Color(255, 255,
255));
+ GUIStyle::draw_raised_box(gc, Rect(0,0,rect.get_width(), rect.get_height()));
+ gc.draw_fillrect(4,4,rect.get_width()-4, 30, Color(77,130,180));
+ gc.print_center(Fonts::pingus_small, rect.get_width()/2, 2, "Open a level");
+
+ GUIStyle::draw_lowered_box(gc, Rect(4 + 60,4+30,rect.get_width()-4, 26+30),
+ Color(0,0,0));
+ gc.print_left(Fonts::courier_small, 10, 8+30, "File: ");
+ gc.print_left(Fonts::courier_small, 10 + 60, 8+30, filename);
+
+ GUIStyle::draw_lowered_box(gc, Rect(4 + 60,4+60,rect.get_width()-4, 26+60),
+ Color(0,0,0));
+ gc.print_left(Fonts::courier_small, 10, 8+60, "Path: ");
+ gc.print_left(Fonts::courier_small, 10 + 60, 8+60, pathname);
}
void
-FileLoadDialog::load_file(const std::string& file) const
+FileLoadDialog::load_file(const System::DirectoryEntry& entry)
{
- std::cout << "FileLoadDialog::load_file: " << file << std::endl;
-
+ if (entry.type == System::DE_DIRECTORY)
+ {
+ //std::cout << "Directory: " << entry.name << std::endl;
+ pathname = System::realpath(pathname + "/" + entry.name);
+ file_list.set_directory(pathname);
+ filename = "";
+ }
+ else
+ {
+ //std::cout << pathname + "/" + entry.name << std::endl;
+ filename = entry.name;
+ }
}
void
FileLoadDialog::set_directory(const std::string& pathname_)
{
- pathname = pathname_;
+ pathname = System::realpath(pathname_);
file_list.set_directory(pathname);
}
-
+
+void
+FileLoadDialog::on_cancel()
+{
+ std::cout << "Cancel" << std::endl;
+ hide();
+}
+
+void
+FileLoadDialog::on_open()
+{
+ std::cout << "Open" << std::endl;
+ hide();
+}
+
+void
+FileLoadDialog::on_up()
+{
+ std::cout << "Up" << std::endl;
+}
+
+void
+FileLoadDialog::on_down()
+{
+ std::cout << "Down" << std::endl;
+}
+
+void
+FileLoadDialog::update_layout()
+{
+ GUI::GroupComponent::update_layout();
+
+ file_list.set_rect(Rect(4, 30 + 30 + 30,
+ rect.get_width()-4 - 30, rect.get_height() - 4 -
35));
+
+ Rect file_rect = file_list.get_rect();
+
+ up_button->set_rect(Rect(file_rect.right + 2, file_rect.top,
+ rect.get_width()-4, file_rect.top +
file_rect.get_height()/2 - 1));
+
+ down_button->set_rect(Rect(file_rect.right + 2, file_rect.top +
file_rect.get_height()/2 + 1,
+ rect.get_width()-4, file_rect.bottom));
+
+ open_button->set_rect(Rect(Vector2i(rect.get_width() - 104,
rect.get_height() - 4 - 30),
+ Size(100, 30)));
+
+ cancel_button->set_rect(Rect(Vector2i(rect.get_width() - 104 - 104,
rect.get_height() - 4 - 30),
+ Size(100, 30)));
+}
+
+void
+FileLoadDialog::on_home()
+{
+
+}
+
} // namespace Editor
/* EOF */
Modified: trunk/pingus/src/editor/file_load_dialog.hpp
===================================================================
--- trunk/pingus/src/editor/file_load_dialog.hpp 2007-09-08 14:51:08 UTC
(rev 3109)
+++ trunk/pingus/src/editor/file_load_dialog.hpp 2007-09-08 14:51:50 UTC
(rev 3110)
@@ -31,6 +31,7 @@
namespace Editor {
+class Button;
class EditorScreen;
/** */
@@ -39,18 +40,33 @@
private:
EditorScreen* editor;
FileList file_list;
+ Button* up_button;
+ Button* down_button;
+ Button* open_button;
+ Button* cancel_button;
+
+ Button* home_button;
+
std::string pathname;
+ std::string filename;
public:
FileLoadDialog(EditorScreen* editor, const Rect& rect);
~FileLoadDialog();
void draw_background(DrawingContext& gc);
- void update_layout() {}
+ void update_layout();
- void load_file(const std::string& file) const;
+ void load_file(const System::DirectoryEntry& entry);
void set_directory(const std::string& pathname);
+ void on_cancel();
+ void on_open();
+
+ void on_up();
+ void on_down();
+
+ void on_home();
private:
FileLoadDialog (const FileLoadDialog&);
FileLoadDialog& operator= (const FileLoadDialog&);
Added: trunk/pingus/src/editor/gui_style.cpp
===================================================================
--- trunk/pingus/src/editor/gui_style.cpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/gui_style.cpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -0,0 +1,56 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#include "gui_style.hpp"
+
+namespace Editor {
+
+void
+GUIStyle::draw_raised_box(DrawingContext& gc, const Rect& rect, const Color&
color, int border)
+{
+ // FIXME: Should use draw_line
+ gc.draw_fillrect(rect.left, rect.top, rect.right, rect.bottom,
+ Color(255, 255, 255));
+ gc.draw_fillrect(rect.left+border, rect.top+border, rect.right, rect.bottom,
+ Color(169, 157, 140));
+ gc.draw_fillrect(rect.left+border, rect.top+border, rect.right-border,
rect.bottom-border,
+ color);
+}
+
+void
+GUIStyle::draw_lowered_box(DrawingContext& gc, const Rect& rect, const Color&
color, int border)
+{
+ // FIXME: Should use draw_line
+ gc.draw_fillrect(rect.left, rect.top, rect.right, rect.bottom,
+ Color(169, 157, 140));
+ gc.draw_fillrect(rect.left+border, rect.top+border, rect.right, rect.bottom,
+ Color(255, 255, 255));
+ gc.draw_fillrect(rect.left+border, rect.top+border, rect.right-border,
rect.bottom-border,
+ color);
+}
+
+} // namespace Editor
+
+/* EOF */
Property changes on: trunk/pingus/src/editor/gui_style.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/pingus/src/editor/gui_style.hpp
===================================================================
--- trunk/pingus/src/editor/gui_style.hpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/gui_style.hpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -0,0 +1,49 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#ifndef HEADER_GUI_STYLE_HPP
+#define HEADER_GUI_STYLE_HPP
+
+#include "math/rect.hpp"
+#include "display/drawing_context.hpp"
+
+namespace Editor {
+
+/** */
+class GUIStyle
+{
+private:
+public:
+ static void draw_raised_box(DrawingContext& gc, const Rect& rect,
+ const Color& color = Color(237, 233, 227), int
border = 1);
+ static void draw_lowered_box(DrawingContext& gc, const Rect& rect,
+ const Color& color = Color(237, 233, 227), int
border = 1);
+};
+
+} // namespace Editor
+
+#endif
+
+/* EOF */
Property changes on: trunk/pingus/src/editor/gui_style.hpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2007-09-08 14:51:08 UTC
(rev 3109)
+++ trunk/pingus/src/editor/object_properties.cpp 2007-09-08 14:51:50 UTC
(rev 3110)
@@ -17,13 +17,18 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include "button.hpp"
+#include "editor_screen.hpp"
#include "object_properties.hpp"
namespace Editor {
-ObjectProperties::ObjectProperties(EditorScreen* editor_)
- : editor(editor_)
+ObjectProperties::ObjectProperties(EditorScreen* editor_, const Rect& rect)
+ : GUI::GroupComponent(rect),
+ editor(editor_)
{
+ add(new Button(Rect(10, 10, 100, 20), "Test"), true);
+ add(new Button(Rect(10, 100, 100, 220), "Test 2"), true);
}
ObjectProperties::~ObjectProperties()
@@ -34,6 +39,13 @@
ObjectProperties::set_object(LevelObj* obj)
{
}
+
+void
+ObjectProperties::draw_background(DrawingContext& gc)
+{
+ gc.draw_fillrect(0,0, rect.get_width(), rect.get_height(),
+ Color(255, 255, 0));
+}
} // namespace Editor
Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp 2007-09-08 14:51:08 UTC
(rev 3109)
+++ trunk/pingus/src/editor/object_properties.hpp 2007-09-08 14:51:50 UTC
(rev 3110)
@@ -20,20 +20,26 @@
#ifndef HEADER_EDITOR_OBJECT_PROPERTIES_HPP
#define HEADER_EDITOR_OBJECT_PROPERTIES_HPP
+
+#include "gui/group_component.hpp"
+
namespace Editor {
+class EditorScreen;
+
/** */
-class ObjectProperties
+class ObjectProperties : public GUI::GroupComponent
{
private:
- Editor* editor;
+ EditorScreen* editor;
LevelObj* current_object;
public:
- ObjectProperties(EditorScreen* editor);
+ ObjectProperties(EditorScreen* editor, const Rect& rect);
~ObjectProperties();
void set_object(LevelObj* obj);
+ void draw_background(DrawingContext& gc);
private:
ObjectProperties (const ObjectProperties&);
Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/editor/object_selector.cpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -139,7 +139,7 @@
: editor(editor_),
button_pos(0,0),
rect(Vector2i(Display::get_width() - 244 + 2, 38 + 3 + 62),
- Size(240, 495)),
+ Size(240, Display::get_height() - (600 - 495))),
drawing_context(new DrawingContext(rect)),
offset(0),
old_offset(0),
Modified: trunk/pingus/src/gui/group_component.cpp
===================================================================
--- trunk/pingus/src/gui/group_component.cpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/gui/group_component.cpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -152,7 +152,7 @@
{
for(Components::iterator i = children.begin(); i != children.end(); ++i)
{
- if ((*i)->is_at(pos.x, pos.y))
+ if ((*i)->is_visible() && (*i)->is_at(pos.x, pos.y))
return *i;
}
return 0;
@@ -163,6 +163,12 @@
{
children.push_back(comp);
}
+
+void
+GroupComponent::update_layout()
+{
+ drawing_context.set_rect(rect);
+}
} // namespace GUI
Modified: trunk/pingus/src/gui/group_component.hpp
===================================================================
--- trunk/pingus/src/gui/group_component.hpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/gui/group_component.hpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -68,6 +68,8 @@
void add(Component*, bool delete_comp);
+ void update_layout();
+
Component* component_at (const Vector2i& pos);
private:
GroupComponent(const GroupComponent&);
Modified: trunk/pingus/src/gui/gui_manager.cpp
===================================================================
--- trunk/pingus/src/gui/gui_manager.cpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/gui/gui_manager.cpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -129,7 +129,7 @@
for (std::vector<Component*>::reverse_iterator i = components.rbegin ();
i != components.rend (); ++i)
{
- if ((*i)->is_at (x, y))
+ if ((*i)->is_visible() && (*i)->is_at (x, y))
return *i;
}
return 0;
Modified: trunk/pingus/src/gui/rect_component.hpp
===================================================================
--- trunk/pingus/src/gui/rect_component.hpp 2007-09-08 14:51:08 UTC (rev
3109)
+++ trunk/pingus/src/gui/rect_component.hpp 2007-09-08 14:51:50 UTC (rev
3110)
@@ -44,6 +44,8 @@
rect = rect_;
update_layout();
}
+
+ Rect get_rect() const { return rect; }
};
} // namespace GUI
Modified: trunk/pingus/src/system.cpp
===================================================================
--- trunk/pingus/src/system.cpp 2007-09-08 14:51:08 UTC (rev 3109)
+++ trunk/pingus/src/system.cpp 2007-09-08 14:51:50 UTC (rev 3110)
@@ -523,5 +523,61 @@
#endif
}
+std::string
+System::realpath(const std::string& pathname)
+{
+ std::string fullpath;
+
+ if (pathname.size() > 0 && pathname[0] == '/')
+ {
+ fullpath = pathname;
+ }
+ else
+ {
+ char buf[PATH_MAX];
+ if (getcwd(buf, PATH_MAX) == 0)
+ {
+ std::cout << "System::realpath: Error: couldn't getcwd()" <<
std::endl;
+ return pathname;
+ }
+
+ fullpath = fullpath + buf + "/" + pathname;
+ }
+
+ std::string result;
+ std::string::reverse_iterator last_slash = fullpath.rbegin();
+ int skip = 0;
+ // /foo/bar/../../bar/baz/
+ //std::cout << "fullpath: '" << fullpath << "'" << std::endl;
+ for(std::string::reverse_iterator i = fullpath.rbegin(); i !=
fullpath.rend(); ++i)
+ { // FIXME: Little crude and hackish
+ if (*i == '/')
+ {
+ std::string dir(last_slash, i);
+ //std::cout << "'" << dir << "'" << std::endl;
+ if (dir == ".." || dir == "/..")
+ {
+ skip += 1;
+ }
+ else if (dir == "." || dir == "/." || dir.empty() || dir == "/")
+ {
+ // pass
+ }
+ else
+ {
+ if (skip == 0)
+ {
+ result += dir;
+ }
+ else
+ skip -= 1;
+ }
+ last_slash = i;
+ }
+ }
+
+ return "/" + std::string(result.rbegin(), result.rend());
+}
+
/* EOF */
Modified: trunk/pingus/src/system.hpp
===================================================================
--- trunk/pingus/src/system.hpp 2007-09-08 14:51:08 UTC (rev 3109)
+++ trunk/pingus/src/system.hpp 2007-09-08 14:51:50 UTC (rev 3110)
@@ -125,6 +125,9 @@
/** Translate to 'en' */
static std::string translate_default(const std::map<std::string,
std::string>& strs);
+ /** Removes all .., double slashes and such from a pathname */
+ static std::string realpath(const std::string& pathname);
+
/** Read a file and generate a checksum and return it. The checksum
generation is very primitiv and should probably be replaced by CRC
or md5. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3110 - in trunk/pingus/src: . display editor gui,
grumbel at BerliOS <=