On Sat, Aug 7, 2010 at 5:48 PM, Kai Sterker <kai.ster...@gmail.com> wrote:
> Started with that work, and came up with the following concept: > > We create a "decoration" class that is initialized from a data file. > The decoration class can then create a widget/container background > with an optional border (and a scrollbar in the future). All these > elements are painted onto a surface the size of the widget/container > and can then be used as a rubber stamp whenever the widget/container > needs to be redrawn. If the container/widget is resized, we'll > recreate the surface. Well, I've pretty much implemented the decoration class and started updating the rest of the gui stuff to make use of it. In doing so, I've also started formatting and documenting the gui code and tying it a bit more into the engine, in places. One of the things I've done is letting gui::base inherit from gfx::drawable, as gui::base had both a draw method and a width and height. All that is exactly what gfx::drawable already provides. And it kind of was the plan to make anything that can be drawn somewhere a drawable. So far so good, but here's the issue: gfx::drawable::draw is declared as const. gui::base::draw was not and quite a few of the widgets have code in their draw() implementation that modifies class members. So here's the question: is there a quick way to work around these problems (other than removing the const from drawable::draw), which will open other issues? Or will I have to go over each widget and rewrite it even more than I already did? Personally, I see a few possibilities: * divide the code into an update() and draw() method. (drawable already provides an update() methodl, probably exactly for that purpose). * move the stuff that changes (like the text of a label) into a class of its own, as inside a const method we can call non-const methods of other objects. * do the changes before the drawing (i.e. render the label text whenever a new string is set or the color is changed), even though this might add some overhead. Or should I give up on making widgets drawables? From looking at v0.3, they weren't there either and I don't really know if there's any benefit to it. Opinions? Suggestions? Otherwise I'll sleep over it and see if a good solution presents itself. Kai P.S.: Nothing to commit, yet, as it's horribly broken right now. Expect working stuff later in the week. _______________________________________________ Adonthell-devel mailing list Adonthell-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/adonthell-devel