windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 333 - in trunk/src: . scripting


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 333 - in trunk/src: . scripting
Date: Sun, 16 May 2004 01:27:44 +0200

Author: grumbel
Date: 2004-05-16 01:27:44 +0200 (Sun, 16 May 2004)
New Revision: 333

Modified:
   trunk/src/
   trunk/src/SConstruct
   trunk/src/editor_map.cxx
   trunk/src/editor_map.hxx
   trunk/src/editor_map_component.cxx
   trunk/src/editor_map_component.hxx
   trunk/src/graphic_context_state.hxx
   trunk/src/minimap.cxx
   trunk/src/minimap.hxx
   trunk/src/object_layer.cxx
   trunk/src/scripting/editor.cxx
   trunk/src/scripting/editor.hxx
   trunk/src/tilemap_paint_tool.cxx
   trunk/src/workspace.cxx
   trunk/src/workspace.hxx
Log:
- more pimpl stuff



Property changes on: trunk/src
___________________________________________________________________
Name: svn:ignore
   - Makefile.in
libwindstille_editor.a
.deps
Makefile
netpanzer
collision
flexlay.semistatic
flexlay
flexlay_wrap.cxx
averagecolor
flexlay.semistatic.tar.bz2
editor
*.os
lib_flexlay.so
_flexlay.so
flexlay.py
flexlay.pyc
.sconsign

   + Makefile.in
libwindstille_editor.a
.deps
Makefile
netpanzer
collision
flexlay.semistatic
flexlay
flexlay_wrap.cxx
averagecolor
flexlay.semistatic.tar.bz2
editor
*.os
lib_flexlay.so
_flexlay.so
flexlay.py
flexlay.pyc
.sconsign
*.pyc
old


Modified: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct        2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/SConstruct        2004-05-15 23:27:44 UTC (rev 333)
@@ -40,13 +40,13 @@
     'scripting/editor.cxx',
     'editor_map.cxx',
     'editor_map_component.cxx',
-    'editor_objmap.cxx',
     'flexlay.cxx',
     'globals.cxx',
     'layer.cxx',
     'graphic_context_state.cxx',
     'gui_manager.cxx',
     'minimap.cxx',
+    'object_layer.cxx',
     'object_add_command.cxx',
     'object_brush.cxx',
     'object_delete_command.cxx',

Modified: trunk/src/editor_map.cxx
===================================================================
--- trunk/src/editor_map.cxx    2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/editor_map.cxx    2004-05-15 23:27:44 UTC (rev 333)
@@ -25,29 +25,43 @@
 #include "editor_map.hxx"
 #include "editor_map_component.hxx"
 
-EditorMap::EditorMap()
-  : background_color(100, 80, 100),
-    foreground_color(255, 80, 255)
+class EditorMapImpl
 {
-  modified = false;
-  serial = 0;
-}
+public:
+  /** Flag if the map got modified, used for 'Some maps are unsaved'
+      style massages */
+  bool modified;
 
-EditorMap::~EditorMap()
+  /** Gets incremented with each map change so that other component
+      can update if required */
+  int serial;
+
+  typedef std::vector<Layer> Layers;
+  Layers layers;
+
+  CL_Color background_color;
+  CL_Color foreground_color;
+
+  /** Metadata attached to this map (ie. mapname, description, scripts, etc.) 
*/
+#ifdef SWIGGUILE
+  SCMObj metadata;
+#endif
+};
+
+EditorMap::EditorMap()
+  : impl(new EditorMapImpl())
 {
-  /*
-    for(Layers::iterator i = layers.begin(); i != layers.end(); ++i)
-    {
-      delete (*i);
-    }
-*/
+  impl->background_color = CL_Color(100, 80, 100);
+  impl->foreground_color = CL_Color(255, 80, 255);
+  impl->modified = false;
+  impl->serial = 0;
 }
 
 void
 EditorMap::add_layer(Layer layer)
 {
-  layers.push_back(layer);
-  ++serial;
+  impl->layers.push_back(layer);
+  impl->serial += 1;
 }
 
 void
@@ -55,18 +69,45 @@
 {
   CL_Rect rect = get_bounding_rect();
 
-  CL_Display::fill_rect(rect, background_color);
-  CL_Display::draw_rect(rect, foreground_color);
-  for(Layers::iterator i = layers.begin(); i != layers.end(); ++i)
-    (*i).draw(parent);  
+  CL_Display::fill_rect(rect, impl->background_color);
+  CL_Display::draw_rect(rect, impl->foreground_color);
+  
+  for(EditorMapImpl::Layers::iterator i = impl->layers.begin(); i != 
impl->layers.end(); ++i)
+    (*i).draw(parent);
+  
   CL_Display::flush();
 }
 
+bool
+EditorMap::is_modified() const
+{
+  return impl->modified;
+}
+
+void
+EditorMap::set_unmodified() 
+{
+  impl->modified = false; 
+}
+
+void
+EditorMap::modify()
+{
+  impl->modified = true; 
+  impl->serial += 1; 
+}
+
+int
+EditorMap::get_serial() const 
+{ 
+  return impl->serial; 
+}
+
 Layer
 EditorMap::get_layer(int i)
 {
-  if (i >= 0 && i < static_cast<int>(layers.size()))
-    return layers[i];
+  if (i >= 0 && i < static_cast<int>(impl->layers.size()))
+    return impl->layers[i];
   else
     return 0;
 }
@@ -75,25 +116,25 @@
 void
 EditorMap::set_metadata(const SCMObj& obj)
 {
-  metadata = obj; 
+  impl->metadata = obj; 
 }
 
 SCMObj
 EditorMap::get_metadata() const
 {
-  return metadata; 
+  return impl->metadata; 
 }
 #endif
 
 CL_Rect
 EditorMap::get_bounding_rect()
 {
-  assert(layers.size() >= 1);
+  assert(impl->layers.size() >= 1);
   
   bool init = false;
   CL_Rect rect;
 
-  for(Layers::iterator i = layers.begin(); i != layers.end(); ++i)
+  for(EditorMapImpl::Layers::iterator i = impl->layers.begin(); i != 
impl->layers.end(); ++i)
     {
       if (i->has_bounding_rect())
         {
@@ -119,7 +160,7 @@
 void
 EditorMap::set_background_color(const CL_Color& color)
 {
-  background_color = color;
+ impl-> background_color = color;
 }
 
 /* EOF */

Modified: trunk/src/editor_map.hxx
===================================================================
--- trunk/src/editor_map.hxx    2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/editor_map.hxx    2004-05-15 23:27:44 UTC (rev 333)
@@ -30,44 +30,25 @@
 #include "layer.hxx"
 
 class EditorMapComponent;
+class EditorMapImpl;
 class TileMapTool;
 
 /** Object which represents a level, quirled together with the GUI
     stuff */
 class EditorMap
 {
-private:
-  /** Flag if the map got modified, used for 'Some maps are unsaved'
-      style massages */
-  bool modified;
-
-  /** Gets incremented with each map change so that other component
-      can update if required */
-  int serial;
-
-  typedef std::vector<Layer> Layers;
-  Layers layers;
-
-  CL_Color background_color;
-  CL_Color foreground_color;
-
-  /** Metadata attached to this map (ie. mapname, description, scripts, etc.) 
*/
-#ifdef SWIGGUILE
-  SCMObj metadata;
-#endif
 public:
   EditorMap();
-  ~EditorMap();
 
   void draw(EditorMapComponent* parent);
 
   void add_layer(Layer layer);
 
-  bool is_modified() const { return modified; }
-  void set_unmodified() { modified = false; }
-  void modify()       { modified = true; serial += 1; }
+  bool is_modified() const;
+  void set_unmodified();
+  void modify();
 
-  int get_serial() const { return serial; }
+  int get_serial() const;
 
   Layer get_layer(int i);
 
@@ -80,6 +61,9 @@
   CL_Rect get_bounding_rect();
 
   void set_background_color(const CL_Color& color);
+
+private:
+  CL_SharedPtr<EditorMapImpl> impl;
 };
 
 #endif

Modified: trunk/src/editor_map_component.cxx
===================================================================
--- trunk/src/editor_map_component.cxx  2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/editor_map_component.cxx  2004-05-15 23:27:44 UTC (rev 333)
@@ -33,7 +33,8 @@
 EditorMapComponent* EditorMapComponent::current_ = 0; 
 
 EditorMapComponent::EditorMapComponent(const CL_Rect& rect, CL_Component* 
parent)
-  : CL_Component(rect, parent)
+  : CL_Component(rect, parent),
+    workspace(rect.get_width(), rect.get_height())
 {
   current_ = this;
 
@@ -41,22 +42,20 @@
   slots.connect(sig_mouse_up(),   this, &EditorMapComponent::mouse_up);
   slots.connect(sig_mouse_down(), this, &EditorMapComponent::mouse_down);
   slots.connect(sig_mouse_move(), this, &EditorMapComponent::mouse_move);
-  
-  workspace = 0;
 }
 
 EditorMapComponent::~EditorMapComponent()
 {
 }
 
-Workspace*
+Workspace
 EditorMapComponent::get_workspace() const
 {
   return workspace;
 }
 
 void
-EditorMapComponent::set_workspace(Workspace* m)
+EditorMapComponent::set_workspace(Workspace m)
 {
   workspace = m;
 }
@@ -64,98 +63,68 @@
 void
 EditorMapComponent::mouse_up(const CL_InputEvent& event)
 {
-  if (workspace) workspace->mouse_up(event);
+  workspace.mouse_up(event);
 }
 
 void
 EditorMapComponent::mouse_move(const CL_InputEvent& event)
 {
-  if (workspace) workspace->mouse_move(event);
+  workspace.mouse_move(event);
 }
 
 void
 EditorMapComponent::mouse_down(const CL_InputEvent& event)
 {
-  if (workspace) workspace->mouse_down(event);
+  workspace.mouse_down(event);
 }
   
 void
 EditorMapComponent::draw ()
 {
-  if (workspace)
-    {
-      workspace->draw();
-    }
-  else
-    {
-      for (int y = 0; y < get_height(); y += 32)
-        for (int x = 0; x < get_width(); x += 32)
-          {
-            if (y % 2)
-              CL_Display::fill_rect(CL_Rect(CL_Point(x, y), CL_Size(32, 32)),
-                                    CL_Color(150, 150, 150));
-            else
-              CL_Display::fill_rect(CL_Rect(CL_Point(x, y), CL_Size(32, 32)),
-                                    CL_Color(50, 50, 50));
-          }
-    }
+  workspace.draw();
 }
 
 CL_Point
 EditorMapComponent::screen2world(const CL_Point& pos)
 {
-  if (workspace) 
-    {
-      CL_Pointf p = workspace->gc_state.screen2world(pos);
-      return CL_Point((int)p.x, (int)p.y);
-    }
-  else
-    {
-      return pos;
-    }
+  CL_Pointf p = workspace.get_gc_state().screen2world(pos);
+  return CL_Point((int)p.x, (int)p.y);
 }
 
 void
 EditorMapComponent::set_zoom(float z)
 {
-  if (workspace) 
-    workspace->gc_state.set_zoom(z);
+  workspace.get_gc_state().set_zoom(z);
 }
 
 void
 EditorMapComponent::zoom_out(CL_Point pos)
 {
-  if (workspace) 
-    workspace->gc_state.set_zoom(pos, workspace->gc_state.get_zoom()/1.25f);
+  workspace.get_gc_state().set_zoom(pos, 
workspace.get_gc_state().get_zoom()/1.25f);
 }
 
 void
 EditorMapComponent::zoom_in(CL_Point pos)
 {
-  if (workspace) 
-    workspace->gc_state.set_zoom(pos, workspace->gc_state.get_zoom()*1.25f);
+  workspace.get_gc_state().set_zoom(pos, 
workspace.get_gc_state().get_zoom()*1.25f);
 }
 
 void
 EditorMapComponent::zoom_to(CL_Rect rect)
 {
-  if (workspace) 
-    workspace->gc_state.zoom_to(rect);
+  workspace.get_gc_state().zoom_to(rect);
 }
 
 CL_Rect
 EditorMapComponent::get_clip_rect()
 {
-  if (workspace) 
-    return workspace->gc_state.get_clip_rect();
-  else
-    return CL_Rect();
+  return workspace.get_gc_state().get_clip_rect();
 }
 
 void
 EditorMapComponent::move_to(int x, int y)
 {
-  if (workspace) workspace->gc_state.set_pos(CL_Pointf(x, y));
+  workspace.get_gc_state().set_pos(CL_Pointf(x, y));
 }
 
 /* EOF */

Modified: trunk/src/editor_map_component.hxx
===================================================================
--- trunk/src/editor_map_component.hxx  2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/editor_map_component.hxx  2004-05-15 23:27:44 UTC (rev 333)
@@ -27,9 +27,8 @@
 #include "field.hxx"
 #include "object_layer.hxx"
 #include "graphic_context_state.hxx"
+#include "workspace.hxx"
 
-class Workspace;
-class EditorMap;
 class TileMapTool;
 
 /** Object which represents a level, quirled together with the GUI
@@ -38,7 +37,7 @@
 {
 private:
   CL_SlotContainer slots;
-  Workspace* workspace;
+  Workspace workspace;
 
   static EditorMapComponent* current_; 
 public:
@@ -47,8 +46,8 @@
   EditorMapComponent(const CL_Rect& rect, CL_Component* parent);
   ~EditorMapComponent();
  
-  Workspace* get_workspace() const;
-  void       set_workspace(Workspace* m);
+  Workspace get_workspace() const;
+  void      set_workspace(Workspace m);
 
   void  set_zoom(float z);
   void  zoom_to(CL_Rect rect);

Modified: trunk/src/graphic_context_state.hxx
===================================================================
--- trunk/src/graphic_context_state.hxx 2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/graphic_context_state.hxx 2004-05-15 23:27:44 UTC (rev 333)
@@ -38,6 +38,7 @@
   float zoom;
 
 public:
+  GraphicContextState() {}
   GraphicContextState(int w, int h);
 
   void push();

Modified: trunk/src/minimap.cxx
===================================================================
--- trunk/src/minimap.cxx       2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/minimap.cxx       2004-05-15 23:27:44 UTC (rev 333)
@@ -42,19 +42,18 @@
 
   drag_active = false;
   last_serial = -1;
-  editor_map = 0;
 }
 
 void
 Minimap::draw()
 {
   // FIXME: Do this only on map changes
-  if (last_serial != 
EditorMapComponent::current()->get_workspace()->get_current_map()->get_serial()
-      || editor_map != 
EditorMapComponent::current()->get_workspace()->get_current_map())
+  if (last_serial != 
EditorMapComponent::current()->get_workspace().get_current_map().get_serial())
+    //      || editor_map != 
EditorMapComponent::current()->get_workspace().get_current_map())
     {
       update_minimap_surface();
-      last_serial = 
EditorMapComponent::current()->get_workspace()->get_current_map()->get_serial();
-      editor_map  = 
EditorMapComponent::current()->get_workspace()->get_current_map();
+      last_serial = 
EditorMapComponent::current()->get_workspace().get_current_map().get_serial();
+      editor_map  = 
EditorMapComponent::current()->get_workspace().get_current_map();
     }
 
   if (1)

Modified: trunk/src/minimap.hxx
===================================================================
--- trunk/src/minimap.hxx       2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/minimap.hxx       2004-05-15 23:27:44 UTC (rev 333)
@@ -30,7 +30,7 @@
   bool drag_active;
   
   int last_serial;
-  EditorMap* editor_map;
+  EditorMap editor_map;
 
   EditorMapComponent* parent;
   CL_Surface minimap_surface;

Modified: trunk/src/object_layer.cxx
===================================================================
--- trunk/src/object_layer.cxx  2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/object_layer.cxx  2004-05-15 23:27:44 UTC (rev 333)
@@ -23,7 +23,7 @@
 #include <ClanLib/Core/System/error.h>
 #include "objmap_object.hxx"
 #include "objmap_sprite_object.hxx"
-#include "editor_objmap.hxx"
+#include "object_layer.hxx"
 
 extern CL_ResourceManager* resources;
 ObjectLayer* ObjectLayer::current_ = 0;

Modified: trunk/src/scripting/editor.cxx
===================================================================
--- trunk/src/scripting/editor.cxx      2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/scripting/editor.cxx      2004-05-15 23:27:44 UTC (rev 333)
@@ -733,32 +733,7 @@
   m->set_zoom(z);
 }
 
-Workspace*
-editor_map_component_get_workspace(CL_Component* c)
-{
-  EditorMapComponent* parent_map = dynamic_cast<EditorMapComponent*>(c); 
-  return parent_map->get_workspace();
-}
 
-void
-editor_map_component_set_workspace(CL_Component* c, Workspace* w)
-{
-  EditorMapComponent* parent_map = dynamic_cast<EditorMapComponent*>(c); 
-  parent_map->set_workspace(w);
-}
-
-void
-workspace_set_current_map(Workspace* workspace, EditorMap* m)
-{
-  workspace->set_current_map(m);
-}
-
-EditorMap*
-workspace_get_current_map(Workspace* workspace)
-{
-  return workspace->get_current_map();
-}
-
 // Map stuff
 EditorMap*
 editor_map_create()
@@ -996,12 +971,6 @@
                        EditorMapComponent::current()->get_height());
 }
 
-void
-workspace_add_map(Workspace* workspace, EditorMap* m, int x, int y)
-{
-  workspace->add_map(m, CL_Point(x, y));
-}
-
 void tilemap_paint_tool_set_tilemap(TilemapLayer tilemap)
 {
   TileMapPaintTool::current()->set_tilemap(tilemap);

Modified: trunk/src/scripting/editor.hxx
===================================================================
--- trunk/src/scripting/editor.hxx      2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/scripting/editor.hxx      2004-05-15 23:27:44 UTC (rev 333)
@@ -33,7 +33,6 @@
 
 #include "Python.h"
 
-class Workspace;
 class EditorMap;
 class EditorObjMap;
 class EditorTileMap;
@@ -58,9 +57,6 @@
 CL_Component* object_selector_create(int x, int y, int w, int h, int obj_w, 
int obj_h);
 CL_Component* editor_map_component_create(int x, int y, int w, int h);
 
-void          editor_map_component_set_workspace(CL_Component* c, Workspace* 
m);
-Workspace*    editor_map_component_get_workspace(CL_Component* c);
-
 void          editor_map_component_set_zoom(CL_Component* c, float z);
 
 void editor_set_brush_tile(int i);
@@ -80,12 +76,6 @@
 
 void connect(CL_Signal_v0& sig, PyObject* obj);
 
-Workspace* workspace_current();
-Workspace* workspace_create();
-void workspace_add_map(Workspace* workspace, EditorMap* m, int x, int y);
-void workspace_set_current_map(Workspace* workspace, EditorMap* m);
-EditorMap* workspace_get_current_map(Workspace* workspace);
-
 Tileset* tileset_create(int tile_size);
 #ifdef SWIGGUILE
 Tileset* tileset_create_from_file(const char* resourcefile);

Modified: trunk/src/tilemap_paint_tool.cxx
===================================================================
--- trunk/src/tilemap_paint_tool.cxx    2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/tilemap_paint_tool.cxx    2004-05-15 23:27:44 UTC (rev 333)
@@ -179,7 +179,7 @@
 {
   if (!tilemap.is_null())
     {
-      
EditorMapComponent::current()->get_workspace()->get_current_map()->modify();
+      
EditorMapComponent::current()->get_workspace().get_current_map().modify();
 
       EditorMapComponent* parent = EditorMapComponent::current();
       CL_Point pos = tilemap.world2tile(parent->screen2world(event.mouse_pos));

Modified: trunk/src/workspace.cxx
===================================================================
--- trunk/src/workspace.cxx     2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/workspace.cxx     2004-05-15 23:27:44 UTC (rev 333)
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <iostream>
 #include <ClanLib/Display/display.h>
 #include <ClanLib/Display/keys.h>
 #include "editor.hxx"
@@ -30,73 +31,49 @@
 
 Workspace* Workspace::current_ = 0;
 
-WorkspaceItem::WorkspaceItem()
+class WorkspaceImpl
 {
-  pos = CL_Point(0, 0);
-  editor_map = 0;
-}
+public:
+  GraphicContextState gc_state;
 
-WorkspaceItem::WorkspaceItem(EditorMap* m, const CL_Point& p)
-  : pos(p), editor_map(m)
-{
-}
+  bool scrolling;
+  CL_Point click_pos;
 
+  /** Position of the center */
+  CL_Pointf old_trans_offset;
+
+  EditorMap editor_map;
+};
+
 Workspace::Workspace(int w, int h)
-  : gc_state(w, h)
+  : impl(new WorkspaceImpl())
 {
   current_ = this;
-  scrolling = false;
-  click_pos = CL_Point(0, 0);
-  old_trans_offset = CL_Pointf(0,0);
 
-  // FIXME: Dummy item
-  items.push_back(new WorkspaceItem());
+  impl->gc_state  = GraphicContextState(w, h);
+  impl->scrolling = false;
+  impl->click_pos = CL_Point(0, 0);
+  impl->old_trans_offset = CL_Pointf(0,0);
 }
 
-Workspace::~Workspace()
-{
-}
-
-WorkspaceItem*
-Workspace::get_current_item()
-{
-  return items.front();
-}
-
 void
 Workspace::draw()
 {
-  gc_state.push();
+  impl->gc_state.push();
 
   CL_Display::clear(CL_Color(100, 0, 100));
-  for(Items::iterator i = items.begin(); i != items.end(); ++i)
-    {
-      if ((*i)->editor_map)
-        {
-          CL_Display::push_modelview();
-          CL_Display::add_translate((*i)->pos.x, (*i)->pos.y);
-      
-          (*i)->editor_map->draw(EditorMapComponent::current());
-      
-          CL_Display::pop_modelview();
-        }
-    }
 
+  impl->editor_map.draw(EditorMapComponent::current());
+  
   if (1) // has_mouse_over()) FIXME: Seperate cursor and state here
     Editor::current()->get_tool_manager()->current_tool()->draw();
     
   CL_Display::flush();
 
-  gc_state.pop();
+  impl->gc_state.pop();
 }
 
 void
-Workspace::add_map(EditorMap* m, const CL_Point& p)
-{
-  items.push_back(new WorkspaceItem(m, p));  
-}
-
-void
 Workspace::mouse_up(const CL_InputEvent& event)
 {
   switch (event.id)
@@ -107,10 +84,12 @@
       break;
 
     case CL_MOUSE_MIDDLE:
-      scrolling = false;
-      gc_state.set_pos(CL_Pointf(old_trans_offset.x + (click_pos.x - 
event.mouse_pos.x) / gc_state.get_zoom(),
-                                 old_trans_offset.y + (click_pos.y - 
event.mouse_pos.y) / gc_state.get_zoom()));
-      old_trans_offset = gc_state.get_pos();
+      impl->scrolling = false;
+      impl->gc_state.set_pos(CL_Pointf(impl->old_trans_offset.x
+                                       + (impl->click_pos.x - 
event.mouse_pos.x) / impl->gc_state.get_zoom(),
+                                       impl->old_trans_offset.y
+                                       + (impl->click_pos.y - 
event.mouse_pos.y) / impl->gc_state.get_zoom()));
+      impl->old_trans_offset = impl->gc_state.get_pos();
       EditorMapComponent::current()->release_mouse();
       break;
     }
@@ -121,10 +100,12 @@
 {
   Editor::current()->get_tool_manager()->current_tool()->on_mouse_move(event);
 
-  if (scrolling)
+  if (impl->scrolling)
     {
-      gc_state.set_pos(CL_Pointf(old_trans_offset.x + (click_pos.x - 
event.mouse_pos.x)/gc_state.get_zoom(),
-                                 old_trans_offset.y + (click_pos.y - 
event.mouse_pos.y)/gc_state.get_zoom()));
+      impl->gc_state.set_pos(CL_Pointf(impl->old_trans_offset.x
+                                       + (impl->click_pos.x - 
event.mouse_pos.x)/impl->gc_state.get_zoom(),
+                                       impl->old_trans_offset.y
+                                       + (impl->click_pos.y - 
event.mouse_pos.y)/impl->gc_state.get_zoom()));
     }
 }
 
@@ -139,12 +120,12 @@
       break;
 
     case CL_MOUSE_MIDDLE:
-      scrolling = true;
-      old_trans_offset = gc_state.get_pos();
-      click_pos = event.mouse_pos;
+      impl->scrolling = true;
+      impl->old_trans_offset = impl->gc_state.get_pos();
+      impl->click_pos = event.mouse_pos;
       EditorMapComponent::current()->capture_mouse();
       break;
-           
+      
     case CL_MOUSE_WHEEL_UP:
       EditorMapComponent::current()->zoom_in(event.mouse_pos);
       break;
@@ -155,16 +136,22 @@
     }
 }
 
-EditorMap*
+EditorMap
 Workspace::get_current_map()
 {
-  return items.front()->editor_map;
+  return impl->editor_map;
 }
 
 void
-Workspace::set_current_map(EditorMap* m)
+Workspace::set_current_map(EditorMap m)
 {
-  items.front()->editor_map = m;
+  impl->editor_map = m;
 }
 
+GraphicContextState&
+Workspace::get_gc_state()
+{
+  return impl->gc_state;
+}
+
 /* EOF */

Modified: trunk/src/workspace.hxx
===================================================================
--- trunk/src/workspace.hxx     2004-05-15 22:26:18 UTC (rev 332)
+++ trunk/src/workspace.hxx     2004-05-15 23:27:44 UTC (rev 333)
@@ -22,44 +22,20 @@
 
 #include <ClanLib/Display/input_event.h>
 #include "graphic_context_state.hxx"
+#include "editor_map.hxx"
 
-class EditorMap;
+class WorkspaceImpl;
 
-class WorkspaceItem
-{
-public:
-  CL_Point pos;
-  EditorMap* editor_map;
-
-public:
-  WorkspaceItem();
-  WorkspaceItem(EditorMap* m, const CL_Point& p);
-};
-
 /** */
 class Workspace
 {
 private:
-  friend class EditorMapComponent;
-  GraphicContextState gc_state;
-
-  typedef std::vector<WorkspaceItem*> Items;
-  Items items;
-
-  bool scrolling;
-  CL_Point click_pos;
-
-  /** Position of the center */
-  CL_Pointf old_trans_offset;
-
   static Workspace* current_;
-
 public:
   static void set_current(Workspace* w) { current_ = w; }
   static Workspace* current() { return current_; }
 
   Workspace(int w, int h);
-  ~Workspace();
 
   void draw();
 
@@ -67,11 +43,13 @@
   void mouse_down(const CL_InputEvent& event);
   void mouse_move(const CL_InputEvent& event);
 
-  void add_map(EditorMap* m, const CL_Point& p);
+  EditorMap get_current_map();
+  void set_current_map(EditorMap m);
 
-  WorkspaceItem* get_current_item();
-  EditorMap* get_current_map();
-  void set_current_map(EditorMap* );
+  GraphicContextState& get_gc_state();
+
+private:
+  CL_SharedPtr<WorkspaceImpl> impl;
 };
 
 #endif





reply via email to

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