<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Best way to abstract allegro events for my gui library</title>
		<link>http://www.allegro.cc/forums/view/611534</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 12 Dec 2012 00:08:05 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So like the title says, I am trying to figure out the best method to abstract Allegro 5&#39;s event system into my own event system for use with my GUI. My GUI also needs to be compatible with other libraries like SDL / SFML / what the hell ever else someone wants a port of.... as well.</p><p>So, my first thought is to duplicate Allegro, so that A5 users don&#39;t have to adjust much to use my GUI&#39;s event system. This would mean copying most ALLEGRO_EVENT_BLAH_BLAH into EAGLE_EVENT_BLAH_BLAH and duplicating the event union and structures.</p><p>The main focus right now is to get the abstraction ready, so I can fill in the backend for Allegro 5 and start porting all my widgets to the new library.</p><p>So, any ideas / tips / helpful comments?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 01 Dec 2012 17:56:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Consider having several event loops, whether the gui is active or not could select one specialized for the gui, another could be for game movement keys, whatever.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sat, 01 Dec 2012 18:00:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does anybody have any ideas for abstracting graphics libraries? I know theres AGUI, who wrote that again?</p><p>Here&#39;s what my gui looks like now, with A4 driving it :<br /><span class="remote-thumbnail"><span class="json">{"name":"607020","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/0\/f06a193524d99eb5d5a68d3eacf3de3f.png","w":812,"h":632,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/0\/f06a193524d99eb5d5a68d3eacf3de3f"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/f/0/f06a193524d99eb5d5a68d3eacf3de3f-240.jpg" alt="607020" width="240" height="186" /></span></p><p>Do you like the way it looks? What options should a user have when drawing widgets in a gui library?</p><p>What is the best way to integrate layout managers? Give every widget handler (frame / window / subwindow) a layout manager?</p><p>So - thoughts?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 07 Dec 2012 21:49:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971280#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> So, any ideas / tips / helpful comments?</p></div></div><p>The best way to deal with it is to create one event for Allegro, named CAllegroEvent or whatever your naming convention is. </p><p>This event will not be available to your users though, unless they explicitly process it. Your event loop will catch this event and create other events for the GUI, like mouse down/mouse up, mouse/move etc.</p><p>In this way, you can put other event systems in, if you wish. For example, you could have an CWin32MessageEvent for all Win32 messages, and then have your GUI create the same mouse down/up/move etc events that are also created for CAllegroEvent.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971770#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> Does anybody have any ideas for abstracting graphics libraries?</p></div></div><p>Provide a CCanvas class with drawing methods, selecting pens and brushes, etc. Then let widgets draw to that.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> Do you like the way it looks?</p></div></div><p>I&#39;ll be honest: I don&#39;t like it very much.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> What options should a user have when drawing widgets in a gui library?</p></div></div><p>The user should be allowed to skin widgets, i.e. select all its graphical aspects at runtime.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> What is the best way to integrate layout managers? Give every widget handler (frame / window / subwindow) a layout manager?</p></div></div><p>Create widgets for layout, i.e. integrate the layout mechanism with widgets. Each widget should have its own layout, and a special group of your widgets will be about layout only.</p><p>Using a secondary tree of layout objects makes it more difficult to create layouts.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sat, 08 Dec 2012 22:37:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971825#target">axilmar</a> said:</div><div class="quote"><p>Using a secondary tree of layout objects makes it more difficult to create layouts.</p></div></div><p>

I&#39;d say that&#39;s the same mistaken believe which makes CSS as hard as it is. &lt;table&gt;&lt;tr&gt;&lt;td&gt; elements in HTML are extremely simple, everyone can for example make a 3 column layout in a minute. CSS on the other hand is not simple at all, a 3 column layout requires hours of research.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sun, 09 Dec 2012 00:49:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I haven&#39;t really found a simpler/better method of widget layouts than what Qt uses. Other than explicit widgets that layout their children.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971825#target">axilmar</a> said:</div><div class="quote"><p>Provide a CCanvas class with drawing methods, selecting pens and brushes, etc. Then let widgets draw to that.</p></div></div><p>I do something similar for my little Canva5 library. I used Qt&#39;s setup as an example, so its fairly similar:</p><p><a href="http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Display.cpp">http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Display.cpp</a><br /><a href="http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Bitmap.cpp">http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Bitmap.cpp</a><br /><a href="http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/PaintEngine.cpp">http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/PaintEngine.cpp</a><br /><a href="http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Drawable.cpp">http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Drawable.cpp</a><br /><a href="http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Painter.cpp">http://git.tomasu.org/canva5.git/blob/refs/heads/prototype:/core/src/Painter.cpp</a></p><p>I rather like it. All I have to do is implement a new Bitmap class and a new Display class, and a new PaintEngine class and the lib is instantly ported to another backend. </p><p>append: One of these days I intend on adding some GUI classes to it. But it can be used as an engine for 2d games quite nicely. Just spam some Item&#39;s of various types at the Model, and it&#39;ll take care of everything for you. You can even create multiple views into the same world! It&#39;s really quite neat.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 09 Dec 2012 03:13:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I really like the Qt/GTK+ design. It requires much less compile-and-test sequences since most of the layout is calculated automatically. The alternative would be a GUI designer, but I tend to find WYSIWYG output hideous.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Luiji99)</author>
		<pubDate>Sun, 09 Dec 2012 03:22:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971825#target">axilmar</a> said:</div><div class="quote"><p>
I&#39;ll be honest: I don&#39;t like it very much.
</p></div></div><p>
Being honest doesn&#39;t help much if you are not also useful.....</p><p>What is it you do not like?<br />The style of the buttons / sliders / radio / menu / drop down / file browser - what? ? ? ? Of course there will be image buttons so you can make it look whatever way you want it to, and you can define hit boxes. Simple event based system, widgets give messages about what happens and then you cherry pick the messages you want and hook them up to other things. It&#39;s also very easy to derive new widgets, all you have to do is implement 3 simple methods, HandleEvent(Event e), Update(double dt), and Display(GraphicsContext gc).</p><p>What exactly is this QT style that you all mention? I am not familiar with their source code or programming with their library...</p><p>Also, what kind of interface do you like? Constructors with every parameter possible, or basic constructors and specialized setup functions....???
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 09 Dec 2012 07:06:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971866#target">Edgar Reynaldo</a> said:</div><div class="quote"><p>What exactly is this QT style that you all mention? I am not familiar with their source code or programming with their library...</p></div></div><p>It provides a dynamic layout mechanism. For the most part there is no hand placement of widgets.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Also, what kind of interface do you like? Constructors with every parameter possible, or basic constructors and specialized setup functions....???</p></div></div><p>I&#39;d go with simple ctors and a bunch of methods.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 09 Dec 2012 07:26:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971867#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p>
It provides a dynamic layout mechanism. For the most part there is no hand placement of widgets.
</p></div></div><p>
Moose, you are referring to the somewhat javax / swing type widget layout mechanisms? Where you provide a window / container with a layout widget? I will be providing layout widgets this time, the widget handlers will own a layout manager, whether a dumb default one where you can hand place widgets or a smart one that lays out and resizes to fill / fit / align / whatever else you want.....</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;d go with simple ctors and a bunch of methods.
</p></div></div><p>
I think this is simpler and better too. More like Javax and AWT. That way you don&#39;t have to memorize long constructor parameters. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 09 Dec 2012 07:57:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971770#target">Edgar Reynaldo</a> said:</div><div class="quote"><p>
 I know theres AGUI, who wrote that again?
</p></div></div><p>

I wrote Agui.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sun, 09 Dec 2012 08:00:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971871#target">Edgar Reynaldo</a> said:</div><div class="quote"><p>Moose, you are referring to the somewhat javax / swing type widget layout mechanisms? Where you provide a window / container with a layout widget? I will be providing layout widgets this time, the widget handlers will own a layout manager, whether a dumb default one where you can hand place widgets or a smart one that lays out and resizes to fill / fit / align / whatever else you want.....</p></div></div><p>Qt has a special layout object you assign to widgets, any widgets. But dedicated layout widgets also work. Same idea. Just so long as you don&#39;t force me to layout my gui by hand, I won&#39;t hate you.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 09 Dec 2012 08:01:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971872#target">jmasterx</a> said:</div><div class="quote"><p>
I wrote Agui.
</p></div></div><p>
Ah, jmasterx, there you are. So how did you achieve your abstraction of the graphics backend in your library agui? Virtual systems? What is your opinion on my gui and what do you think I should work on with it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 09 Dec 2012 08:14:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Since Agui favors Listeners over bubbling messages, the way I did it might not be exactly what you need (since I think you mentioned integrating your messages?)</p><p>But here is basically how I did it.</p><p>I have a base class Image, Font, Font Loader, Image Loader, Graphics Context...</p><p>I expect the back-end to implement all of these.</p><p>The loaders are pretty straight forward:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">class</span> AGUI_BACKEND_DECLSPEC Allegro5FontLoader <span class="k2">:</span>
    <span class="k1">public</span> FontLoader
  <span class="k2">{</span>
  public:
    Allegro5FontLoader<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span> <span class="k2">{</span><span class="k2">}</span>
    ~Allegro5FontLoader<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span> <span class="k2">{</span><span class="k2">}</span>

    <span class="k1">virtual</span> Font<span class="k3">*</span> loadFont<span class="k2">(</span><span class="k1">const</span> std::string <span class="k3">&amp;</span>fileName, <span class="k1">int</span> height<span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>

They implement the base class&#39;s load method and return an abstract Font, Image, etc.</p><p>The way Input works is as follows.<br />I have a base input class that allows you to queue up Mouse and Keyboard events.</p><p>The Input Handler base looks like:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">namespace</span> agui
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span>
<span class="number">  4</span>  <span class="c">/**</span>
<span class="number">  5</span><span class="c">     * Abstract class for Input.</span>
<span class="number">  6</span><span class="c">   *</span>
<span class="number">  7</span><span class="c">   * Should implement:</span>
<span class="number">  8</span><span class="c">   *</span>
<span class="number">  9</span><span class="c">   * A method to receive a back end specific event and convert it</span>
<span class="number"> 10</span><span class="c">   * to MouseInput or KeyboardInput.</span>
<span class="number"> 11</span><span class="c">   *</span>
<span class="number"> 12</span><span class="c">   * getTime (default uses std::clock)</span>
<span class="number"> 13</span><span class="c">   *</span>
<span class="number"> 14</span><span class="c">   * Should respect:</span>
<span class="number"> 15</span><span class="c">   *</span>
<span class="number"> 16</span><span class="c">   * isMouseEnabled</span>
<span class="number"> 17</span><span class="c">   *</span>
<span class="number"> 18</span><span class="c">   * isKeyboardEnabled</span>
<span class="number"> 19</span><span class="c">     * @author Joshua Larouche</span>
<span class="number"> 20</span><span class="c">     * @since 0.1.0</span>
<span class="number"> 21</span><span class="c">     */</span>
<span class="number"> 22</span>
<span class="number"> 23</span>  <span class="k1">class</span> AGUI_CORE_DECLSPEC Input
<span class="number"> 24</span>  <span class="k2">{</span>
<span class="number"> 25</span>    <span class="k1">double</span> startTime<span class="k2">;</span>
<span class="number"> 26</span>    std::queue<span class="k3">&lt;</span>MouseInput&gt; mouseEvents<span class="k2">;</span>
<span class="number"> 27</span>    std::queue<span class="k3">&lt;</span>KeyboardInput&gt; keyboardEvents<span class="k2">;</span>
<span class="number"> 28</span>    <span class="k1">bool</span> mouseEnabled<span class="k2">;</span>
<span class="number"> 29</span>    <span class="k1">bool</span> keyboardEnabled<span class="k2">;</span>
<span class="number"> 30</span>  protected:
<span class="number"> 31</span>  <span class="c">/**</span>
<span class="number"> 32</span><span class="c">   * Default constructor.</span>
<span class="number"> 33</span><span class="c">     */</span>
<span class="number"> 34</span>    Input<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 35</span>  public:
<span class="number"> 36</span>  <span class="c">/**</span>
<span class="number"> 37</span><span class="c">   * Called by the Gui in its logic loop. Used for non event driven back ends.</span>
<span class="number"> 38</span><span class="c">     */</span>
<span class="number"> 39</span>    <span class="k1">virtual</span> <span class="k1">void</span> pollInput<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 40</span>  <span class="c">/**</span>
<span class="number"> 41</span><span class="c">   * Pushes a mouse event which will be dequeued and processed in the next logic loop.</span>
<span class="number"> 42</span><span class="c">     */</span>
<span class="number"> 43</span>    <span class="k1">void</span> pushMouseEvent<span class="k2">(</span><span class="k1">const</span> MouseInput <span class="k3">&amp;</span>input<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 44</span>  <span class="c">/**</span>
<span class="number"> 45</span><span class="c">   * Pushes a keyboard event which will be dequeued and processed in the next logic loop.</span>
<span class="number"> 46</span><span class="c">     */</span>
<span class="number"> 47</span>    <span class="k1">void</span> pushKeyboardEvent<span class="k2">(</span><span class="k1">const</span> KeyboardInput <span class="k3">&amp;</span>input<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 48</span>  <span class="c">/**</span>
<span class="number"> 49</span><span class="c">   * @return True if no mouse events are queued.</span>
<span class="number"> 50</span><span class="c">     */</span>
<span class="number"> 51</span>    <span class="k1">bool</span> isMouseQueueEmpty<span class="k2">(</span><span class="k2">)</span> <span class="k1">const</span><span class="k2">;</span>
<span class="number"> 52</span>  <span class="c">/**</span>
<span class="number"> 53</span><span class="c">   * @return True if no keyboard events are queued.</span>
<span class="number"> 54</span><span class="c">     */</span>
<span class="number"> 55</span>    <span class="k1">bool</span> isKeyboardQueueEmpty<span class="k2">(</span><span class="k2">)</span> <span class="k1">const</span><span class="k2">;</span>
<span class="number"> 56</span>  <span class="c">/**</span>
<span class="number"> 57</span><span class="c">   * Called by the Gui to process the event.</span>
<span class="number"> 58</span><span class="c">   * @return The keyboard event information and removes it from the queue.</span>
<span class="number"> 59</span><span class="c">     */</span>
<span class="number"> 60</span>    <span class="k1">const</span> KeyboardInput dequeueKeyboardInput<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 61</span>  <span class="c">/**</span>
<span class="number"> 62</span><span class="c">   * Called by the Gui to process the event.</span>
<span class="number"> 63</span><span class="c">   * @return The mouse event information and removes it from the queue.</span>
<span class="number"> 64</span><span class="c">     */</span>
<span class="number"> 65</span>    <span class="k1">const</span> MouseInput dequeueMouseInput<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 66</span>  <span class="c">/**</span>
<span class="number"> 67</span><span class="c">   * @return The amount of time the application has been running in seconds.</span>
<span class="number"> 68</span><span class="c">     */</span>
<span class="number"> 69</span>    <span class="k1">virtual</span> <span class="k1">double</span> getTime<span class="k2">(</span><span class="k2">)</span> <span class="k1">const</span><span class="k2">;</span>
<span class="number"> 70</span>  <span class="c">/**</span>
<span class="number"> 71</span><span class="c">   * Set whether or not keyboard input is enabled for the Gui.</span>
<span class="number"> 72</span><span class="c">     */</span>
<span class="number"> 73</span>    <span class="k1">void</span> setKeyboardEnabled<span class="k2">(</span><span class="k1">bool</span> enabled<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 74</span>  <span class="c">/**</span>
<span class="number"> 75</span><span class="c">   * Set whether or not mouse input is enabled for the Gui.</span>
<span class="number"> 76</span><span class="c">     */</span>
<span class="number"> 77</span>    <span class="k1">void</span> setMouseEnabled<span class="k2">(</span><span class="k1">bool</span> enabled<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 78</span>  <span class="c">/**</span>
<span class="number"> 79</span><span class="c">   * @return True if mouse input is enabled for the Gui.</span>
<span class="number"> 80</span><span class="c">     */</span>
<span class="number"> 81</span>    <span class="k1">bool</span> isMouseEnabled<span class="k2">(</span><span class="k2">)</span> <span class="k1">const</span><span class="k2">;</span>
<span class="number"> 82</span>  <span class="c">/**</span>
<span class="number"> 83</span><span class="c">   * @return True if keyboard input is enabled for the Gui.</span>
<span class="number"> 84</span><span class="c">     */</span>
<span class="number"> 85</span>    <span class="k1">bool</span> isKeyboardEnabled<span class="k2">(</span><span class="k2">)</span> <span class="k1">const</span><span class="k2">;</span>
<span class="number"> 86</span>  <span class="c">/**</span>
<span class="number"> 87</span><span class="c">   * Default destructor.</span>
<span class="number"> 88</span><span class="c">     */</span>
<span class="number"> 89</span>    <span class="k1">virtual</span> ~Input<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 90</span>  <span class="k2">}</span><span class="k2">;</span>
<span class="number"> 91</span><span class="k2">}</span>
</div></div><p>

The way this works is, there is a Gui object that handles just about everything event related. It takes in an Input and GraphicsContext.<br />Example:
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">class</span> Scene <span class="k2">:</span> <span class="k1">public</span> agui::ActionListener, <span class="k1">public</span> agui::WidgetListener,
<span class="number">  2</span>    <span class="k1">public</span> SceneEventProvider
<span class="number">  3</span>  <span class="k2">{</span>
<span class="number">  4</span>    Timer<span class="k3">*</span> m_gameTimer<span class="k2">;</span>
<span class="number">  5</span>    DeviceManager<span class="k3">*</span> m_settings<span class="k2">;</span>
<span class="number">  6</span>    DynamicUIManager<span class="k3">*</span> m_dynamicUI<span class="k2">;</span>
<span class="number">  7</span>    SceneManagerMessage<span class="k3">*</span> m_sceneMessenger<span class="k2">;</span>
<span class="number">  8</span>    
<span class="number">  9</span>    agui::Gui m_gui<span class="k2">;</span>
<span class="number"> 10</span>    agui::Allegro5Input m_a5GuiInput<span class="k2">;</span>
<span class="number"> 11</span>    agui::Allegro5Graphics m_a5GuiGraphics<span class="k2">;</span>
<span class="number"> 12</span>    agui::Allegro5CursorProvider m_a5GuiCursor<span class="k2">;</span>
<span class="number"> 13</span>.....
<span class="number"> 14</span>
<span class="number"> 15</span>  Scene::Scene<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span>
<span class="number"> 16</span>    <span class="k2">:</span> m_gameTimer<span class="k2">(</span>NULL<span class="k2">)</span>,
<span class="number"> 17</span>    m_sceneMessenger<span class="k2">(</span>NULL<span class="k2">)</span>,
<span class="number"> 18</span>    m_settings<span class="k2">(</span>NULL<span class="k2">)</span>,
<span class="number"> 19</span>    m_frame<span class="k2">(</span>NULL<span class="k2">)</span>
<span class="number"> 20</span>  <span class="k2">{</span>
<span class="number"> 21</span>    m_gui.setInput<span class="k2">(</span><span class="k3">&amp;</span>m_a5GuiInput<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>    m_gui.setGraphics<span class="k2">(</span><span class="k3">&amp;</span>m_a5GuiGraphics<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>    m_gui.setCursorProvider<span class="k2">(</span><span class="k3">&amp;</span>m_a5GuiCursor<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span>    m_gui.setToolTipShowLength<span class="k2">(</span><span class="n">10</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>    m_gui.setHoverInterval<span class="k2">(</span><span class="n">0</span>.<span class="n">75</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 26</span>    m_gui.setMaxToolTipWidth<span class="k2">(</span><span class="n">400</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 27</span>
<span class="number"> 28</span>  <span class="k2">}</span>
</div></div><p>

What the Gui does with this Input is:<br />In each logic() update it:<br />-calls input-&gt;poll()<br />-dequeues and dispatches queued, abstracted input.</p><p>It is the backend implementation&#39;s responsibility to convert whatever input it receives into agui::MouseInput and agui::KeyboardInput.</p><p>Now, in a case of A4 or SDL 1.2, the Input::poll() method would be implemented.</p><p>In an event driven style such as A5, I created a processInput(ALLEGRO_EVENT&amp; evt).</p><p>That is called like this:
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>  <span class="k1">void</span> Scene::processGuiInputEvent<span class="k2">(</span> <a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a><span class="k3">*</span> evt <span class="k2">)</span>
<span class="number">  2</span>  <span class="k2">{</span>
<span class="number">  3</span>    m_a5GuiInput.processEvent<span class="k2">(</span><span class="k3">*</span>evt<span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span>  <span class="k2">}</span>
<span class="number">  5</span>
<span class="number">  6</span>...
<span class="number">  7</span>In Scene Manager...
<span class="number">  8</span><span class="c">//main loop</span>
<span class="number">  9</span>    <span class="k1">while</span><span class="k2">(</span>m_gameIsRunning<span class="k2">)</span>
<span class="number"> 10</span>    <span class="k2">{</span>
<span class="number"> 11</span>    
<span class="number"> 12</span>      handled <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 13</span>      <a href="http://www.allegro.cc/manual/al_wait_for_event"><span class="a">al_wait_for_event</span></a><span class="k2">(</span>queue,<span class="k3">&amp;</span>evt<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 14</span>
<span class="number"> 15</span>      <span class="k1">bool</span> hasNext <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_peek_next_event"><span class="a">al_peek_next_event</span></a><span class="k2">(</span>queue,<span class="k3">&amp;</span>next<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 16</span>      <span class="k1">if</span><span class="k2">(</span>hasNext <span class="k3">&amp;</span><span class="k3">&amp;</span> next.type <span class="k3">=</span><span class="k3">=</span> ALLEGRO_EVENT_TIMER<span class="k2">)</span>
<span class="number"> 17</span>      <span class="k2">{</span>
<span class="number"> 18</span>        <a href="http://www.allegro.cc/manual/al_drop_next_event"><span class="a">al_drop_next_event</span></a><span class="k2">(</span>queue<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>      <span class="k2">}</span>
<span class="number"> 20</span>      <span class="c">//render the scene</span>
<span class="number"> 21</span>      <span class="k1">if</span><span class="k2">(</span>m_needsRedraw <span class="k3">&amp;</span><span class="k3">&amp;</span> <a href="http://www.allegro.cc/manual/al_is_event_queue_empty"><span class="a">al_is_event_queue_empty</span></a><span class="k2">(</span>queue<span class="k2">)</span><span class="k2">)</span>
<span class="number"> 22</span>      <span class="k2">{</span>
<span class="number"> 23</span>        m_currentScene-&gt;render<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span>        m_needsRedraw <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 25</span>      <span class="k2">}</span>
<span class="number"> 26</span>
<span class="number"> 27</span>      defaultBeginEventHandler<span class="k2">(</span><span class="k3">&amp;</span>evt<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 28</span>      m_currentScene-&gt;processEvent<span class="k2">(</span><span class="k3">&amp;</span>evt,handled<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 29</span>
<span class="number"> 30</span>...
<span class="number"> 31</span>  <span class="k1">void</span> SceneManager::defaultBeginEventHandler<span class="k2">(</span> <a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a><span class="k3">*</span>evt <span class="k2">)</span>
<span class="number"> 32</span>  <span class="k2">{</span>
<span class="number"> 33</span>
<span class="number"> 34</span>    m_currentScene-&gt;processGuiInputEvent<span class="k2">(</span>evt<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 35</span>
<span class="number"> 36</span>    <span class="k1">if</span><span class="k2">(</span>evt-&gt;type <span class="k3">=</span><span class="k3">=</span> ALLEGRO_EVENT_TIMER <span class="k3">&amp;</span><span class="k3">&amp;</span> evt-&gt;timer.source <span class="k3">=</span><span class="k3">=</span> m_gameTimer<span class="k2">)</span>
<span class="number"> 37</span>    <span class="k2">{</span>
<span class="number"> 38</span>      m_needsRedraw <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 39</span>      m_currentScene-&gt;processGuiLogic<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 40</span>      m_devices-&gt;getNetClient<span class="k2">(</span><span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>tick<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 41</span>    <span class="k2">}</span>
<span class="number"> 42</span>    <span class="k1">else</span> <span class="k1">if</span><span class="k2">(</span>evt-&gt;type <span class="k3">=</span><span class="k3">=</span> ALLEGRO_EVENT_DISPLAY_RESIZE<span class="k2">)</span>
<span class="number"> 43</span>    <span class="k2">{</span>
<span class="number"> 44</span>      sendResizeMessage<span class="k2">(</span>evt-&gt;display.width,evt-&gt;display.height<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 45</span>    <span class="k2">}</span>
<span class="number"> 46</span>  <span class="k2">}</span>
</div></div><p> </p><p>That is the basic idea... create an abstract set of functionality that any backend should be able to support, then implement it as a subclass and use polymorphism (and casting) to do the backend specific action.</p><p>As for Layouts, I probably should have made every Widget own a layout, but instead I made it so that a Layout has complete control over the Widgets it is laying out.</p><p>I prefer the idea of every Widget having a layout, and preferably a NULL layout can be supported.</p><p>As to what you should work on with it... I guess games or level editors...</p><p>I like your GUI, I think it looks quite nice. The default skin doesn&#39;t matter anyways :p</p><p>Take Agui for example, it looks much nicer in action!</p><p><span class="remote-thumbnail"><span class="json">{"name":"607025","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/5\/c5f02ac525f2c373d6fa7ae914a70bf9.png","w":476,"h":281,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/5\/c5f02ac525f2c373d6fa7ae914a70bf9"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/c/5/c5f02ac525f2c373d6fa7ae914a70bf9-240.jpg" alt="607025" width="240" height="141" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sun, 09 Dec 2012 08:53:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@Edgar:</p><p>I do not like the artistic style of your GUI. It&#39;s primitive.</p><p>Regarding the API, another way to handle events is to attach event handlers to interactive objects, like Flash does. You can read the Actionscript 3 documentation online, in Adobe&#39;s site.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sun, 09 Dec 2012 16:08:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971902#target">axilmar</a> said:</div><div class="quote"><p>Regarding the API, another way to handle events is to attach event handlers to interactive objects</p></div></div><p>ie: listeners?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 09 Dec 2012 18:31:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, listeners. In Flash, every interactive object has the methods addEventListener and removeEventListener.</p><p>My favorite thing though is signals and slots.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sun, 09 Dec 2012 21:28:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971902#target">axilmar</a> said:</div><div class="quote"><p>
@Edgar:I do not like the artistic style of your GUI. It&#39;s primitive.
</p></div></div><p>
It&#39;s just a default style. You can style it any way you want, or at least you will be able to. I&#39;m going to shuffle things around a bit now and let the user create the gui components themselves, like scroll bar buttons and scrollers. So you can make it look just like OSX if you want to. I&#39;m not going to try and create system themes, but I should have a mechanism for loading guis from script files so the user could write their own system themes.</p><p>@Everyone<br />Should I include support for nine patches, for dynamic resizing of images?</p><p>What is your favorite way to design a gui? Would you like a widget placement editor? Ie.. a gui editor?</p><p>Would writing handlers for extra large video bitmaps that the gpu can&#39;t handle be useful to anyone? Do you want support for large video bitmaps? (Made up of several smaller video bitmaps and pieced together like a jigsaw)</p><p>@Jmasterx<br />What is the AGUI_BACKEND_DECLSPEC declaration for? Do you need that for building on different platforms?</p><p>For my input I decided to follow A5 and use a EagleEventHandler base class along with base classes for system, graphics context, timers, and input. Every backend has to implement these to function.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971878#target">jmasterx</a> said:</div><div class="quote"><p>
In an event driven style such as A5, I created a processInput(ALLEGRO_EVENT&amp; evt). That is called like this:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> Scene::processGuiInputEvent<span class="k2">(</span> <a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a><span class="k3">*</span> evt <span class="k2">)</span>
  <span class="k2">{</span>
    m_a5GuiInput.processEvent<span class="k2">(</span><span class="k3">*</span>evt<span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
</pre></div></div><p>
</p></div></div><p>
Doesn&#39;t this make your library depend on A5?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 10 Dec 2012 01:00:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971940#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> What is your favorite way to design a gui?</p></div></div><p>Code. I&#39;ve never seen a GUI being totally 100% designable by an editor.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Mon, 10 Dec 2012 01:22:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611534/971940#target">Edgar Reynaldo</a> said:</div><div class="quote"><p>
Doesn&#39;t this make your library depend on A5?
</p></div></div><p>

No, because processEvent(ALLEGRO_EVENT* ...) is a method that is specific to Allero5Input class.</p><p>The GUI is only aware of the Input class.</p><p>If you used Agui with SDL you might have an SDLInput which might have processEvent(SDL_EVENT*...)</p><p>agui::Allegro5Input::processEvent(...) calls Input::queueMouseEvent and queueKeyboardEvent. So there is no dependency on Allegro5.</p><p>These are generically dequeued in Gui::logic();</p><p>In my example, my game uses Allegro5 to power it so I find it acceptable to make Allegro5 calls in it.</p><p>But Agui itself can be compiled without any exteral libraries, check out the cmake file.</p><p>The DECL_SPEC allow the library to be compiled as static or as a DLL; MSVC requires each class to be exported using _declspec when building as a DLL. I have 1 for core and 1 for backend to avoid conflicts in certain compilation situations.</p><p>But because of how MSVCRT and such work, I don&#39;t recommend anyone use agui as a DLL unless you&#39;re using the exact same runtime. But it does work. </p><p>Agui has nine patch support if you want to look into that. It is incredibly useful if you&#39;re going to support layouts.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Mon, 10 Dec 2012 02:24:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, I decided to just make a thin wrapper over EagleEvent&#39;s. The events and the keycodes and everything mesh with allegro - ALLEGRO_EVENT_KEY_UP is now EAGLE_EVENT_KEY_UP and so on.... So I guess it will just be a superset of all the library backends it supports. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>Here is the sourceforge project page I setup :<br /><a href="https://sourceforge.net/p/eagle5gui/">https://sourceforge.net/p/eagle5gui/</a></p><p>And the svn repo :<br />svn checkout &quot;<a>svn://svn.code.sf.net/p/eagle5gui/code/trunk</a> eagle5gui-code&quot;</p><p>Please take a look at what I have so far, and tell me what you think of it! <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 11 Dec 2012 02:39:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The way you do it is how I did it too. I also mapped the gui to Allegro5 <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>I looked over the code you committed and it looks fine. I didn&#39;t find Widgets but I guess you&#39;ll add those soon.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Tue, 11 Dec 2012 05:43:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, I haven&#39;t ported any widgets yet, first I have to finish the backend for A5 and then I can rebuild my gui on top of it. I shouldn&#39;t have to change a lot to port my widgets, but I will have to change all the drawing routines, and their input checks will change to use events. So, a little modification is necessary.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 12 Dec 2012 00:08:05 +0000</pubDate>
	</item>
</rss>
