[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2580 - trunk/src/editor
From: |
jave27 |
Subject: |
[Pingus-CVS] r2580 - trunk/src/editor |
Date: |
Fri, 6 Jan 2006 19:03:56 +0100 |
Author: jave27
Date: 2006-01-06 19:03:50 +0100 (Fri, 06 Jan 2006)
New Revision: 2580
Modified:
trunk/src/editor/context_menu.cxx
trunk/src/editor/context_menu.hxx
Log:
eol style update for newer files.
Modified: trunk/src/editor/context_menu.cxx
===================================================================
--- trunk/src/editor/context_menu.cxx 2006-01-05 22:06:47 UTC (rev 2579)
+++ trunk/src/editor/context_menu.cxx 2006-01-06 18:03:50 UTC (rev 2580)
@@ -1,224 +1,224 @@
-// $Id: context_menu.cxx,v 1.00 2005/12/29 23:41:12 Jave27 Exp $
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 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/sprite.h>
-#include <ClanLib/Core/System/clanstring.h>
-#include "context_menu.hxx"
-#include "level_objs.hxx"
-#include "editor_viewport.hxx"
-#include "editor_screen.hxx"
-#include "../gui/gui_manager.hxx"
-#include "../fonts.hxx"
-
-namespace Pingus {
-
-namespace Editor {
-
- // Determine which actions are available for these objects
- ContextMenu::ContextMenu(std::vector<LevelObj*> o, Vector p,
EditorViewport* vp, bool base_menu)
- : objs(o),
- viewport(vp),
- pos(p),
- item_height(Fonts::pingus_small.get_height()),
- selected_action_offset(0),
- displayed_child(0)
- {
- if (base_menu)
- {
- // Create all available child menus
- width = 110;
- show = true;
- create_child_menus();
- }
- else
- {
- width = 200;
- show = false;
- }
-
- total_height = item_height * actions.size();
- }
-
-
- ContextMenu::~ContextMenu()
- {
- for (unsigned i = 0; i < actions.size(); i++)
- if (actions[i].child)
- delete actions[i].child;
- }
-
-
- // Keep track of where the mouse is for highlighting
- void
- ContextMenu::on_pointer_move(int x, int y)
- {
- mouse_at.x = (float)x;
- mouse_at.y = (float)y;
-
- selected_action_offset = (unsigned)((mouse_at.y - pos.y) /
item_height);
- }
-
- void
- ContextMenu::draw(DrawingContext &gc)
- {
- if (show)
- {
- // Draw the box
- gc.draw_fillrect(pos.x, pos.y, pos.x + width, pos.y +
total_height,
- CL_Color(211,211,211,100));
- // Draw the border
- gc.draw_rect(pos.x, pos.y, pos.x + width, pos.y +
total_height,
- CL_Color::black);
- // Draw the highlighted action if the mouse is in the
box
- if (hover)
- {
- gc.draw_fillrect(pos.x, pos.y +
selected_action_offset *
- item_height, pos.x + width, pos.y +
(selected_action_offset + 1) * item_height,
- CL_Color(128,128,128,150));
- }
-
- // Draw the action names
- for (unsigned i = 0; i < actions.size(); i++)
- gc.print_left(Fonts::pingus_small, pos.x, pos.y
+
- (i * item_height),
actions[i].friendly_name);
- }
- }
-
- bool
- ContextMenu::is_at(int x, int y)
- {
- if (show)
- return (x > pos.x && x < pos.x + width &&
- y > pos.y && y < pos.y + total_height);
- else
- return false;
- }
-
- void
- ContextMenu::on_primary_button_click(int x, int y)
- {
- if (!actions[selected_action_offset].child)
- {
- for (unsigned i = 0; i < objs.size(); i++)
- {
- switch
(actions[selected_action_offset].modifier)
- {
- case (REMOVE) :
- objs[i]->remove();
- break;
- case (ROTATE) :
-
objs[i]->set_modifier(actions[selected_action_offset].parameter);
- break;
- case (SETOWNER) :
-
objs[i]->set_owner(CL_String::to_int(actions[selected_action_offset].parameter));
- break;
- default :
- break;
- }
- }
- viewport->remove_context_menu();
- }
- }
-
- void
- ContextMenu::on_secondary_button_click(int x, int y)
- {
- // Does the same as the primary button
- on_primary_button_click(x, y);
- }
-
- void
- ContextMenu::create_child_menus()
- {
- // Create Remove button - available to all objects
- actions.push_back(ContextItem("Remove", "", REMOVE, 0));
-
- // Determine which actions are available to the selected objects
- unsigned available_attribs = 0xffff;
- for (unsigned i = 0; i < (unsigned)objs.size(); i++)
- available_attribs = available_attribs &
objs[i]->get_attribs();
-
- ContextMenu* menu;
- if (available_attribs & CAN_ROTATE)
- {
- menu = new ContextMenu(objs, Vector(pos.x + width,
pos.y), viewport, false);
- viewport->get_screen()->get_gui_manager()->add(menu);
- menu->add_action(ContextItem("0 degrees", "ROT0",
ROTATE, 0));
- menu->add_action(ContextItem("90 Degrees", "ROT90",
ROTATE, 0));
- menu->add_action(ContextItem("180 Degrees", "ROT180",
ROTATE, 0));
- menu->add_action(ContextItem("270 Degrees", "ROT270",
ROTATE, 0));
- menu->add_action(ContextItem("0 Degrees + Flip",
"ROT0FLIP", ROTATE, 0));
- menu->add_action(ContextItem("90 Degrees + Flip",
"ROT90FLIP", ROTATE, 0));
- menu->add_action(ContextItem("180 Degrees + Flip",
"ROT180FLIP", ROTATE, 0));
- menu->add_action(ContextItem("270 Degrees + Flip",
"ROT270FLIP", ROTATE, 0));
- add_action(ContextItem("Rotate >", "", ROTATE, menu));
- }
- if (available_attribs & HAS_OWNER)
- {
- menu = new ContextMenu(objs, Vector(pos.x + width,
pos.y), viewport, false);
- viewport->get_screen()->get_gui_manager()->add(menu);
- menu->add_action(ContextItem("0", "0", SETOWNER, 0));
- menu->add_action(ContextItem("1", "1", SETOWNER, 0));
- menu->add_action(ContextItem("2", "2", SETOWNER, 0));
- menu->add_action(ContextItem("3", "3", SETOWNER, 0));
- add_action(ContextItem("Set Owner >", "", SETOWNER,
menu));
- }
- // TODO - Add more menu options here
- }
-
- void
- ContextMenu::add_action(ContextItem item)
- {
- actions.push_back(item);
- total_height += item_height;
- }
-
- void
- ContextMenu::display(bool should_display)
- {
- show = should_display;
- if (!show && displayed_child)
- displayed_child->display(false);
- }
-
- void
- ContextMenu::update(float delta)
- {
- UNUSED_ARG(delta);
-
- if (displayed_child != actions[selected_action_offset].child)
- {
- if (displayed_child)
- {
- displayed_child->display(false);
- displayed_child = 0;
- }
- if (actions[selected_action_offset].child)
- {
- displayed_child =
actions[selected_action_offset].child;
- displayed_child->display(true);
- }
- }
- }
-
-} // Editor namespace
-} // Pingus namespace
-
-/* EOF */
-
+// $Id: context_menu.cxx,v 1.00 2005/12/29 23:41:12 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2005 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/sprite.h>
+#include <ClanLib/Core/System/clanstring.h>
+#include "context_menu.hxx"
+#include "level_objs.hxx"
+#include "editor_viewport.hxx"
+#include "editor_screen.hxx"
+#include "../gui/gui_manager.hxx"
+#include "../fonts.hxx"
+
+namespace Pingus {
+
+namespace Editor {
+
+ // Determine which actions are available for these objects
+ ContextMenu::ContextMenu(std::vector<LevelObj*> o, Vector p,
EditorViewport* vp, bool base_menu)
+ : objs(o),
+ viewport(vp),
+ pos(p),
+ item_height(Fonts::pingus_small.get_height()),
+ selected_action_offset(0),
+ displayed_child(0)
+ {
+ if (base_menu)
+ {
+ // Create all available child menus
+ width = 110;
+ show = true;
+ create_child_menus();
+ }
+ else
+ {
+ width = 200;
+ show = false;
+ }
+
+ total_height = item_height * actions.size();
+ }
+
+
+ ContextMenu::~ContextMenu()
+ {
+ for (unsigned i = 0; i < actions.size(); i++)
+ if (actions[i].child)
+ delete actions[i].child;
+ }
+
+
+ // Keep track of where the mouse is for highlighting
+ void
+ ContextMenu::on_pointer_move(int x, int y)
+ {
+ mouse_at.x = (float)x;
+ mouse_at.y = (float)y;
+
+ selected_action_offset = (unsigned)((mouse_at.y - pos.y) /
item_height);
+ }
+
+ void
+ ContextMenu::draw(DrawingContext &gc)
+ {
+ if (show)
+ {
+ // Draw the box
+ gc.draw_fillrect(pos.x, pos.y, pos.x + width, pos.y +
total_height,
+ CL_Color(211,211,211,100));
+ // Draw the border
+ gc.draw_rect(pos.x, pos.y, pos.x + width, pos.y +
total_height,
+ CL_Color::black);
+ // Draw the highlighted action if the mouse is in the
box
+ if (hover)
+ {
+ gc.draw_fillrect(pos.x, pos.y +
selected_action_offset *
+ item_height, pos.x + width, pos.y +
(selected_action_offset + 1) * item_height,
+ CL_Color(128,128,128,150));
+ }
+
+ // Draw the action names
+ for (unsigned i = 0; i < actions.size(); i++)
+ gc.print_left(Fonts::pingus_small, pos.x, pos.y
+
+ (i * item_height),
actions[i].friendly_name);
+ }
+ }
+
+ bool
+ ContextMenu::is_at(int x, int y)
+ {
+ if (show)
+ return (x > pos.x && x < pos.x + width &&
+ y > pos.y && y < pos.y + total_height);
+ else
+ return false;
+ }
+
+ void
+ ContextMenu::on_primary_button_click(int x, int y)
+ {
+ if (!actions[selected_action_offset].child)
+ {
+ for (unsigned i = 0; i < objs.size(); i++)
+ {
+ switch
(actions[selected_action_offset].modifier)
+ {
+ case (REMOVE) :
+ objs[i]->remove();
+ break;
+ case (ROTATE) :
+
objs[i]->set_modifier(actions[selected_action_offset].parameter);
+ break;
+ case (SETOWNER) :
+
objs[i]->set_owner(CL_String::to_int(actions[selected_action_offset].parameter));
+ break;
+ default :
+ break;
+ }
+ }
+ viewport->remove_context_menu();
+ }
+ }
+
+ void
+ ContextMenu::on_secondary_button_click(int x, int y)
+ {
+ // Does the same as the primary button
+ on_primary_button_click(x, y);
+ }
+
+ void
+ ContextMenu::create_child_menus()
+ {
+ // Create Remove button - available to all objects
+ actions.push_back(ContextItem("Remove", "", REMOVE, 0));
+
+ // Determine which actions are available to the selected objects
+ unsigned available_attribs = 0xffff;
+ for (unsigned i = 0; i < (unsigned)objs.size(); i++)
+ available_attribs = available_attribs &
objs[i]->get_attribs();
+
+ ContextMenu* menu;
+ if (available_attribs & CAN_ROTATE)
+ {
+ menu = new ContextMenu(objs, Vector(pos.x + width,
pos.y), viewport, false);
+ viewport->get_screen()->get_gui_manager()->add(menu);
+ menu->add_action(ContextItem("0 degrees", "ROT0",
ROTATE, 0));
+ menu->add_action(ContextItem("90 Degrees", "ROT90",
ROTATE, 0));
+ menu->add_action(ContextItem("180 Degrees", "ROT180",
ROTATE, 0));
+ menu->add_action(ContextItem("270 Degrees", "ROT270",
ROTATE, 0));
+ menu->add_action(ContextItem("0 Degrees + Flip",
"ROT0FLIP", ROTATE, 0));
+ menu->add_action(ContextItem("90 Degrees + Flip",
"ROT90FLIP", ROTATE, 0));
+ menu->add_action(ContextItem("180 Degrees + Flip",
"ROT180FLIP", ROTATE, 0));
+ menu->add_action(ContextItem("270 Degrees + Flip",
"ROT270FLIP", ROTATE, 0));
+ add_action(ContextItem("Rotate >", "", ROTATE, menu));
+ }
+ if (available_attribs & HAS_OWNER)
+ {
+ menu = new ContextMenu(objs, Vector(pos.x + width,
pos.y), viewport, false);
+ viewport->get_screen()->get_gui_manager()->add(menu);
+ menu->add_action(ContextItem("0", "0", SETOWNER, 0));
+ menu->add_action(ContextItem("1", "1", SETOWNER, 0));
+ menu->add_action(ContextItem("2", "2", SETOWNER, 0));
+ menu->add_action(ContextItem("3", "3", SETOWNER, 0));
+ add_action(ContextItem("Set Owner >", "", SETOWNER,
menu));
+ }
+ // TODO - Add more menu options here
+ }
+
+ void
+ ContextMenu::add_action(ContextItem item)
+ {
+ actions.push_back(item);
+ total_height += item_height;
+ }
+
+ void
+ ContextMenu::display(bool should_display)
+ {
+ show = should_display;
+ if (!show && displayed_child)
+ displayed_child->display(false);
+ }
+
+ void
+ ContextMenu::update(float delta)
+ {
+ UNUSED_ARG(delta);
+
+ if (displayed_child != actions[selected_action_offset].child)
+ {
+ if (displayed_child)
+ {
+ displayed_child->display(false);
+ displayed_child = 0;
+ }
+ if (actions[selected_action_offset].child)
+ {
+ displayed_child =
actions[selected_action_offset].child;
+ displayed_child->display(true);
+ }
+ }
+ }
+
+} // Editor namespace
+} // Pingus namespace
+
+/* EOF */
+
Property changes on: trunk/src/editor/context_menu.cxx
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/src/editor/context_menu.hxx
===================================================================
--- trunk/src/editor/context_menu.hxx 2006-01-05 22:06:47 UTC (rev 2579)
+++ trunk/src/editor/context_menu.hxx 2006-01-06 18:03:50 UTC (rev 2580)
@@ -1,128 +1,128 @@
-// $Id: context_menu.hxx,v 1.00 2005/12/29 23:41:12 Jave27 Exp $
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 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_EDITOR_CONTEXT_MENU_HXX
-#define HEADER_PINGUS_EDITOR_CONTEXT_MENU_HXX
-
-#include <vector>
-#include "../vector.hxx"
-#include "../gui/component.hxx"
-
-namespace Pingus {
-
-namespace Editor {
-
- class LevelObj;
- class EditorViewport;
- class ContextMenu;
-
- typedef enum ItemModifier { REMOVE, ROTATE, SETOWNER, STRETCH };
-
- class ContextItem {
- public:
- std::string friendly_name;
- std::string parameter;
- ItemModifier modifier;
- ContextMenu* child;
-
- public:
- ContextItem(std::string friendly_name_, std::string parameter_,
ItemModifier mod,
- ContextMenu* child_menu)
- : friendly_name(friendly_name_),
- parameter(parameter_),
- modifier(mod),
- child(child_menu)
- { }
- };
-
- class ContextMenu : public GUI::Component {
- private:
- /** Creates the child menu structure and detemines which
actions are available */
- void create_child_menus();
-
- /** Level objects to be affected by this menu */
- std::vector<LevelObj*> objs;
-
- /** Viewport to which this menu belongs */
- EditorViewport* viewport;
-
- /** List of actions available in this menu */
- std::vector<ContextItem> actions;
-
- /** Where the mouse is located */
- Vector mouse_at;
-
- /** Location of context menu */
- Vector pos;
-
- /** Is the mouse over the menu? */
- bool hover;
-
- /** Should this be showing? */
- bool show;
-
- /** The offset into actions vector of the currently highlighted
action */
- unsigned selected_action_offset;
-
- /** Currently displayed child menu (if any) */
- ContextMenu* displayed_child;
-
- /** Height of a single action */
- unsigned item_height;
-
- unsigned total_height;
- unsigned width;
-
- public:
- // Constructor
- ContextMenu (std::vector<LevelObj*>, Vector p, EditorViewport*
v, bool base_menu = true);
-
- // Desctructor
- ~ContextMenu ();
-
- /** Add an action to the list */
- void add_action(ContextItem item);
-
- void display (bool should_display);
-
- /// GUI Component Functions
- bool is_at(int x, int y);
- void draw (DrawingContext& gc);
- void update (float delta);
- void on_pointer_move (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 () { hover = true; }
- void on_pointer_leave () { hover = false; }
-
-
-
- private:
- ContextMenu ();
- ContextMenu (const ContextMenu&);
- ContextMenu& operator= (const ContextMenu&);
-
- }; // ContextMenu class
-
-} // Editor namespace
-} // Pingus namespace
-
-#endif
-
-/* EOF */
+// $Id: context_menu.hxx,v 1.00 2005/12/29 23:41:12 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2005 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_EDITOR_CONTEXT_MENU_HXX
+#define HEADER_PINGUS_EDITOR_CONTEXT_MENU_HXX
+
+#include <vector>
+#include "../vector.hxx"
+#include "../gui/component.hxx"
+
+namespace Pingus {
+
+namespace Editor {
+
+ class LevelObj;
+ class EditorViewport;
+ class ContextMenu;
+
+ typedef enum ItemModifier { REMOVE, ROTATE, SETOWNER, STRETCH };
+
+ class ContextItem {
+ public:
+ std::string friendly_name;
+ std::string parameter;
+ ItemModifier modifier;
+ ContextMenu* child;
+
+ public:
+ ContextItem(std::string friendly_name_, std::string parameter_,
ItemModifier mod,
+ ContextMenu* child_menu)
+ : friendly_name(friendly_name_),
+ parameter(parameter_),
+ modifier(mod),
+ child(child_menu)
+ { }
+ };
+
+ class ContextMenu : public GUI::Component {
+ private:
+ /** Creates the child menu structure and detemines which
actions are available */
+ void create_child_menus();
+
+ /** Level objects to be affected by this menu */
+ std::vector<LevelObj*> objs;
+
+ /** Viewport to which this menu belongs */
+ EditorViewport* viewport;
+
+ /** List of actions available in this menu */
+ std::vector<ContextItem> actions;
+
+ /** Where the mouse is located */
+ Vector mouse_at;
+
+ /** Location of context menu */
+ Vector pos;
+
+ /** Is the mouse over the menu? */
+ bool hover;
+
+ /** Should this be showing? */
+ bool show;
+
+ /** The offset into actions vector of the currently highlighted
action */
+ unsigned selected_action_offset;
+
+ /** Currently displayed child menu (if any) */
+ ContextMenu* displayed_child;
+
+ /** Height of a single action */
+ unsigned item_height;
+
+ unsigned total_height;
+ unsigned width;
+
+ public:
+ // Constructor
+ ContextMenu (std::vector<LevelObj*>, Vector p, EditorViewport*
v, bool base_menu = true);
+
+ // Desctructor
+ ~ContextMenu ();
+
+ /** Add an action to the list */
+ void add_action(ContextItem item);
+
+ void display (bool should_display);
+
+ /// GUI Component Functions
+ bool is_at(int x, int y);
+ void draw (DrawingContext& gc);
+ void update (float delta);
+ void on_pointer_move (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 () { hover = true; }
+ void on_pointer_leave () { hover = false; }
+
+
+
+ private:
+ ContextMenu ();
+ ContextMenu (const ContextMenu&);
+ ContextMenu& operator= (const ContextMenu&);
+
+ }; // ContextMenu class
+
+} // Editor namespace
+} // Pingus namespace
+
+#endif
+
+/* EOF */
Property changes on: trunk/src/editor/context_menu.hxx
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2580 - trunk/src/editor,
jave27 <=