Another two cents (so you have 4!!! :P)

I would make a object "background" and an object "foreground" instead
of backgroundimage in the component style, so you can have animations
in background an foreground (which is cool).


2011/7/14 inigo.delg...@gmail.com <inigo.delg...@gmail.com>:
> I have just take the code and I dont like -or have to argue because
> dont think that is the best way to do- some things...
>
> As always I would like to be wrong and correct my opinions after this
> dicussion because my objetive is to learn and to improve my
> programming skills.
>
> Coding:
>     -8 whitespaces are a lot of whitespaces, i think 4 are more readable.
>     -I think that the first character in methods/functions shold be
> lowercase and in classes upper case.
>
> At last these are 2 conventions but I think that are commonly used in
> python... anyhow are only a convention and this is only a petition,
> like you wish.
>
>
> BaseUIComponent:
>
> You have  _parentSurface and _controlSurface that I think that are unnecesary:
>
> I think that the component should have "how" to draw the component and
> not "where" the where is common for all of them (always in a game that
> only have one window). I'll put the 'where' -the surface- in a
> parameter in the render() or, being more radical and thinking in this
> UI like a simple game UI, put it as global because you'll only use one
> surface per game.
>
> For the collisions (to know if the mouse cursor is inside the
> component) I'll do this:
>
> def isPointInside(self, cx,cy):
>     if self._absY > cy > self._absY - self._heigth and self._absX < cx
> < self._asbX + self._widht:
>         return True
>     else return False
>
> Which can be 'reintention of the wheel' but: they're only from 1
> comparation to 4 comparations and 2 sums (the alternative are always 2
> sums and the creation of 2 objects) ad it's not a complicated code...
> For collitions between rectangles I wouldn't do this... but to know if
> a point is in/outside a rectangle...
>
> This way you can avoid having the surfaces pointed in all objects.
>
>
> UIComponentColection:
>
> I think that this should be a BaseUIComponent (implement it) that
> contains a list of another objects that implement BaseUIComponent for
> structural coherence, so p.e. it can be decorated (from the pattern
> decorator of the GoF) in the future easily.
>
> Another think. In the render() method in UIComponentCollection have:
>
> for component in self._uiComponentCollection:
>       if not component._disposed:
>            component.render()
>       else:
>           # dispose logic
>
> So, to be honest, the method should be called "renderOrDisposeComponents()"
>
> I'll do something like this, in the collection:
>
> def render(self, display):
>     for comp in self._uiComponentCollection:
>         comp.render(display)
>
> And change the 'dispose' for a 'visible'  property so in the
> BaseUIComponent you can do:
>
> def render(self, display):
>     if self._visible:
>         #render stuff (blit)
>
> Because generaly you dont want to dispose elements, only set them
> visible or invisible... And the visible and invisible properties are
> of the object and the object draws himself.
>
> And also you can do a dispose method in the Collection to search and
> dispose a component if you want....
>
> Well these are my ideas, my 2 cents.
>
>
>
>
>
>
>
> 2011/7/4 <i...@sarconsrealm.org>
>>
>> Hi Jake,
>>
>> To answer your questions:
>>
>> 1. For rendering I'm currently doing blit.
>>
>> 2. CSS parser is a great idea but initially I would like to implement a 
>> configuration manager using XML because this provides me with the 
>> opportunity of implementing a designer later on when I have enough quality 
>> components to build it with.
>>
>> Question:
>>
>> Why do you consider having CSS properties as attributes in the XML node 
>> wrong? The XML you have provided has width and height properties as 
>> attributes and font-size as a node content, shouldn't they all be nodes or 
>> attributes to be consistent? I'm not saying yours is wrong just wanted to 
>> know the reasoning behind it.
>>
>> Currently in my branch code I am implementing the configuration manager as a 
>> separate class that is being instantiated inside the base component and that 
>> finds the XML node by ID attribute where the ID is the ID of the control. To 
>> have all components instantiated from the existing XML I am using the 
>> component collection constructor with the config (XML) path provided to it. 
>> It goes through the nodes and instantiates each component by getting the 
>> component type, be it an ImageBox or a Button, from the XML and 
>> instantiating the component with the XML node attribute. Let me know what 
>> you think! I would soon have this code committed and once I make sure it 
>> works as expected, I would have it merged to trunk.
>>
>> ---- OriginalMessage ----
>> From: "Jake b" <ninmonk...@gmail.com>
>> To: pygame-users@seul.org
>> Sent: Sun, Jul 03, 2011, 04:28 AM
>> Subject: Re: Re: [pygame] Pygame-UI: UI Component Framework for python and 
>> pygame
>>
>> For rendering, what do you plan on doing? ( blit, opengl, svg_blit, 
>> pygame.draw )
>>
>> My main request for reusability is loading a .css file.
>> If for XML, I tried this. [ Using attributes for sll style info seemed 
>> wrong. ]
>>
>> <configuration>
>>         <component name="inventory left" width="200px" height="150px">
>>             <parent>inventory root</parent>
>>             <type>window frame</type>
>>             <!-- load base, except set font size -->
>>             <basestyle>inventory.css</basestyle>
>>             <style>font-size: 20px;</style>
>>         </component>
>>         <component name="inventory right" width="100px" height="150px">
>>             <parent>inventory root</parent>
>>             <type>window frame</type>
>>             <basestyle>inventory.css</basestyle>
>>             <style>font-size: 12px;</style>
>>         </component>
>> </configuration>
>>
>> Or, you could define that in xml:
>>
>> <configuration>
>>     <stylelist>
>>         <style id="inventory base">font-size: 1em; color:gray; font-family: 
>> sans-serif;</style>
>>     </stylelist>
>>
>>     <component name="inventory left pane" basestyle="inventory base" 
>> width="200px" height="150px">
>>         <parent>inventory root</parent>
>>         <type>window frame</type>
>>         <style>font-size: 20px;</style>
>>     </component>
>>
>>     <component name="inventory right pane" basestyle="inventory base" 
>> width="100px" height="150px">
>>         <parent>inventory root</parent>
>>         <type>window frame</type>
>>         <style>font-size: 12px;</style>
>>     </component>
>> </configuration>
>>
>>
>>
>>
>>
>> --
>> Jake
>
>
>
> --
> Nota: Tildes omitidas para evitar incompatibilidades.
>
> :wq
>



-- 
Nota: Tildes omitidas para evitar incompatibilidades.

:wq

Reply via email to