pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3107 - in trunk/pingus/src: . editor gui


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3107 - in trunk/pingus/src: . editor gui
Date: Fri, 7 Sep 2007 23:11:14 +0200

Author: grumbel
Date: 2007-09-07 23:11:14 +0200 (Fri, 07 Sep 2007)
New Revision: 3107

Added:
   trunk/pingus/src/gui/group_component.cpp
   trunk/pingus/src/gui/group_component.hpp
Modified:
   trunk/pingus/src/SConscript
   trunk/pingus/src/editor/file_load_dialog.cpp
   trunk/pingus/src/editor/file_load_dialog.hpp
   trunk/pingus/src/gui/component.hpp
   trunk/pingus/src/gui/gui_manager.cpp
Log:
- added visibility toggle for components
- added groupcompanent (dummy file)

Modified: trunk/pingus/src/SConscript
===================================================================
--- trunk/pingus/src/SConscript 2007-09-07 16:59:48 UTC (rev 3106)
+++ trunk/pingus/src/SConscript 2007-09-07 21:11:14 UTC (rev 3107)
@@ -129,7 +129,8 @@
 'groundtype.cpp', 
 'gui/checkbox.cpp',
 'gui/combobox.cpp', 
-'gui/cursor.cpp', 
+'gui/cursor.cpp',
+'gui/group_component.cpp', 
 'gui/display.cpp', 
 'gui/gui_manager.cpp', 
 'gui/gui_screen.cpp', 

Modified: trunk/pingus/src/editor/file_load_dialog.cpp
===================================================================
--- trunk/pingus/src/editor/file_load_dialog.cpp        2007-09-07 16:59:48 UTC 
(rev 3106)
+++ trunk/pingus/src/editor/file_load_dialog.cpp        2007-09-07 21:11:14 UTC 
(rev 3107)
@@ -25,6 +25,7 @@
 
 #include <iostream>
 #include <boost/bind.hpp>
+#include "display/drawing_context.hpp"
 #include "gui/gui_manager.hpp"
 #include "editor_screen.hpp"
 #include "file_load_dialog.hpp"
@@ -45,16 +46,24 @@
 FileLoadDialog::~FileLoadDialog()
 {
 }
+
+void
+FileLoadDialog::draw(DrawingContext& gc)
+{
+  gc.draw_fillrect(rect.left, rect.top, rect.right, rect.bottom, Color(100, 
100, 100), -10);
+}
   
 void
 FileLoadDialog::load_file(const std::string& file) const
 {
   std::cout << "FileLoadDialog::load_file: " << file << std::endl;
+  
 }
 
 void
-FileLoadDialog::set_directory(const std::string& pathname)
+FileLoadDialog::set_directory(const std::string& pathname_)
 {
+  pathname = pathname_;
   file_list.set_directory(pathname);
 }
 

Modified: trunk/pingus/src/editor/file_load_dialog.hpp
===================================================================
--- trunk/pingus/src/editor/file_load_dialog.hpp        2007-09-07 16:59:48 UTC 
(rev 3106)
+++ trunk/pingus/src/editor/file_load_dialog.hpp        2007-09-07 21:11:14 UTC 
(rev 3107)
@@ -39,6 +39,7 @@
 private:
   EditorScreen* editor;
   FileList file_list;
+  std::string pathname;
 
 public:
   FileLoadDialog(EditorScreen* editor, const Rect& rect);
@@ -46,7 +47,7 @@
   
   bool is_at(int x, int y) { return false; }
 
-  void draw(DrawingContext&) {}
+  void draw(DrawingContext& gc);
   void update_layout() {}
 
   void load_file(const std::string& file) const;

Modified: trunk/pingus/src/gui/component.hpp
===================================================================
--- trunk/pingus/src/gui/component.hpp  2007-09-07 16:59:48 UTC (rev 3106)
+++ trunk/pingus/src/gui/component.hpp  2007-09-07 21:11:14 UTC (rev 3107)
@@ -25,18 +25,17 @@
 class DrawingContext;
 
 namespace GUI {
-
+
 /** A component represents an area which recivies events in the GUI,
     some people might call it a widget */
 class Component
 {
-private:
-       
 protected:
   bool has_focus;
+  bool visible;
 
 public:
-  Component () : has_focus(false) { }
+  Component () : has_focus(false), visible(true) { }
   virtual ~Component() {}
 
   virtual void set_focus(bool val) { has_focus = val; }
@@ -53,8 +52,6 @@
   /** Gets issued once the primary button is released */
   virtual void on_primary_button_release (int x, int y) { UNUSED_ARG(x); 
UNUSED_ARG(y); }
 
-  virtual void on_primary_button_double_click (int x, int y) { UNUSED_ARG(x); 
UNUSED_ARG(y); }
-
   virtual void on_secondary_button_press (int x, int y) { UNUSED_ARG(x); 
UNUSED_ARG(y); }
   virtual void on_secondary_button_release (int x, int y) { UNUSED_ARG(x); 
UNUSED_ARG(y); }
 
@@ -78,11 +75,16 @@
       components should implement this */
   virtual void on_key_pressed(const unsigned short c) { UNUSED_ARG(c); }
 
+  virtual void hide() { visible = false; }
+  virtual void show() { visible = true; }
+
+  virtual bool is_visible() { return visible; }
+
 private:
   Component (const Component&);
   Component& operator= (const Component&);
 };
-
+
 } // namespace GUI
 
 #endif

Added: trunk/pingus/src/gui/group_component.cpp
===================================================================
--- trunk/pingus/src/gui/group_component.cpp    2007-09-07 16:59:48 UTC (rev 
3106)
+++ trunk/pingus/src/gui/group_component.cpp    2007-09-07 21:11:14 UTC (rev 
3107)
@@ -0,0 +1,114 @@
+/*  $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 "group_component.hpp"
+
+namespace GUI {
+
+GroupComponent::GroupComponent(const Rect& rect)
+  : RectComponent(rect)
+{
+}
+
+GroupComponent::~GroupComponent()
+{
+}
+       
+void
+GroupComponent::draw (DrawingContext& gc)
+{
+}
+
+void
+GroupComponent::update (float delta)
+{
+}
+
+bool is_at (int x, int y);
+
+void
+GroupComponent::on_primary_button_press (int x, int y)
+{
+}
+
+void
+GroupComponent::on_primary_button_release (int x, int y)
+{
+}
+
+void
+GroupComponent::on_primary_button_double_click (int x, int y)
+{
+}
+  
+void
+GroupComponent::on_secondary_button_press (int x, int y)
+{
+}
+
+void
+GroupComponent::on_secondary_button_release (int x, int y)
+{
+}
+
+void
+GroupComponent::on_primary_button_click (int x, int y)
+{
+}
+
+void
+GroupComponent::on_secondary_button_click (int x, int y)
+{
+}
+
+void
+GroupComponent::on_pointer_enter () 
+{
+}
+
+void
+GroupComponent::on_pointer_leave () 
+{
+}
+
+void
+GroupComponent::on_pointer_move (int x, int y)
+{
+}
+
+void
+GroupComponent::on_key_pressed(const unsigned short c)
+{
+}
+
+void
+GroupComponent::add(Component*)
+{
+  
+}
+
+} // namespace GUI
+
+/* EOF */


Property changes on: trunk/pingus/src/gui/group_component.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/pingus/src/gui/group_component.hpp
===================================================================
--- trunk/pingus/src/gui/group_component.hpp    2007-09-07 16:59:48 UTC (rev 
3106)
+++ trunk/pingus/src/gui/group_component.hpp    2007-09-07 21:11:14 UTC (rev 
3107)
@@ -0,0 +1,77 @@
+/*  $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_PINGUS_GUI_GROUP_COMPONENT_HPP
+#define HEADER_PINGUS_GUI_GROUP_COMPONENT_HPP
+
+#include "display/drawing_context.hpp"
+#include "rect_component.hpp"
+
+namespace GUI {
+
+/** */
+class GroupComponent : public RectComponent
+{
+private:
+  std::vector<Component> children;
+  DrawingContext drawing_context;
+  
+public:
+  GroupComponent(const Rect& rect);
+  ~GroupComponent();  
+       
+  void draw (DrawingContext& gc);
+  void update (float delta);
+
+  void on_primary_button_press (int x, int y);
+  void on_primary_button_release (int x, int y);
+
+  void on_primary_button_double_click (int x, int y);
+  
+  void on_secondary_button_press (int x, int y);
+  void on_secondary_button_release (int x, int y);
+  
+  void on_primary_button_click (int x, int y);
+  void on_secondary_button_click (int x, int y);
+
+  void on_pointer_enter ();
+  void on_pointer_leave ();
+
+  void on_pointer_move (int x, int y);
+
+  void on_key_pressed(const unsigned short c);
+
+  void add(Component*);
+
+private:
+  GroupComponent (const GroupComponent&);
+  GroupComponent& operator= (const GroupComponent&);
+};
+
+} // namespace GUI
+
+#endif
+
+/* EOF */


Property changes on: trunk/pingus/src/gui/group_component.hpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/pingus/src/gui/gui_manager.cpp
===================================================================
--- trunk/pingus/src/gui/gui_manager.cpp        2007-09-07 16:59:48 UTC (rev 
3106)
+++ trunk/pingus/src/gui/gui_manager.cpp        2007-09-07 21:11:14 UTC (rev 
3107)
@@ -54,7 +54,8 @@
   for (std::vector<Component*>::iterator i = components.begin ();
        i != components.end (); ++i)
     {
-      (*i)->draw (gc);
+      if ((*i)->is_visible())
+        (*i)->draw (gc);
     }
 }
 
@@ -66,7 +67,8 @@
   for (std::vector<Component*>::iterator i = components.begin ();
        i != components.end (); ++i)
     {
-      (*i)->update (delta.get_time ());
+      if ((*i)->is_visible())
+        (*i)->update (delta.get_time ());
     }
 }
 
@@ -139,7 +141,7 @@
   for (std::vector<Component*>::iterator i = components.begin ();
        i != components.end (); ++i)
     {
-      if ((*i)->is_at (x, y))
+      if ((*i)->is_visible() && (*i)->is_at (x, y))
        return true;
     }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]