Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - amiralawi

Pages: [1]
1
Window / Event subtypes inaccessible
« on: September 28, 2007, 06:18:18 am »
Currently the event class is setup using an anonymous union and named (but otherwise inaccessible) structs:

Code: [Select]
class Event
{
public :

    ////////////////////////////////////////////////////////////
    /// Enumeration of the different types of events
    ////////////////////////////////////////////////////////////
    enum EventType
    {
        Close,
        Resize,
        LostFocus,
        GainedFocus,
        TextEntered,
        KeyPressed,
        KeyReleased,
        MouseWheelMoved,
        MouseButtonPressed,
        MouseButtonReleased,
        MouseMove,
        JoystickButtonPressed,
        JoystickButtonReleased,
        JoystickMove
    };

    ////////////////////////////////////////////////////////////
    // Member data
    ////////////////////////////////////////////////////////////
    EventType Type; ///< Type of the event

    union
    {

        ////////////////////////////////////////////////////////////
        /// Text event parameters
        ////////////////////////////////////////////////////////////
        struct
        {
            Uint16 Unicode;
        } Text;

        ////////////////////////////////////////////////////////////
        /// Keyboard events parameters
        ////////////////////////////////////////////////////////////
        struct
        {
            Key::Code Code;
            bool      Alt;
            bool      Control;
            bool      Shift;
        } Key;

        ////////////////////////////////////////////////////////////
        /// Mouse events parameters
        ////////////////////////////////////////////////////////////
        struct
        {
            unsigned int Buttons;
            unsigned int X;
            unsigned int Y;
        } Mouse;

        ////////////////////////////////////////////////////////////
        /// Mouse wheel events parameters
        ////////////////////////////////////////////////////////////
        struct
        {
            int Delta;
        } MouseWheel;

        ////////////////////////////////////////////////////////////
        /// Joystick events parameters
        ////////////////////////////////////////////////////////////
        struct
        {
            unsigned int JoystickId;
            unsigned int Button;
            int          X;
            int          Y;
            int          Z;
        } Joystick;

        ////////////////////////////////////////////////////////////
        /// Size events parameters
        ////////////////////////////////////////////////////////////
        struct
        {
            unsigned int Width;
            unsigned int Height;
        } Size;
    };
};


Is there any particular reason for this?  If the structures were defined separately from their instantiations in the event class then they would be accessible outside of the class while still preserving their current usability (ie, won't break anyone's code):


Code: [Select]
class Event
{
public :

    ////////////////////////////////////////////////////////////
    /// Enumeration of the different types of events
    ////////////////////////////////////////////////////////////
    enum EventType
    {
        Close,
        Resize,
        LostFocus,
        GainedFocus,
        TextEntered,
        KeyPressed,
        KeyReleased,
        MouseWheelMoved,
        MouseButtonPressed,
        MouseButtonReleased,
        MouseMove,
        JoystickButtonPressed,
        JoystickButtonReleased,
        JoystickMove
    };

struct TextEvent{
Uint 16 Unicode;
};

struct KeyEvent{
Key::Code Code;
bool Alt;
bool Control;
bool Shift;
};

struct MouseEvent{
unsigned int Buttons;
unsigned int X;
unsigned int Y;
};

//etc.

    EventType Type; ///< Type of the event

    union
    {
        TextEvent Text;
KeyEvent Key;
MouseEvent Mouse;

//etc.
    };
};


The reason I bring this up is because this is creating a problem in my effort to create a set of python bindings.  I can work around it, but the result will be a very inelegant one, and it seems like this is how it should be anyways.

2
Python / Python,... bindings
« on: September 23, 2007, 04:02:51 am »
Is the development on the python bindings still active?  I'm very interested in getting a working python implementation and have been working on it using boost.python: I would be willing to share it if it's needed.

Pages: [1]