http://wildfiregames.com/~code/resources/divisions/GUI/TDD/GUI_Engine_TDD_1.41.doc http://wildfiregames.com/~code/resources/divisions/GUI/TDD/GUI_Engine_TDD_1.41.xls == '''Underscores versus Hyphens''' == The GUI interface now lets you interchangeablely use underscores instead of hyphens: `object.cell_id` is exactly equivalent to `object["cell-id"]` As a naming convention, it's best to just stick to alphanumerics (A..Z, a..z, 0-9) and underscores wherever possible since the hyphen is a reserved character. == '''New Sizing''' == (posted by Gustav, 24th November 2003) Okay fellow GUI-guys, the new sizing is now implemented and you will have to start sketching the GUI in the lowest allowed resolution, and also how things should tile or stretch or whatever you want them to do when the resolution is higher than that. Now each object's size and position is described with not 4 values like before, but with 8 values, the doubling is because now there is a percentage-modifier. You see if you want to place something so it sticks out from the right edge of the screen 10 pixels, you want the '''left''' being "100%-10" and the '''right''' being "100%"... Do you follow me? In the XML files you now go like: "0 50%-10 100% 50%+10" or something like that. Got it? == '''Controls Specifications''' == (posted by Gustav, 2nd January 2004) I thought I'd compile a little list of the basic controls and how the will work both technically and graphically... This way you can comment on things and suggest changes/additions... I just want to know I am on the same page as you guys :) I will write this in "this is how it is," but don't think that isn't changable... It's just, if you have suggestions, and I decide to change things, then I will edit this document. Notice also that when a sprite fills a whole area, remember that a GUI sprite can have *real* images outside the sprite's perimeter. Just so you know the graphical potential. Also sprites are always optional, many times text is to too! '''Frame''' Filled with a sprite. Does nothing beyond that. If you remove the sprite it is equivalent to an "Empty" control. '''Button''' A button consist of a sprite filling all of its size and text that can be placed in any alignment. When hovered, pressed or disabled, both the sprite and the text color can be changed. The buttons work as in Windows, you can press it, but it is once you release it the action is committed. '''Text''' A text box has got a sprite filling all of its size, text can be placed in any alignment. A horisontal scroll-bar can be added (and it will always show, like in Internet Explorer, even when there is nothing to scroll... would you like this to change?). When a scroll-bar is added, valign is omitted and "top" is always used. Images can be inserted both like smileys :) and like images. Also font, size and color of text will be able to be changed with syntax similar to the one on this forum. This control will be alone with these features, they will not be generic to all text rendering (or do you want them to be that?). '''Input''' An input is a sprite filling all of its size, and text that can be edited. You will be able to edit this text as in a Windows edit box. Selecting a section of it will make a sprite appear in below the text (remember they can be monochrome), and a specific text color for parts that are selected can be set. The text being inputted will never span more than a single row. If too much is entered the same as in a windows text box will happen: A horisontal scrolling but with no idicator than the text itself. The option of making the caption being cleared the first time the edit box is receiving focus is available. Such as: "Enter your name here", and then when you press it, it clears. Also that initial text might be in another color (unless you wanna scrap the feature). Ideally I would like to support clipboard features, such as paste (from outside the application... It is WONDERFUL for IP-adresses and domain names for servers)... I haven't researched the technicalities of this (vis-�-vis SDL) yet. '''Empty''' Has got no functionality at all, works as a container for children. Can be used as a coordinate-system for instance, making the children relative in position. Will also be the default type, so one could go in the XML files, and one would have a container that per se wouldn't be interactable or do anything. Notice if you give the empty class a size and position, it will catch (although not do anything with) the mouse-over if that is the case. In other words, it will be a glass layer. The option of removing this behavior is available though (as is for all controls). '''Progress-Bar''' A progress-bar is given the value between 0 and 100. First a sprite is drawn to fill the whole size of the progress-bar. Then another sprite is drawn on top of the first one, but spanning only to an extent, representing the given value, in width... In height it is the same as the first one. '''Check Box''' A check-box contains a squared sprite to the left (or right) with text on the opposite side. The square itself can have 8 different kinds of sprites (although many are optional): false, false-over, false-pressed and false-disabled, true, true-over, true-pressed, true-disabled... false and true being unchecked and checked. By pressing the whole size of the check-box one can change its value (the pressing is of the same behavior as a button); notice that implies that the text can also be pressed, not just the square itself. '''Radio Button''' A radio button is derived from the check-box, so it is similar in all ways, except that when pressed, the box pressed is always set to checked, and the siblings (!) is set to false (unchecked). To make a group of radio buttons, it is advised to use an object of type empty; and fill it with nothing but radio buttons that you want to group! Also, the little difference between the check box and the radio button will of course change when you make intuitive graphics for them that will accentuate the difference (round and square I presume) :) '''List Box''' I won't explain this in detail because I hope everyone knows how a list box looks (I can fetch images otherwise). One sprite will cover the background (even behind the scroll-bar, this is because one could set a border outside this area), one sprite will be the background of the selected element. Only one element can be selected at once. A scrollbar will be attached to the right, although optional if should be present even when there is nothing to scroll. [b]Drop Down [list] A drop down list box is like a list box (informational), only it hides the unselected items. Yes we've all seen them so I need not to explain further. Anyway, there will be a squared button to the right, it will be able to change sprite when hovered/pressed/disabled. When pressed an area below will appear, it will graphically be equivalent to the list box (including scrollbar stuff), but it will disappear when pressing outside (that press won't do squat to the outside, if you were hovering a button, you will have to presst twice. Like in Windows... Do tell me if this is a nuisance rather than a intuition, since the other way is simpler, technically). '''Slider''' I forgot the slider, will need some feedback on how you guys want the slider to look. Horisontal? Vertical? With markers? Snap to the markers? '''Menu''' A menu system like "File Edit ..." in Windows. One will be able to make a row of root menus. After pressing a root menu, its sub-menu appears. Sub-menus can also have sub-menus, in an unlimited spectrum. The menu structure is declared in XML within the of the menu object. The root menus will always open downwards (these menus are meant to be placed on the top of the screen). Sub-menus will be opened like in windows, next to the arrow, but on top of its parent. An element will be able to be: something that executes a script, a parent (that opens a sub-menu) or a seperator. Elements and root menus will be able to be disabled. Icons will be able to be attached to these elements (icons are just textures). Once a menu is opened it won't be closed until having pressed outside, hovering an element that opens a sub-menu for a brief moment, will open the sub-menu, one can also click it. Hovering an element of a different kind for the same amount of time, will close the sub-menu (this is just like Windows). There is a lot of behaviors to explain here, but I will try making it as alike as windows as possible. Some things will inevitably vary. Elements will be declared either 'always visible' or 'initially hidden'. The ones initially hidden will only open once the last element is pressed (this element will probably have >> only pointing down in the middle). That element will disappear once opened. There will be no animations when reveiling the hidden ones (like there is in Office). More on this when I actually start working on this class. '''Color Picker''' Needs more specifications. '''Wiki (not the established name)''' Customized text box with links and such. Needs more specifications. I'm not looking for heaps of comments (although they are welcomed), I was just thinking a reference page like this should be established, so that all you GUI designers know what controls you can work with. If you want more, suggest them here. '''[size=7]GUI XML Crookedness'''![/size] (Posted by Gustav, 14th October 2004) Alright, having reviewed some of the XML code, I've decided I need a thread where I can point out things that's done crooked, or possibly if there are easier ways of doing things. Yeah, that's basically it. This thread is all about learning how the GUI works, and how to use it correctly. I'm sorry if I will come off stern, but I'll just go ahead and tell you guys everything that I feel is out there, and don't feel bad, you're not even forced to agree with me, this is just my pointers. '''Sizing''' `` The sizing is defined as following: "'''left top right bottom'''" and not "left top width height". This is very important, because what that object creates, is a rectangle that will capture the event of the mouse (or maybe not, I'm not sure). In either case, it's not good. The sprite in this one is added without percentage modifiers, so it still turns out okay. Although using these conventions will result eventually in major crookedness, because when drawing a sprite, we want the mouse to know when it's hovering the sprite, and that is done with the texture being stretched and the size being the size of the sprite. '''I recommend specifying textures as "0 0 100% 100%" and letting the size of the object define the resulting sprite size''' when applicable. Also, those objects, is it meant for the user to be able to click them and still interact with the game? Or should they block that? If they shouldn't interfere, they should be set as "ghost", and if they should, they need correct sizing. I just committed an update that makes the GUI blocks signals to the game, so that if you select the GUI menu now, an object won't be selected in the background. Although, this has revealed that at some places the GUI blocks empty space, like the bottom menu, it blocks everything from the horisontal line from the top of the minimap and below: `