[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3175 - in trunk/pingus: . src src/editor src/gui
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3175 - in trunk/pingus: . src src/editor src/gui |
Date: |
Tue, 18 Sep 2007 03:27:05 +0200 |
Author: grumbel
Date: 2007-09-18 03:27:03 +0200 (Tue, 18 Sep 2007)
New Revision: 3175
Added:
trunk/pingus/src/gui/component.cpp
Modified:
trunk/pingus/TODO
trunk/pingus/src/SConscript
trunk/pingus/src/editor/combobox.cpp
trunk/pingus/src/editor/combobox.hpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/gui/component.hpp
trunk/pingus/src/gui/group_component.cpp
trunk/pingus/src/gui/group_component.hpp
Log:
- make combobox work better (open to top, grab input when opened)
- new file src/gui/component.cpp
Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO 2007-09-17 22:15:31 UTC (rev 3174)
+++ trunk/pingus/TODO 2007-09-18 01:27:03 UTC (rev 3175)
@@ -106,6 +106,8 @@
- level converter has a bug that causes some object types to be
ignored (startpos and likely the other more excotic worldobj things)
+- level converter writes 0/1 instead of #t/#f
+
- menu crashes when you click a little wildely
- "core/misc/404sprite" isn't returned for missing graphics
@@ -158,8 +160,6 @@
- convert all levels and check all classic levels for issues (run
branches/pingus_sdl/contribl/levelconvert.sh from SVN toplevel dir)
-- level converter writes 0/1 instead of #t/#f
-
- add drag&drop scrolling
- nuke button is unclean, other buttons not so great either -> repaint
@@ -170,6 +170,7 @@
(isn't used in tutorial island, since those levels don't have time)
(have a blinking clock and tick sound or so)
+- write a README.input
Roadmap for Pingus Editor 0.7.1:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -179,12 +180,6 @@
- add object duplication
-- add color prop for surface-background
-
-- add position prop for all LevelObjs
-
-- make GPType prop
-
- ObjectSelector need to support more object types: Starbackground,
SolidColorBackground
- keyboard shortcuts need to be implemented (use input framework, but
@@ -195,7 +190,7 @@
d - duplicate
delete - delete object
insert - show/hide objectselector
- cursor - pixel width moves
+ cursor - pixel width moves (alternative: hold a button for slow moves)
f - hflip
shift+f - vflip
r - rotate90
@@ -204,17 +199,15 @@
- implement proper tmpfile Support (save tmp levels to ~/.pingus/tmp/
for backup purpose in case of editor crash or so)
-- make combo box open to the top or bottom depending on variable
-
- add options to show/hide hidden files and filter stuff
- add new level and save level dialogs
-- write a README.input
-
Less Important:
===============
+- add pixel perfect object selection
+
- implement a minimap (just rects when surfaces are to tricky)
- could/should rotate around object center
Modified: trunk/pingus/src/SConscript
===================================================================
--- trunk/pingus/src/SConscript 2007-09-17 22:15:31 UTC (rev 3174)
+++ trunk/pingus/src/SConscript 2007-09-18 01:27:03 UTC (rev 3175)
@@ -136,7 +136,8 @@
'globals.cpp',
'goal_manager.cpp',
'graphic_context_state.cpp',
-'groundtype.cpp',
+'groundtype.cpp',
+'gui/component.cpp',
'gui/checkbox.cpp',
'gui/combobox.cpp',
'gui/cursor.cpp',
Modified: trunk/pingus/src/editor/combobox.cpp
===================================================================
--- trunk/pingus/src/editor/combobox.cpp 2007-09-17 22:15:31 UTC (rev
3174)
+++ trunk/pingus/src/editor/combobox.cpp 2007-09-18 01:27:03 UTC (rev
3175)
@@ -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 <vector>
#include <string>
#include "resource.hpp"
@@ -73,6 +74,7 @@
{
// Determine which item was selected, if any, and set the current item
to it.
drop_down = false;
+ ungrab();
if (hover_item != -1)
{
@@ -83,6 +85,13 @@
else
{
drop_down = true;
+ grab();
+
+ list_rect = Rect(Vector2i(rect.left,
+ rect.top + get_box_offset()),
+ Size(rect.get_width(),
+ rect.get_height() * item_list.size()));
+
on_pointer_move(x,y);
}
}
@@ -90,16 +99,21 @@
void
Combobox::draw(DrawingContext &gc)
{
+ { // draw the unopened box
+ gc.draw_fillrect(rect, Color(255,255,255));
+ gc.draw(sprite, Vector2i(rect.right - 12, rect.top));
+ gc.draw_rect(rect, Color(0,0,0));
+
+ if (current_item != -1)
+ {
+ gc.print_left(Fonts::verdana11, rect.left + 5,
+ rect.top + rect.get_height()/2 -
Fonts::verdana11.get_height()/2,
+ item_list[current_item].label);
+ }
+ }
+
if (drop_down && !item_list.empty())
{
- int y_offset = get_box_offset();
-
- Rect list_rect(Vector2i(rect.left,
- rect.top + y_offset),
- Size(rect.get_width(),
- item_list.size() * rect.get_height()));
-
-
gc.draw_fillrect(list_rect, Color(255,255,255), 90);
for (int i = 0; i < int(item_list.size()); ++i)
@@ -117,25 +131,16 @@
gc.draw_rect(list_rect, Color(0,0,0), 100);
}
- else
- {
- gc.draw_fillrect(rect, Color(255,255,255));
- gc.draw(sprite, Vector2i(rect.right - 12, rect.top));
- gc.draw_rect(rect, Color(0,0,0));
-
- if (current_item != -1)
- {
- gc.print_left(Fonts::verdana11, rect.left + 5,
- rect.top + rect.get_height()/2 -
Fonts::verdana11.get_height()/2,
- item_list[current_item].label);
- }
- }
}
int
Combobox::get_box_offset()
{
- return -(rect.get_height() * current_item);
+ // open over the current item
+ //return -(rect.get_height() * current_item);
+
+ // open to the top
+ return -(rect.get_height() * item_list.size());
}
bool
@@ -151,13 +156,19 @@
}
void
-Combobox::on_pointer_move(int x, int y)
+Combobox::on_pointer_move(int x, int y)
{
if (drop_down)
{
- hover_item = (y - rect.top - get_box_offset()) / rect.get_height();
- if (hover_item < 0 || hover_item >= int(item_list.size()))
- hover_item = -1;
+ if (list_rect.is_inside(Vector2i(x,y)))
+ {
+ hover_item = (y - list_rect.top) / rect.get_height();
+ hover_item = Math::clamp(0, hover_item, int(item_list.size()-1));
+ }
+ else
+ {
+ hover_item = -1;
+ }
}
}
Modified: trunk/pingus/src/editor/combobox.hpp
===================================================================
--- trunk/pingus/src/editor/combobox.hpp 2007-09-17 22:15:31 UTC (rev
3174)
+++ trunk/pingus/src/editor/combobox.hpp 2007-09-18 01:27:03 UTC (rev
3175)
@@ -47,6 +47,7 @@
{
protected:
Sprite sprite;
+ Rect list_rect;
/** List of items in this Combobox */
std::vector<ComboItem> item_list;
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2007-09-17 22:15:31 UTC
(rev 3174)
+++ trunk/pingus/src/editor/object_properties.cpp 2007-09-18 01:27:03 UTC
(rev 3175)
@@ -225,7 +225,7 @@
unsigned int attr = obj->get_attribs();
if (attr & HAS_GPTYPE)
{
-
gptype_type->set_selected_item(Groundtype::string_to_type(obj->get_type()));
+
gptype_type->set_selected_item(Groundtype::string_to_type(obj->get_ground_type()));
place(gptype_label, gptype_type);
}
Added: trunk/pingus/src/gui/component.cpp
===================================================================
--- trunk/pingus/src/gui/component.cpp 2007-09-17 22:15:31 UTC (rev 3174)
+++ trunk/pingus/src/gui/component.cpp 2007-09-18 01:27:03 UTC (rev 3175)
@@ -0,0 +1,55 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// 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 <assert.h>
+#include "group_component.hpp"
+#include "component.hpp"
+
+namespace GUI {
+
+GroupComponent*
+Component::get_parent() const
+{
+ return parent;
+}
+
+void
+Component::set_parent(GroupComponent* p)
+{
+ assert(parent == 0);
+ parent = p;
+}
+
+void
+Component::grab()
+{
+ if (parent)
+ parent->grab(this);
+}
+
+void
+Component::ungrab()
+{
+ if (parent)
+ parent->ungrab(this);
+}
+
+} // namespace GUI
+
+/* EOF */
Property changes on: trunk/pingus/src/gui/component.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/pingus/src/gui/component.hpp
===================================================================
--- trunk/pingus/src/gui/component.hpp 2007-09-17 22:15:31 UTC (rev 3174)
+++ trunk/pingus/src/gui/component.hpp 2007-09-18 01:27:03 UTC (rev 3175)
@@ -26,17 +26,20 @@
namespace GUI {
+class GroupComponent;
+
/** A component represents an area which recivies events in the GUI,
some people might call it a widget */
class Component
{
private:
+ GroupComponent* parent;
bool focus;
bool mouse_over;
bool visible;
public:
- Component () : focus(false), mouse_over(false), visible(true) { }
+ Component () : parent(0), focus(false), mouse_over(false), visible(true) { }
virtual ~Component() {}
virtual void set_focus(bool val) { focus = val; }
@@ -85,6 +88,12 @@
components should implement this */
virtual void on_key_pressed(const unsigned short c) { UNUSED_ARG(c); }
+ GroupComponent* get_parent() const;
+ void set_parent(GroupComponent* p);
+
+ void grab();
+ void ungrab();
+
private:
Component (const Component&);
Component& operator= (const Component&);
Modified: trunk/pingus/src/gui/group_component.cpp
===================================================================
--- trunk/pingus/src/gui/group_component.cpp 2007-09-17 22:15:31 UTC (rev
3174)
+++ trunk/pingus/src/gui/group_component.cpp 2007-09-18 01:27:03 UTC (rev
3175)
@@ -76,7 +76,7 @@
if (grabbed_comp)
{
- grabbed_comp->on_pointer_move(mouse_pos.x, mouse_pos.y);
+ grabbed_comp->on_primary_button_press(mouse_pos.x, mouse_pos.y);
}
else
{
@@ -105,7 +105,7 @@
if (grabbed_comp)
{
- grabbed_comp->on_pointer_move(mouse_pos.x, mouse_pos.y);
+ grabbed_comp->on_primary_button_release(mouse_pos.x, mouse_pos.y);
}
else
{
@@ -135,7 +135,7 @@
if (grabbed_comp)
{
- grabbed_comp->on_pointer_move(mouse_pos.x, mouse_pos.y);
+ grabbed_comp->on_secondary_button_press(mouse_pos.x, mouse_pos.y);
}
else
{
@@ -157,7 +157,7 @@
if (grabbed_comp)
{
- grabbed_comp->on_pointer_move(mouse_pos.x, mouse_pos.y);
+ grabbed_comp->on_secondary_button_release(mouse_pos.x, mouse_pos.y);
}
else if (secondary_pressed_comp)
{
@@ -244,6 +244,7 @@
void
GroupComponent::add(Component* comp, bool delete_comp)
{
+ comp->set_parent(this);
children.push_back(comp);
}
@@ -277,12 +278,14 @@
GroupComponent::grab(Component* comp)
{
grabbed_comp = comp;
+ Component::grab();
}
void
GroupComponent::ungrab(Component* comp)
{
grabbed_comp = 0;
+ Component::ungrab();
}
} // namespace GUI
Modified: trunk/pingus/src/gui/group_component.hpp
===================================================================
--- trunk/pingus/src/gui/group_component.hpp 2007-09-17 22:15:31 UTC (rev
3174)
+++ trunk/pingus/src/gui/group_component.hpp 2007-09-18 01:27:03 UTC (rev
3175)
@@ -79,7 +79,7 @@
// Causes all input directed to comp
void grab(Component* comp);
- void ungrab(Component*);
+ void ungrab(Component* comp);
Component* component_at (const Vector2i& pos);
private:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3175 - in trunk/pingus: . src src/editor src/gui,
grumbel at BerliOS <=