Feature request: ChamplainView property 'show-coords'



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!

-- 
http://exolucere.ca


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