windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 352 - trunk/src


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 352 - trunk/src
Date: Thu, 27 May 2004 14:04:43 +0200

Author: grumbel
Date: 2004-05-27 14:04:43 +0200 (Thu, 27 May 2004)
New Revision: 352

Added:
   trunk/src/scrollbar.cxx
   trunk/src/scrollbar.hxx
   trunk/src/viewport.cxx
   trunk/src/viewport.hxx
Modified:
   trunk/src/SConstruct
   trunk/src/editor.py
   trunk/src/flexlay.i
   trunk/src/graphic_context_state.cxx
   trunk/src/graphic_context_state.hxx
   trunk/src/titlebar.cxx
   trunk/src/window.cxx
Log:
- added scrollbar and viewport dummy

Modified: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct        2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/SConstruct        2004-05-27 12:04:43 UTC (rev 352)
@@ -96,6 +96,7 @@
     'menubar.cxx',
     'popup_menu.cxx',
     'lispreader.cxx',
+    'scrollbar.cxx',
     'tile.cxx',
     'titlebar.cxx',
     'tile_brush.cxx',
@@ -110,6 +111,7 @@
     'tool_manager.cxx',
     'workspace.cxx',
     'window.cxx',
+    'viewport.cxx',
     'zoom_tool.cxx'],
     CPPPATH=['/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/',
              '..'],

Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/editor.py 2004-05-27 12:04:43 UTC (rev 352)
@@ -64,6 +64,11 @@
 dirview = DirectoryView(CL_Rect(CL_Point(3, 40), CL_Size(300, 200)), 
gui.get_component())
 dirview.set_directory("/");
 
+scrollbar = Scrollbar(CL_Rect(CL_Point(370, 5), CL_Size(12, 300)), 
gui.get_component())
+scrollbar.set_range(50, 150)
+scrollbar.set_pagesize(10)
+scrollbar.set_pos(100)
+
 load_icon    = Icon(CL_Point(34*0+2, 2), 
make_sprite("../data/images/icons24/stock_open.png"), "Some tooltip", 
gui.get_component());
 save_icon    = Icon(CL_Point(34*1+2, 2), 
make_sprite("../data/images/icons24/stock_save.png"), "Some tooltip", 
gui.get_component());
 save_as_icon = Icon(CL_Point(34*2+2, 2), 
make_sprite("../data/images/icons24/stock_save_as.png"), "Some tooltip", 
gui.get_component());

Modified: trunk/src/flexlay.i
===================================================================
--- trunk/src/flexlay.i 2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/flexlay.i 2004-05-27 12:04:43 UTC (rev 352)
@@ -39,6 +39,7 @@
 #include "directory_view.hxx"
 #include "menu.hxx"
 #include "menubar.hxx"
+#include "scrollbar.hxx"
 %}
 
 %include "std_string.i"
@@ -77,5 +78,7 @@
 %include "directory_view.hxx"
 %include "menu.hxx"
 %include "menubar.hxx"
+%include "scrollbar.hxx"
 
+
 /* EOF */

Modified: trunk/src/graphic_context_state.cxx
===================================================================
--- trunk/src/graphic_context_state.cxx 2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/graphic_context_state.cxx 2004-05-27 12:04:43 UTC (rev 352)
@@ -21,12 +21,24 @@
 #include <ClanLib/GUI/component.h>
 #include "graphic_context_state.hxx"
 
+GraphicContextState::GraphicContextState()
+  : width(1), height(1), offset(0,0), zoom(1.0f)
+{
+}
+
 GraphicContextState::GraphicContextState(int w, int h)
   : width(w), height(h), offset(0,0), zoom(1.0f)
 {  
 }
 
 void
+GraphicContextState::set_size(int w, int h)
+{
+  width  = w;
+  height = h;
+}
+
+void
 GraphicContextState::push()
 {
   CL_Display::push_modelview();
@@ -57,7 +69,7 @@
 }
 
 CL_Pointf
-GraphicContextState::get_pos()
+GraphicContextState::get_pos() const
 {
   return CL_Pointf(-offset.x + (get_width()/2  / zoom),
                    -offset.y + (get_height()/2  / zoom));

Modified: trunk/src/graphic_context_state.hxx
===================================================================
--- trunk/src/graphic_context_state.hxx 2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/graphic_context_state.hxx 2004-05-27 12:04:43 UTC (rev 352)
@@ -38,9 +38,11 @@
   float zoom;
 
 public:
-  GraphicContextState() {}
+  GraphicContextState();
   GraphicContextState(int w, int h);
 
+  void set_size(int w, int h);
+
   void push();
   void pop();
 
@@ -48,11 +50,11 @@
       visible on the screen */
   CL_Rect get_clip_rect();
 
-  int get_width()  { return width; }
-  int get_height() { return height; }
+  int get_width()  const { return width; }
+  int get_height() const { return height; }
 
   void      set_pos(const CL_Pointf& pos);
-  CL_Pointf get_pos();
+  CL_Pointf get_pos() const;
 
   /** Set zoom to z, while preserving the screen position pos at the same 
point */
   void  set_zoom(CL_Point pos, float z);

Added: trunk/src/scrollbar.cxx
===================================================================
--- trunk/src/scrollbar.cxx     2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/scrollbar.cxx     2004-05-27 12:04:43 UTC (rev 352)
@@ -0,0 +1,89 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2002 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 <ClanLib/Display/display.h>
+#include "scrollbar.hxx"
+
+class ScrollbarImpl
+{
+public:
+  std::vector<CL_Slot> slots;
+
+  ScrollbarImpl(Scrollbar* parent_) : parent(parent_) {}
+
+  Scrollbar* parent;
+  float min;
+  float max;
+  float pagesize;
+  float pos;
+  
+  void draw();
+};
+
+Scrollbar::Scrollbar(const CL_Rect& rect, CL_Component* parent)
+  : CL_Component(rect, parent),
+    impl(new ScrollbarImpl(this))
+{
+  impl->min = 0;
+  impl->max = 100;
+  impl->pagesize = 10;
+  impl->pos  = 0;
+
+  impl->slots.push_back(sig_paint().connect(impl.get(), &ScrollbarImpl::draw));
+}
+  
+void
+Scrollbar::set_range(float min, float max)
+{
+  impl->min = min;
+  impl->max = max;
+}
+
+void
+Scrollbar::set_pagesize(float size)
+{
+  impl->pagesize = size;  
+}
+
+void
+Scrollbar::set_pos(float pos)
+{
+  impl->pos = pos;
+}
+
+void 
+ScrollbarImpl::draw()
+{
+  CL_Rect rect = CL_Rect(CL_Point(0, 0), 
+                         CL_Size(parent->get_width()-1,
+                                 parent->get_height()-1));
+  CL_Display::fill_rect(rect,
+                        CL_Color(255, 255, 255));
+  CL_Display::draw_rect(rect,
+                        CL_Color(155, 155, 155));
+
+  float scale = parent->get_height()/(max - min);
+
+  CL_Display::fill_rect(CL_Rect(CL_Point(2, int((pos-min-(pagesize/2)) * 
scale)), 
+                                CL_Size(parent->get_width()-5,
+                                        int(pagesize*scale))),
+                        CL_Color(0, 0, 0));
+}
+
+/* EOF */

Added: trunk/src/scrollbar.hxx
===================================================================
--- trunk/src/scrollbar.hxx     2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/scrollbar.hxx     2004-05-27 12:04:43 UTC (rev 352)
@@ -0,0 +1,44 @@
+//  $Id$
+// 
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2002 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_SCROLLBAR_HXX
+#define HEADER_SCROLLBAR_HXX
+
+#include <ClanLib/GUI/component.h>
+#include <ClanLib/Core/Math/rect.h>
+#include "shared_ptr.hxx"
+
+class ScrollbarImpl;
+
+/** */
+class Scrollbar : public CL_Component
+{
+public:
+  Scrollbar(const CL_Rect& rect, CL_Component* parent);
+  
+  void set_range(float min, float max);
+  void set_pagesize(float size);
+  void set_pos(float pos);
+private:
+  SharedPtr<ScrollbarImpl> impl;
+};
+
+#endif
+
+/* EOF */

Modified: trunk/src/titlebar.cxx
===================================================================
--- trunk/src/titlebar.cxx      2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/titlebar.cxx      2004-05-27 12:04:43 UTC (rev 352)
@@ -20,6 +20,7 @@
 #include <iostream>
 #include <ClanLib/Display/display.h>
 #include <ClanLib/Display/keys.h>
+#include <ClanLib/Display/mouse.h>
 #include "fonts.hxx"
 #include "titlebar.hxx"
 
@@ -99,9 +100,22 @@
 void
 TitlebarImpl::draw()
 {
-  CL_Display::fill_rect(CL_Rect(CL_Point(0, 0),
-                                CL_Size(parent->get_width()-1, 
parent->get_height())), 
-                        CL_Color(250, 250, 250));
+  // FIXME: Hack should be done via has_mouse_over(), but that doesn't include 
child components
+  if 
(parent->get_parent()->get_position().is_inside(CL_Point(CL_Mouse::get_x(), 
+                                                              
CL_Mouse::get_y())))
+      //parent->get_parent()->has_mouse_over())
+    {
+      CL_Display::fill_rect(CL_Rect(CL_Point(0, 0),
+                                    CL_Size(parent->get_width()-1, 
parent->get_height())), 
+                            CL_Color(250, 250, 250));
+    }
+  else
+    {
+      CL_Display::fill_rect(CL_Rect(CL_Point(0, 0),
+                                    CL_Size(parent->get_width()-1, 
parent->get_height())), 
+                            CL_Color(240, 240, 240));
+    }
+
   Fonts::verdana11.draw(4, 0, title);
 }
                   

Added: trunk/src/viewport.cxx
===================================================================
--- trunk/src/viewport.cxx      2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/viewport.cxx      2004-05-27 12:04:43 UTC (rev 352)
@@ -0,0 +1,50 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2002 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 "graphic_context_state.hxx"
+#include "viewport.hxx"
+
+class ViewportImpl
+{
+public:
+  CL_Component* child;
+  GraphicContextState gc_state;
+};
+
+Viewport::Viewport(CL_Component* child, const CL_Rect& rect, CL_Component* 
parent)
+  : CL_Component(rect, parent),
+    impl(new ViewportImpl())
+{
+  impl->child = child;
+  impl->gc_state.set_size(rect.get_width(), rect.get_height());
+}
+
+void
+Viewport::set_pos(const CL_Pointf& pos)
+{
+  impl->gc_state.set_pos(pos);
+}
+
+CL_Pointf
+Viewport::get_pos() const
+{
+  return impl->gc_state.get_pos();
+}
+
+/* EOF */

Added: trunk/src/viewport.hxx
===================================================================
--- trunk/src/viewport.hxx      2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/viewport.hxx      2004-05-27 12:04:43 UTC (rev 352)
@@ -0,0 +1,43 @@
+//  $Id$
+// 
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2002 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_VIEWPORT_HXX
+#define HEADER_VIEWPORT_HXX
+
+#include <ClanLib/GUI/component.h>
+#include <ClanLib/Core/Math/rect.h>
+#include "shared_ptr.hxx"
+
+class ViewportImpl;
+
+/** */
+class Viewport : public CL_Component
+{
+public:
+  Viewport(CL_Component* child, const CL_Rect& rect, CL_Component* parent);
+  
+  void set_pos(const CL_Pointf& pos);
+  CL_Pointf get_pos() const;
+private:
+  SharedPtr<ViewportImpl> impl;
+};
+
+#endif
+
+/* EOF */

Modified: trunk/src/window.cxx
===================================================================
--- trunk/src/window.cxx        2004-05-26 22:53:36 UTC (rev 351)
+++ trunk/src/window.cxx        2004-05-27 12:04:43 UTC (rev 352)
@@ -56,6 +56,7 @@
 
   void draw();
   void do_maximize();
+  void do_close();
 };
 
 Window::Window(const CL_Rect& rect, const std::string& title, CL_Component* 
parent)
@@ -84,7 +85,7 @@
 
   impl->slots.push_back(sig_paint().connect(impl.get(),      
&WindowImpl::draw));
   impl->slots.push_back(impl->maximize->sig_clicked().connect(impl.get(), 
&WindowImpl::do_maximize));
-
+  impl->slots.push_back(impl->close->sig_clicked().connect(impl.get(), 
&WindowImpl::do_close));
 }
 
 Window::~Window()
@@ -120,6 +121,12 @@
 }
 
 void
+WindowImpl::do_close()
+{
+  parent->show(false);
+}
+
+void
 WindowImpl::do_maximize()
 {
   // FIXME: Move this to scripting language





reply via email to

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