[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3144 - in trunk/pingus/src: editor gui
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3144 - in trunk/pingus/src: editor gui |
Date: |
Fri, 14 Sep 2007 18:20:37 +0200 |
Author: grumbel
Date: 2007-09-14 18:20:37 +0200 (Fri, 14 Sep 2007)
New Revision: 3144
Modified:
trunk/pingus/src/editor/inputbox.cpp
trunk/pingus/src/editor/object_selector_list.cpp
trunk/pingus/src/gui/component.hpp
trunk/pingus/src/gui/group_component.cpp
trunk/pingus/src/gui/group_component.hpp
trunk/pingus/src/gui/input_box.cpp
Log:
- added has_mouse_over() function to Component
Modified: trunk/pingus/src/editor/inputbox.cpp
===================================================================
--- trunk/pingus/src/editor/inputbox.cpp 2007-09-14 15:49:18 UTC (rev
3143)
+++ trunk/pingus/src/editor/inputbox.cpp 2007-09-14 16:20:37 UTC (rev
3144)
@@ -39,7 +39,7 @@
Inputbox::draw(DrawingContext& gc)
{
gc.draw_fillrect(rect, Color(255,255,255));
- gc.draw_rect(rect, has_focus ? Color(255,128,0) : Color(0,0,0));
+ gc.draw_rect(rect, has_focus() ? Color(255,128,0) : Color(0,0,0));
gc.print_left(Fonts::verdana11, rect.left + 5,
rect.top + rect.get_height()/2 -
Fonts::verdana11.get_height()/2,
Modified: trunk/pingus/src/editor/object_selector_list.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector_list.cpp 2007-09-14 15:49:18 UTC
(rev 3143)
+++ trunk/pingus/src/editor/object_selector_list.cpp 2007-09-14 16:20:37 UTC
(rev 3144)
@@ -162,12 +162,12 @@
Objects::iterator i = objects.begin();
- for(int y = 0; y < 20; ++y)
+ for(int y = 0; y < 20; ++y) // FIXME: This is incorrect
for(int x = 0; x < 5; ++x)
{
if (i != objects.end())
- {
- if (current_object != -1 && (i - objects.begin()) ==
current_object)
+ { // draw a item
+ if (has_mouse_over() && current_object != -1 && (i -
objects.begin()) == current_object)
{
gc.draw_fillrect(x * 48, y * 48,
x * 48 + 48, y * 48 + 48,
@@ -195,7 +195,7 @@
++i;
}
else
- {
+ { // draw the quads for empty slots
gc.draw_fillrect(x * 48, y * 48,
x * 48 + 48, y * 48 + 48,
(((x-(y%2)) % 2) ? Color(0,0,0) :
Color(100,100,100)));
Modified: trunk/pingus/src/gui/component.hpp
===================================================================
--- trunk/pingus/src/gui/component.hpp 2007-09-14 15:49:18 UTC (rev 3143)
+++ trunk/pingus/src/gui/component.hpp 2007-09-14 16:20:37 UTC (rev 3144)
@@ -30,16 +30,26 @@
some people might call it a widget */
class Component
{
-protected:
- bool has_focus;
+private:
+ bool focus;
+ bool mouse_over;
bool visible;
public:
- Component () : has_focus(false), visible(true) { }
+ Component () : focus(false), mouse_over(false), visible(true) { }
virtual ~Component() {}
- virtual void set_focus(bool val) { has_focus = val; }
+ virtual void set_focus(bool val) { focus = val; }
+ virtual void set_mouse_over(bool val) { mouse_over = val; }
+ virtual bool has_mouse_over() const { return mouse_over; }
+ virtual bool has_focus() const { return focus; }
+
+ virtual void hide() { visible = false; }
+ virtual void show() { visible = true; }
+
+ virtual bool is_visible() const { return visible; }
+
virtual void draw (DrawingContext& gc) =0;
virtual void update (float delta) { UNUSED_ARG(delta);}
@@ -75,11 +85,6 @@
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&);
Modified: trunk/pingus/src/gui/group_component.cpp
===================================================================
--- trunk/pingus/src/gui/group_component.cpp 2007-09-14 15:49:18 UTC (rev
3143)
+++ trunk/pingus/src/gui/group_component.cpp 2007-09-14 16:20:37 UTC (rev
3144)
@@ -184,10 +184,16 @@
if (comp != mouse_over_comp)
{
if (mouse_over_comp)
- mouse_over_comp->on_pointer_leave();
+ {
+ mouse_over_comp->set_mouse_over(false);
+ mouse_over_comp->on_pointer_leave();
+ }
if (comp)
- comp->on_pointer_enter();
+ {
+ comp->set_mouse_over(true);
+ comp->on_pointer_enter();
+ }
}
mouse_over_comp = comp;
@@ -216,6 +222,23 @@
{
drawing_context.set_rect(rect);
}
+
+void
+GroupComponent::on_pointer_enter()
+{
+
+}
+
+void
+GroupComponent::on_pointer_leave()
+{
+ if (mouse_over_comp)
+ {
+ mouse_over_comp->set_mouse_over(false);
+ mouse_over_comp->on_pointer_leave();
+ }
+ mouse_over_comp = 0;
+}
} // namespace GUI
Modified: trunk/pingus/src/gui/group_component.hpp
===================================================================
--- trunk/pingus/src/gui/group_component.hpp 2007-09-14 15:49:18 UTC (rev
3143)
+++ trunk/pingus/src/gui/group_component.hpp 2007-09-14 16:20:37 UTC (rev
3144)
@@ -70,8 +70,8 @@
void on_key_pressed(const unsigned short c);
- void on_pointer_enter() {}
- void on_pointer_leave() {}
+ void on_pointer_enter();
+ void on_pointer_leave();
void on_pointer_move(int x, int y);
Modified: trunk/pingus/src/gui/input_box.cpp
===================================================================
--- trunk/pingus/src/gui/input_box.cpp 2007-09-14 15:49:18 UTC (rev 3143)
+++ trunk/pingus/src/gui/input_box.cpp 2007-09-14 16:20:37 UTC (rev 3144)
@@ -51,7 +51,7 @@
if (label != std::string())
gc.print_right(Fonts::pingus_small, pos.x, pos.y, label);
- if (has_focus)
+ if (has_focus())
gc.draw_line(pos.x +
Fonts::pingus_small.get_size(shrink_string(str)).width + 12,
pos.y, pos.x +
Fonts::pingus_small.get_size(shrink_string(str)).width + 12,
pos.y + height, Color(0,255,255));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3144 - in trunk/pingus/src: editor gui,
grumbel at BerliOS <=