solang-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Solang-devel] Introducing the RendererRegistry


From: Debarshi Ray
Subject: [Solang-devel] Introducing the RendererRegistry
Date: Thu, 6 Aug 2009 18:41:58 +0530

Till now there was no way to cleanly switch from one renderer to
another. eg., from the browser to the enlarged or editor. We hacked
through the mess by using a bunch of signals in the Engine which the
older renderer would emit and the newer one would respond to. Then the
newly presented renderer would use a string as a key to fetch the
IRendererPtr from the Application and set it as the current renderer.

The problems with this approach were:
1) Each old and new renderer pair would need a separate signal in the
Engine. So to switch back and forth from three renderers one would
need six separate signals. Although we may not need to actually switch
between all permutations this does not look elegant to me.
2) Using a string as a key in a map to identify a particular
implementation of IRenderer is type unsafe.

So the idea is to use a RendererRegistry which is basically a list of
all the renderers and a mechanism to select a particular
implementation of IRenderer in a typesafe manner.

RendererRegistry & renderer_registry = application_->get_renderer_registry();
const IRendererPtr enlarged_renderer =
renderer_registry.select<EnlargedRenderer>();

if (0 == enlarged_renderer)
{
    return;
}
...
...
enlarged_renderer->render(photo); // current photo from the listStore
to be enlarged
enlarged_renderer->present(); // switch to enlarged_renderer
...
...
renderer_registry.set_current(enlarged_renderer);

The idea is to get the IRenderer::present method to simulate the task
of manually clicking the renderer tab. Once that is done the
on_switch_page handler does the remaining job of showing the UI
controls and setting the current renderer. This way the
on_switch_page_handler code is same for manually and programmatically
changing the renderer.

So here are a couple of patches to implement this:
http://rishi.fedorapeople.org/0001-Use-IRenderer-instead-of-Renderer.patch
http://rishi.fedorapeople.org/0002-Basic-RendererRegistry.patch (the real stuff)

Happy hacking,
Debarshi
-- 
One reason that life is complex is that it has a real part and an
imaginary part.
    -- Andrew Koenig




reply via email to

[Prev in Thread] Current Thread [Next in Thread]