« first day (587 days earlier)      last day (4353 days later) » 

2:00 PM
I use the same technique in my library I linked you to earlir
look at my UI code- it maintains a bunch of lines indicating which units are selected and which are not
but it has no OnPaint method anywhere near it
the renderer draws all existing Lines automatically
 
Ell
I will take another look at your code
 
try not to judge it too harshly, it does need some refactoring- although that specific aspect is not up for review
 
Ell
don't worry I would never judge anyone elses code
unless its on thedailywtf.com
 
by the way, @jalf, you here?
 
Ell
@DeadMG Am I looking at CPPContext.hpp?
 
2:08 PM
@Ell let me check :P
I need to rename some files
yes
 
Ell
and it represents the move orders of unitss or?
 
oh yeah, that too
and the units which are selected
and it also maintains some lines in 3D space which indicate which units are selected
but it never has any OnPaint method and never calls into the renderer to draw anything- it just creates the objects which represent what it wants
 
Ell
right okay, I understand that
and then when Context needs to draw, it loops through the stuff it contains
 
right
 
Ell
and draws them itsself
 
2:12 PM
and when a Line is destroyed, it removes itself from the Context's internal structures
 
Ell
right, kk
now, lets say you write a ListBox class
 
which I am going to have to do soon
 
Ell
with a vector<string> Data. And you can go listBox.data.push_back("One"), "two", "three", etc.
say you add 20 items. Now, this class must also hold a vector of Text items, musnt it? for the context to draw?
 
@Ell I personally would be looking at vector<Control>
but yes, it must
 
Anyone has got a good resource on how the event-based system is usually implemented ? (As in how exactly do I know an event happened and so I can call onXyz() ...)
 
Ell
2:14 PM
so, lets say we delete item 2, then we have to loop through items 3...20 and decrease their y by the height of item 2 ?
@ScarletAmaranth see boost::signal (thats one way anway) (boost.org/doc/libs/1_49_0/doc/html/signals.html)
 
@ScarletAmaranth There's event source(s) and event sink(s).
 
yes, if you remove an item you have to move the others up
 
You query events and dispatch them.
That's about it.
 
@CatPlusPlus So sinks have to be checking all the time whether there's a new event available ?
 
@Ell @ScarletAmaranth I'd recommend Signal2 instead: boost.org/doc/libs/1_49_0/doc/html/signals2.html
 
Ell
2:17 PM
@sehe thank you
 
while !event_queue.empty
    event = event_queue.pop
    dispatch(event)
somewhere else: event_queue.push(some_event)
 
Ell
it is a thready safe version isnt it?
 
Synthesised events can come from system, or another part of the application.
 
@Ell Among other things, IIRC
 
define thread-safe
 
2:17 PM
@CatPlusPlus Oh, ok, so there's not a magical trick that would literally let an event handler know that an event has happened.
 
thread aware
 
@ScarletAmaranth You typically have one event loop.
A.k.a. a reactor.
 
Next, you get fission
 
@sehe FUSION BIZNATCHES
 
Ell
@DeadMG I understand your version, but I still don't understand how it is preferable to the other version
 
2:19 PM
@CatPlusPlus There's an event loop that's poping an event queue and checking whether something has occured after which it passes it to a proper onXHappened so it can handle it ?
 
it's preferable because I don't have to orgasm OnPaint all over my code
and I don't have to change it every time I add new things which need rendering
 
@ScarletAmaranth Yes.
 
Ell
but my version is preferable because all the paint logic is contained in an OnPaint method
@DeadMG change what? the code?
 
all my paint logic is contained in the renderer, which is where it should be
@Ell Yes.
 
@CatPlusPlus Dzenkuje bardzo.
 
2:20 PM
@Cicada aw I missed that. Pic or it didn't happen :)
 
in my version, imagine you add std::vector<std::unique_ptr<Text>> and fill it with some Text.
now you're done
in your version, you have to change OnPaint to reflect this change
 
Ell
@DeadMG but in the onpaint function, there will be code iterating over the data in the control, e.g. std::vector<string>, so the code can stay the same
 
no it can't, because I just added another
 
Ell
another what? item to the list?
 
no, another vector
it's a hypothetical control
 
Ell
2:22 PM
but that is your change
 
in your code, you always have to manually loop through and draw every time, and whenever you change the structure, you have to change OnPaint
 
Ell
in your version, you change it by adding another vector of Texts, in mine, you change it by looping through it
 
in my code, it just draws itself and you don't have to change anything
@Ell It's a hypothetical equal change to a hypothetical control.
representing adding arbitrary extra things which need drawing
 
Both of your codes suck.
 
@CatPlusPlus Mine is RAII, bitch :P
 
Ell
2:23 PM
right, but then arent you mixing the underlying data with the rendering data?
 
@sehe A Discworld one.
 
Ell
@DeadMG does the Text in the vector contain the data in the control, or the drawable? or both?
 
@Ell The drawable, but there's nothing stopping you considering it also the data in the control if you define the two to be equal
 
Hi Robot.
 
@CatPlusPlus Mhm, could I then possible predict certain actions and "pre-load/compute/fetch" whatever i expect the next event to be ? I mean, not to actually insert a new event that didn't happen but only to do stuff that will probably happen and then maybe discard it should it actually not happen ?
 
2:25 PM
plus
what are you going to do when you have controls which are dynamic?
 
What do you want to preload?
 
by that I mean, a listbox which can contain, say, buttons, or images, as well as just text
 
Suppose i need to do some heavy lifting if event X occurs.
And i know that event X is likely to happen after event Y.
 
Ell
@DeadMG okay it is starting to make sense now
 
now your OnPaint is gonna be a real mess
 
2:26 PM
The whole point of event-based architecture is to respond to events when they happen.
 
So as soon as event Y happens, I assign thread A to do work that will have to be done should X happen ?
 
@LucDanton Am I missing something? It doesn't work :(
 
Ell
well, not really, you can jsut go foreach(auto child : children) {child.OnPaint(subset_of_canvas)}
 
You can if you really want, I don't think I've ever seen something like that.
Events are typically independent of each other.
 
@Ell Nope. Now you've got the same system as me- explicit drawable objects, not implicit ones every OnPaint.
 
2:27 PM
Even paired ones.
 
@CatPlusPlus But if you have enough data from a particular system, you can sort of see what events usually happen after eachother ?
 
Like key press/key release. You have no guarantee you'll get them with no events in between.
 
Yeah I see your point.
 
If they're not dependent on each other, they have equal probability of appearing in the stream.
 
@RMartinhoFernandes I can't say I tried it.
 
2:31 PM
Well, depends on the events, I guess.
 
@CatPlusPlus And what to do when you know that even B is very likely (yet not guaranteed) to come right after event A. (So there is some dependency in the system yet most of the events that can occur are absolutely independent.)
 
Well, nothing special. I just handle it when it appears.
 
@CatPlusPlus Btw, why not provide a range-like interface to an event stream in glskel or springbok or whatever is the one?
 
Ell
@DeadMG hmmm yes it seems I have. Apart from the primitive things dont have Drawable objects
 
@CatPlusPlus Oki doke then, thanks ;)
 
2:32 PM
@RMartinhoFernandes Draw me a picture.
 
@Ell And if you are to do such a system, you may as well just call the Drawable's OnPaint automatically and draw it from the renderer, which is the simples and easies
 
Well, maybe not picture, literally.
 
Hehe, you realized who you were talking to, eh?
I had paint open already.
Let's see if I can figure out boost.iterator and I'll show you a POC.
Or make a pull request. That'd probably be better.
 
Yes, go forth and fork.
 
Ell
@DeadMG I understand it all now, and can see the advantages. I just don't like it for some reason, i don't know why :L
 
2:36 PM
because it's clean, modern and simple? :P
 
Ell
but I still think it is just a more declarative version - there is a rectangle with x:0, y:10 width:200, height:100 instead of draw a rectangle at x 0, y 10 with width 200 and height 100
 
@sehe Dat signal I like.
 
Ell
@DeadMG I feel like it is unnecessary - too many objects when it is simpler to just go DrawRectangle
 
Hi
 
@Ell You're just exchanging them for 999999 functions.
 
Ell
2:38 PM
well not 99999999, just the primitive stuff - lines, ellipses, beziers, rectangles
 
in my opinion, not having to know when to draw is a big advantage
@Ell No, calling those functions, is the 9999 OnPaint functions
 
Ell
ohh I see.
 
plus, you haven't considered the external library problem
 
Ell
you mean, other libraries might not know when to draw?
 
yes
 
2:39 PM
I am trying to write a API hook for NtSetInformationFile. Do you guys know how to disassemble that function
 
for me, I can give another library a Drawable for whatever reason, and it will keep drawing just fine
but for you, that external library has to have a hook you can use to get it back and draw it
 
Ell
how about clipping areas and stuff?
 
what about them?
I frustum cull my 3D objects, and the other clipping is done by the GPU
 
Ell
i mean - if i want to draw in just a certain area of a control?
 
you can set Drawables to invisible
 
Ell
2:41 PM
do you have a clipping object which contains child drawables?
 
I could do if I wanted to
I haven't, though, mostly because I have no need for such a thin
 
Ell
kk - but if the need were to arise
 
I absolutely could
 
Ell
so this completely eliminates the need for a canvas at all?
 
I certainly don't have a canvas-style class
 
Ell
2:43 PM
so when these drawable objects are created, they are given a reference to a context that does the rendering?
 
yes
to remove themselves when they are destroyed
 
Ell
do you always pass that round?
or keep that in a global variable for ease?
 
I pass it
 
Ell
kk - but you will never need more than one context, will you?
 
the context creates the drawables, so it's little effort to give them one
ehhh, I wouldn't be so sure about that
it's a dumb idea to assume I will only need one
 
Ell
2:45 PM
fair enough
 
what if I allow in future to change my renderer from D3D9 to D3D11 but it fails?
I would want to display an error message- but for that I need a renderer
 
Ell
oh yea :L
hmm so I am about to just create a clone of your system?
 
do what you want
I obviously espose the design I've chosen as using it so far has proven as simple and easy as I expected
 
"Do what you want, mine's better anyway".
 
Ell
Im wondering if i could just use your code and change the names
:L Im not sure I like "context" ;)
 
2:49 PM
That makes perfect sense.
 
@Ell Me neither.
but I need the good names for namespace names :P
I think I'd go with State or something now, but I've got too many to ditch the convention
 
Arrgh, dammit. I need to find out how launch stuff with NVidia's GPU from the command-line.
 
Xeo
Oh my, it seems they finally introduced the [migrated] "tag" at the end of a migrated question
 
I'm an expert on strings now.
Apparently.
 
Ell
2:54 PM
@DeadMG at the moment you only have sprites an labels?
 
I'd like to trade that for a templates one.
 
@Ell Don't currently need anything else.
 
Time to start coding.
 
@RMartinhoFernandes Not many on SO are, but you're late to the club for a robot...
 
2:55 PM
@Xeo I think I've seen at since, like, always
 
Ell
@DeadMg I am confused about Scene2D? your context contains a vector of pointers to those, not "Drawables"? Or is Scene2D a "drawable"?
 
Xeo
@sehe I'm pretty sure it always said [closed], for a stupid reason
@RMartinhoFernandes 9 upvotes and I have silver templates :D
 
No, they've been adding [migrated] to the title for a while now.
 
@Ell They're kinda redundant right now. Their job is to group the drawables.
 
Xeo
@RMartinhoFernandes Oh, did they? Oh well.
 
2:57 PM
I need to refactor them somewhat, but the idea is that the drawables come in groups, like, the main screen group, etc, and then you pick a current group depending on which screen/ui you need rendered now
 
Ell
Wow. I just learned that my feet are so disgusting you can carve dead skin off them with a knife and I wont feel a thing
 
Ell
who wants a video?
 
Cheese, delicious cheese
And vigorous... oh well
 
Ell
I'm not even kidding though. I should see a chiropodist
 

« first day (587 days earlier)      last day (4353 days later) »