Re: Feature request: ChamplainView property 'show-coords'



On Tue, Nov 23, 2010 at 00:35, Robert Park <rbpark exolucere ca> wrote:
> One thing that I'm doing with libchamplain that seems like a basic
> feature that a lot of people would find useful is to have the map
> display it's coordinates directly on the map. I'm currently
> implementing this by using a ClutterText in front of a
> ClutterRectangle (the rectangle is semitransparent and simply helps
> improve the readability of the text if the map background isn't
> contrasty enough).
>
> Anyway, the code to keep the coordinate view aligned with the view
> properly (eg, when the window is resized) is a bit ugly, and I think
> it would be swell if libchamplain could take over this function for
> me, in the same way that it is capable of drawing it's own scale
> legend.
>
> The code I have looks like this:
>
> (in __init__)
>        self.coords = Clutter.Text()
>        self.coords.set_single_line_mode(True)
>        self.coords.set_parent(self.stage)
>        self.coords.raise_top()
>        self.coords.show()
>
>        self.coords_background = Clutter.Rectangle.new_with_color(
>            Clutter.Color.new(255, 255, 255, 160)
>        )
>        self.coords_background.set_parent(self.stage)
>        self.coords_background.raise_top()
>        self.coords_background.show()
>        self.coords_background.set_size(
>            self.coords.get_width() + 10,
>            self.coords.get_height() + 10
>        )
>
>        self.stage.connect('notify::height', self.position_actors)
>        self.stage.connect('notify::width', self.position_actors)
>
>    def position_actors(self, stage=None, parameter=None):
>        self.coords.set_position(
>            (self.stage.get_width() - self.coords.get_width()) / 2,
>             self.stage.get_height() - 2 * self.coords.get_height()
>        )
>
>        self.coords_background.set_position(
>            self.coords.get_x() - 5,
>            self.coords.get_y() - 5
>        )
>
> Anyway, I think that's all kind of ugly, and I'd really super duper
> appreciate it if libchamplain could just do all that messy stuff for
> me, and I could replace all of the above with this:
>
>        self.map_view.set_property('show-scale', True)
>        self.map_view.set_property('show-coords', True)
>
> That would be so neat and tidy ;-)
>
> Surely other app developers using libchamplain would appreciate such a
> feature? It would cut down on duplicated work between apps for
> something that I think most apps using libchamplain would want to have
> (for example, Google Earth displays coordinates in a similar way, and
> so does PhotoLinker.app)
>
> Thanks guys!

Hi Robert,

this is the kind of thing I would like to address in 0.10, but in a
slightly different way. The problem with adding new methods into
ChamplainView is that this solution is not very flexible. If you
consider the scale, one would have to add functions for changing its
position, size, vertical or horizontal orientation and so on. And
similar set of functions would have to be added for all other elements
users want to see on top of their map (like your coordinates).

Instead I would like to move the scale outside the ChamplainView code
and make it an independent actor that can be added to ChamplainView
and connected to the signals it is interested in. So the code would
look something like

champlain_scale = ChamplainScale()

champlain_view.add(champlain_scale)

champlain_scale.set_position(x, y)
# + possibly scale, rotate and so on (since ChamplainScale would
inherit from ClutterActor, we'd have all the ClutterActor
functionality)

# connect the necessary ChamplainView signals that the actor has to
take into account for its painting
champlain_scale.connect_signals()

And the same could be done for your coordinate view if we make such an
actor. This will also make the implementation of ChamplainView much
simpler as it won't have to care about what type of actors it
contains.

I haven't had much time recently but it looks it should get better
starting from the next week so I hope to get this into the next
release in time.

Cheers,

Jiri


>
> --
> http://exolucere.ca
> _______________________________________________
> libchamplain-list mailing list
> libchamplain-list gnome org
> http://mail.gnome.org/mailman/listinfo/libchamplain-list
>


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