pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2591 - in trunk/src: editor gui


From: jave27
Subject: [Pingus-CVS] r2591 - in trunk/src: editor gui
Date: Sun, 15 Jan 2006 03:09:09 +0100

Author: jave27
Date: 2006-01-15 03:08:53 +0100 (Sun, 15 Jan 2006)
New Revision: 2591

Modified:
   trunk/src/editor/editor_panel.cxx
   trunk/src/editor/editor_panel.hxx
   trunk/src/editor/editor_screen.cxx
   trunk/src/editor/panel_buttons.cxx
   trunk/src/editor/panel_buttons.hxx
   trunk/src/gui/combobox.cxx
Log:
Updated editor item interaction a little more.



Modified: trunk/src/editor/editor_panel.cxx
===================================================================
--- trunk/src/editor/editor_panel.cxx   2006-01-14 23:34:39 UTC (rev 2590)
+++ trunk/src/editor/editor_panel.cxx   2006-01-15 02:08:53 UTC (rev 2591)
@@ -37,7 +37,9 @@
 
 // Constructor
 EditorPanel::EditorPanel(EditorScreen* es)
-: editor(es)
+: editor(es), 
+       pressed_button(0), 
+       combobox(0)
 {
 
 }
@@ -97,5 +99,16 @@
        get_screen()->get_gui_manager()->add((GUI::Component*)button);
 }
 
+void 
+EditorPanel::set_selected_button(PanelButton* pb)
+{
+       if (pressed_button)
+               pressed_button->select(false);
+       
+       pressed_button = pb;
+       if (pressed_button)
+               pressed_button->select(true);
+}
+
 } // Editor namespace
 } // Pingus namespace

Modified: trunk/src/editor/editor_panel.hxx
===================================================================
--- trunk/src/editor/editor_panel.hxx   2006-01-14 23:34:39 UTC (rev 2590)
+++ trunk/src/editor/editor_panel.hxx   2006-01-15 02:08:53 UTC (rev 2591)
@@ -44,8 +44,12 @@
        /** Collection of buttons on this panel */
        std::vector<PanelButton*> panel_buttons;
 
+       /** Combobox which can change it's item list based on the button 
pressed */
        GUI::Combobox* combobox;
 
+       /** Currently selected object on this panel */
+       PanelButton* pressed_button;
+
 public:
        /** Constructor
                @param es The EditorScreen to which this panel belongs */
@@ -70,6 +74,9 @@
        
        /** Return the combobox object */
        GUI::Combobox* get_combobox() { return combobox; }
+       
+       /** Changes which button is currently pressed */
+       void set_selected_button(PanelButton* pb);
 
 private:
        EditorPanel();

Modified: trunk/src/editor/editor_screen.cxx
===================================================================
--- trunk/src/editor/editor_screen.cxx  2006-01-14 23:34:39 UTC (rev 2590)
+++ trunk/src/editor/editor_screen.cxx  2006-01-15 02:08:53 UTC (rev 2591)
@@ -110,6 +110,7 @@
 {
        close_dialog = true;
        plf->save_level(file);
+       panel->set_selected_button(0);
 }
 
 // Load a new level
@@ -119,6 +120,7 @@
        close_dialog = true;
        plf->load_level(file);
        viewport->refresh();
+       panel->set_selected_button(0);
 }
 
 // Play the current level (save to a temporary file 

Modified: trunk/src/editor/panel_buttons.cxx
===================================================================
--- trunk/src/editor/panel_buttons.cxx  2006-01-14 23:34:39 UTC (rev 2590)
+++ trunk/src/editor/panel_buttons.cxx  2006-01-15 02:08:53 UTC (rev 2591)
@@ -36,7 +36,8 @@
 // Constructor
 PanelButton::PanelButton(EditorPanel* p) :
   hover(false),
-  panel(p)
+  panel(p),
+       is_selected(false)
 {
   button = Resource::load_sprite("core/editor/button");
   button_pressed = Resource::load_sprite("core/editor/button_pressed");
@@ -46,9 +47,7 @@
 void
 PanelButton::draw(Pingus::DrawingContext &gc)
 {
-       //if (is_pressed())
-       //FIXME: Component::is_pressed() not implemented
-       if (false)
+       if (is_selected)
                gc.draw(button_pressed, pos);
        else
                gc.draw(button, pos);
@@ -77,6 +76,15 @@
          && y > pos.y && y < pos.y + sur.get_height());
 }
 
+// Something all buttons should do.
+void
+PanelButton::on_primary_button_click(int x, int y)
+{
+       UNUSED_ARG(x);
+       UNUSED_ARG(y);
+       panel->set_selected_button(this);
+}
+
 // Standard exit button
 PanelButtonExit::PanelButtonExit(EditorPanel *p) :
        PanelButton(p)
@@ -89,6 +97,7 @@
 void
 PanelButtonExit::on_primary_button_click(int x, int y)
 {
+       PanelButton::on_primary_button_click(x, y);
        panel->get_screen()->on_escape_press();
 }
 
@@ -104,6 +113,7 @@
 void
 PanelButtonLoad::on_primary_button_click(int x, int y)
 {
+       PanelButton::on_primary_button_click(x, y);
        panel->get_screen()->show_file_dialog(true);
 }
 
@@ -120,6 +130,7 @@
 PanelButtonSave::on_primary_button_click(int x, int y)
 {
        // TODO: Open a file dialog box to save the level.
+       PanelButton::on_primary_button_click(x, y);
        panel->get_screen()->save(path_manager.complete("levels/test.pingus"), 
".pingus");
 }
 
@@ -135,9 +146,8 @@
 void
 PanelButtonGroundpiece::on_primary_button_click(int x, int y)
 {
-       UNUSED_ARG(x);
-       UNUSED_ARG(y);
-       
+       PanelButton::on_primary_button_click(x, y);
+
        // FIXME: Add actual groundpieces
        panel->get_combobox()->clear();
        panel->get_combobox()->set_label("Groundpieces");

Modified: trunk/src/editor/panel_buttons.hxx
===================================================================
--- trunk/src/editor/panel_buttons.hxx  2006-01-14 23:34:39 UTC (rev 2590)
+++ trunk/src/editor/panel_buttons.hxx  2006-01-15 02:08:53 UTC (rev 2591)
@@ -58,6 +58,9 @@
        /** The location of this button on the screen  (set by the EditorPanel) 
*/
        Vector pos;
 
+       /** Is this button currently selected? */
+       bool is_selected;
+
 public:
        /** Constructor 
                @param p The EditorPanel to which this button belongs */
@@ -84,12 +87,18 @@
 
        /** Return true if the button is located at this x,y coordinate */
        bool is_at(int x, int y);
+       
+       /** Action taken when the button is clicked */
+       virtual void on_primary_button_click(int x, int y);
 
        /** Action taken when the mouse enters the button area */
        virtual void on_pointer_enter () { hover = true; }
 
        /** Action taken when the mouse leaves the button area */
        virtual void on_pointer_leave () { hover = false; }
+       
+       /** Action taken when the button is selected or not */
+       virtual void select(bool s) { is_selected = s; }
 
 private:
        PanelButton (const PanelButton&);

Modified: trunk/src/gui/combobox.cxx
===================================================================
--- trunk/src/gui/combobox.cxx  2006-01-14 23:34:39 UTC (rev 2590)
+++ trunk/src/gui/combobox.cxx  2006-01-15 02:08:53 UTC (rev 2591)
@@ -78,6 +78,8 @@
                if ((*i)->delete_it())
                        delete (*i);
        }
+       item_list.clear();
+       current_item = 0;
 }
 
 // Returns whether or not the combobox is at this location





reply via email to

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