From 5cf999b48c5813fa962ee1188815c90b6971c3cb Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 12 Mar 2008 07:57:10 +0000 Subject: [PATCH] added menu prototypes and fixed small bugs git-svn-id: http://www.neo1973-germany.de/svn@28 46df4e5c-bc4e-4628-a0fc-830ba316316d --- pylgrim/pylgrim.edc | 362 +++++++++++++++++++++++++++----------------- pylgrim/pylgrim.py | 35 +++-- 2 files changed, 248 insertions(+), 149 deletions(-) diff --git a/pylgrim/pylgrim.edc b/pylgrim/pylgrim.edc index 8646290..dcb3077 100644 --- a/pylgrim/pylgrim.edc +++ b/pylgrim/pylgrim.edc @@ -1,6 +1,9 @@ fonts { font: "DejaVuSansMono.ttf" "Sans"; } +images { + image: "button.png" COMP; +} collections { group { @@ -23,63 +26,63 @@ collections { } } part { - name: "minus"; - type: RECT; - description { - state: "default" 0.0; - rel1 { - relative: 0.0 0.9; - offset: 0 0; - } - rel2 { - relative: 0.2 1.0; - offset: -1 -1; - } - } + name: "minus"; + type: RECT; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 0.9; + offset: 0 0; + } + rel2 { + relative: 0.2 1.0; + offset: -1 -1; + } + } } part { - name: "plus"; - type: RECT; - description { - state: "default" 0.0; - rel1 { - relative: 0.8 0.9; - offset: 0 0; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } - } + name: "plus"; + type: RECT; + description { + state: "default" 0.0; + rel1 { + relative: 0.8 0.9; + offset: 0 0; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + } } } } group { name: "overlay"; parts { - part { - name: "label"; - type: TEXT; - effect: SOFT_OUTLINE; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - relative: 0.0 0.0; - offset: 0 0; - } - rel2 { - relative: 1.0 0.1; - offset: -1 -1; - } - text { - font: "Sans"; - size: 1; - fit: 1 1; - align: 0.5 0.0; - } - } - } + part { + name: "label"; + type: TEXT; + effect: SOFT_OUTLINE; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + relative: 1.0 0.1; + offset: -1 -1; + } + text { + font: "Sans"; + size: 1; + fit: 1 1; + align: 0.5 0.0; + } + } + } part { name: "center"; type: RECT; @@ -97,101 +100,186 @@ collections { } } part { - name: "progress"; - type: TEXT; - effect: SOFT_OUTLINE; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - relative: 0.05 0.4; - offset: 0 0; - } - rel2 { - relative: 0.95 0.5; - offset: -1 -1; - } - text { - font: "Sans"; - size: 1; - fit: 1 1; - align: 0.5 1.0; - } - } + name: "progress"; + type: TEXT; + effect: SOFT_OUTLINE; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + relative: 0.05 0.4; + offset: 0 0; + } + rel2 { + relative: 0.95 0.5; + offset: -1 -1; + } + text { + font: "Sans"; + size: 1; + fit: 1 1; + align: 0.5 1.0; + } + } } part { - name: "minus"; - type: TEXT; - effect: SOFT_OUTLINE; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - relative: 0.0 0.9; - offset: 0 0; - } - rel2 { - relative: 0.2 1.0; - offset: -1 -1; - } - text { - text: "[-]"; - font: "Sans"; - size: 1; - fit: 1 1; - align: 0.5 0.5; - } - } + name: "minus"; + type: TEXT; + effect: SOFT_OUTLINE; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 0.9; + offset: 0 0; + } + rel2 { + relative: 0.2 1.0; + offset: -1 -1; + } + text { + text: "[-]"; + font: "Sans"; + size: 1; + fit: 1 1; + align: 0.5 0.5; + } + } } part { - name: "bar"; - type: TEXT; - effect: SOFT_OUTLINE; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - relative: 0.2 0.9; - offset: 0 0; - } - rel2 { - relative: 0.8 1.0; - offset: -1 -1; - } - text { - text: "|||||||||||||+||||"; - font: "Sans"; - size: 1; - fit: 1 1; - align: 0.5 0.5; - } - visible:0; - } + name: "bar"; + type: TEXT; + effect: SOFT_OUTLINE; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + relative: 0.2 0.9; + offset: 0 0; + } + rel2 { + relative: 0.8 1.0; + offset: -1 -1; + } + text { + text: "|||||||||||||+||||"; + font: "Sans"; + size: 1; + fit: 1 1; + align: 0.5 0.5; + } + visible:0; + } } part { - name: "plus"; - type: TEXT; - effect: SOFT_OUTLINE; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - relative: 0.8 0.9; - offset: 0 0; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } - text { - text: "[+]"; - font: "Sans"; - size: 1; - fit: 1 1; - align: 0.5 0.5; - } - } + name: "plus"; + type: TEXT; + effect: SOFT_OUTLINE; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + relative: 0.8 0.9; + offset: 0 0; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + text { + text: "[+]"; + font: "Sans"; + size: 1; + fit: 1 1; + align: 0.5 0.5; + } + } } } } + group { + name: "menu"; + parts + { + #define BUTTON(part_name, ypos, button_text) \ + part { \ + name: "button_clip_"part_name; \ + type: RECT; \ + mouse_events: 0; \ + description { \ + state: "default" 0.0; \ + rel1 { \ + relative: 0.1 0.1+(ypos*0.2); \ + offset: 0 0; \ + } \ + rel2 { \ + relative: 0.9 0.25+(ypos*0.2); \ + offset: -1 -1; \ + } \ + } \ + } \ + part { \ + name: "button_"part_name; \ + mouse_events: 1; \ + type: IMAGE; \ + clip_to: "button_clip_"part_name; \ + description { \ + state: "default" 0.0; \ + rel1 { \ + relative: 0.0 0.0; \ + offset: 0 0; \ + to: "button_clip_"part_name; \ + } \ + rel2 { \ + relative: 1.0 1.0; \ + offset: -1 -1; \ + to: "button_clip_"part_name; \ + } \ + image { \ + normal: "button.png"; \ + border: 20 20 20 20; \ + } \ + } \ + description { \ + state: "active" 0.0; \ + inherit: "default" 0.0; \ + image { \ + normal: "button.png"; \ + border: 20 20 20 20; \ + } \ + } \ + } \ + part { \ + name: "button_text_"part_name; \ + mouse_events: 0; \ + type: TEXT; \ + clip_to: "button_clip_"part_name; \ + effect: SOFT_OUTLINE; \ + description { \ + state: "default" 0.0; \ + rel1 { \ + relative: 0.1 0.0; \ + offset: 0 0; \ + to: "button_clip_"part_name; \ + } \ + rel2 { \ + relative: 0.9 1.0; \ + offset: -1 -1; \ + to: "button_clip_"part_name; \ + } \ + text { \ + font: "Sans"; \ + size: 1; \ + fit: 1 1; \ + align: 0.5 0.5; \ + text: button_text; \ + } \ + } \ + } + BUTTON("0", 0, "fix to GPS"); + BUTTON("1", 1, "wiki POIs"); + BUTTON("2", 2, "online mode"); + BUTTON("3", 3, "back"); + } + } } diff --git a/pylgrim/pylgrim.py b/pylgrim/pylgrim.py index 3cf0462..67792c3 100755 --- a/pylgrim/pylgrim.py +++ b/pylgrim/pylgrim.py @@ -84,11 +84,11 @@ class Pylgrim(edje.Edje): self.tiles_to_preload = [] #initial lat,lon,zoom - self.lat = 0 - self.lon = 0 + self.lat = initial_lat + self.lon = initial_lon self.x = 0 self.y = 0 - self.z = 0 + self.z = initial_zoom self.offset_x = 0 self.offset_y = 0 @@ -112,7 +112,15 @@ class Pylgrim(edje.Edje): self.progress.color = 255, 0, 0, 255 self.progress.layer = 4 self.progress.show() - + + ''' + self.menu = edje.Edje(self.evas_canvas.evas_obj.evas, file=filename, group='menu') + self.menu.size = self.evas_canvas.evas_obj.evas.size + self.menu.layer = 4 + self.evas_canvas.evas_obj.data["menu"] = self.menu + self.menu.show() + ''' + #calculate size of tile raster self.border_x = int(math.ceil(self.size[0]/256.0)) self.border_y = int(math.ceil(self.size[1]/256.0)) @@ -152,6 +160,13 @@ class Pylgrim(edje.Edje): except Exception, e: print 'LocationFeed', e return True + + def position(self, content): + latitude = float(content.get('latitude', self.lat)) + longitude = float(content.get('longitude', self.lon)) + print 'position', latitude, longitude + if not self.animate: + self.set_current_tile(latitude, longitude, self.z) def on_key_down(self, obj, event): if event.keyname in ("F6", "f"): @@ -211,15 +226,11 @@ class Pylgrim(edje.Edje): if os.path.exists(filename): os.unlink(filename) - def position(self, content): - latitude = float(content.get('latitude', self.lat)) - longitude = float(content.get('longitude', self.lon)) - print 'position', latitude, longitude - if not self.animate: - self.set_current_tile(latitude, longitude, self.z) - #jump to coordinates def set_current_tile(self, lat, lon, z): + #update shown coordinates everytime they change + self.overlay.part_text_set("label", "lat:%f lon:%f zoom:%d"%(lat,lon,z)) + x = (lon+180)/360 * 2**z y = (1-math.log(math.tan(lat*math.pi/180) + 1/math.cos(lat*math.pi/180))/math.pi)/2 * 2**z offset_x, offset_y = int((x-int(x))*256),int((y-int(y))*256) @@ -307,7 +318,6 @@ class Pylgrim(edje.Edje): self.overlay.part_text_set("progress", "") self.progress_bg.geometry = 0,0,0,0 self.progress.geometry = 0,0,0,0 - self.update_coordinates() self.animate = False return False @@ -382,6 +392,7 @@ class Pylgrim(edje.Edje): self.y = int(self.y) + (self.offset_y-self.current_pos[1])/256.0 self.offset_x, self.offset_y = int((self.x-int(self.x))*256),int((self.y-int(self.y))*256) self.init_redraw() + self.update_coordinates() if abs(self.current_pos[0]) > 0 or abs(self.current_pos[1]) > 0: #on mouse up + move: update current coordinates self.update_coordinates()