now fully resizable for EVERY desired resolution
git-svn-id: http://www.neo1973-germany.de/svn@10 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
b432bd213f
commit
56f46db575
1 changed files with 35 additions and 23 deletions
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#coding=utf8
|
#coding=utf8
|
||||||
|
|
||||||
WIDTH = 800
|
WIDTH = 480
|
||||||
HEIGHT = 480
|
HEIGHT = 640
|
||||||
|
|
||||||
TITLE = "pylgrim"
|
TITLE = "pylgrim"
|
||||||
WM_NAME = "pylgrim"
|
WM_NAME = "pylgrim"
|
||||||
|
@ -74,6 +74,7 @@ class TestView(edje.Edje):
|
||||||
self.size = self.evas_canvas.evas_obj.evas.size
|
self.size = self.evas_canvas.evas_obj.evas.size
|
||||||
self.on_key_down_add(self.on_key_down)
|
self.on_key_down_add(self.on_key_down)
|
||||||
self.focus = True
|
self.focus = True
|
||||||
|
self.evas_canvas.evas_obj.data["main"] = self
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,13 +94,11 @@ class TestView(edje.Edje):
|
||||||
self.z = 10
|
self.z = 10
|
||||||
|
|
||||||
self.icons = []
|
self.icons = []
|
||||||
border = 3
|
|
||||||
for i in xrange((2*border+1)**2):
|
|
||||||
self.icons.append(tile(self.evas_canvas.evas_obj.evas))
|
|
||||||
|
|
||||||
self.overlay = edje.Edje(self.evas_canvas.evas_obj.evas, file=f, group='overlay')
|
self.overlay = edje.Edje(self.evas_canvas.evas_obj.evas, file=f, group='overlay')
|
||||||
self.overlay.size = self.evas_canvas.evas_obj.evas.size
|
self.overlay.size = self.evas_canvas.evas_obj.evas.size
|
||||||
self.overlay.layer = 1
|
self.overlay.layer = 1
|
||||||
|
self.evas_canvas.evas_obj.data["overlay"] = self.overlay
|
||||||
self.overlay.show()
|
self.overlay.show()
|
||||||
|
|
||||||
self.progress_bg = evas.Rectangle(self.evas_canvas.evas_obj.evas)
|
self.progress_bg = evas.Rectangle(self.evas_canvas.evas_obj.evas)
|
||||||
|
@ -114,13 +113,14 @@ class TestView(edje.Edje):
|
||||||
self.progress.layer = 3
|
self.progress.layer = 3
|
||||||
self.progress.show()
|
self.progress.show()
|
||||||
|
|
||||||
self.overlay.part_text_set("label", "lat:%f lon:%f zoom:%d"%(self.lat,self.lon,self.z))
|
self.border = 0
|
||||||
|
|
||||||
self.set_current_tile(self.lat, self.lon, self.z)
|
|
||||||
|
|
||||||
self.mouse_down = False
|
self.mouse_down = False
|
||||||
|
|
||||||
self.animate = False
|
self.animate = False
|
||||||
|
|
||||||
|
self.set_current_tile(self.lat, self.lon, self.z)
|
||||||
|
|
||||||
|
|
||||||
#jump to coordinates
|
#jump to coordinates
|
||||||
def set_current_tile(self, lat, lon, z):
|
def set_current_tile(self, lat, lon, z):
|
||||||
|
@ -132,12 +132,24 @@ class TestView(edje.Edje):
|
||||||
|
|
||||||
def init_redraw(self):
|
def init_redraw(self):
|
||||||
self.animate = True
|
self.animate = True
|
||||||
border = 3
|
#calculate size of tile raster - reload if it differs from before eg. when size changes
|
||||||
for i in xrange(2*border+1):
|
self.border = int((self.size[0]+self.size[1])/512)+1
|
||||||
for j in xrange(2*border+1):
|
if len(self.icons) != (2*self.border+1)**2:
|
||||||
if not os.path.exists("%d/%d/%d.png"%(self.z,self.x+i-border,self.y+j-border)):
|
print "use", self.border
|
||||||
self.tiles_to_download.append((self.z,self.x+i-border,self.y+j-border))
|
#clean up
|
||||||
|
for icon in self.icons:
|
||||||
|
icon.delete()
|
||||||
|
self.icons = []
|
||||||
|
#fill
|
||||||
|
for i in xrange((2*self.border+1)**2):
|
||||||
|
self.icons.append(tile(self.evas_canvas.evas_obj.evas))
|
||||||
|
#add all tiles that are not yet downloaded to a list
|
||||||
|
for i in xrange(2*self.border+1):
|
||||||
|
for j in xrange(2*self.border+1):
|
||||||
|
if not os.path.exists("%d/%d/%d.png"%(self.z,self.x+i-self.border,self.y+j-self.border)):
|
||||||
|
self.tiles_to_download.append((self.z,self.x+i-self.border,self.y+j-self.border))
|
||||||
self.tiles_to_download_total = len(self.tiles_to_download)
|
self.tiles_to_download_total = len(self.tiles_to_download)
|
||||||
|
#if there are tiles to download, display progress bar
|
||||||
if self.tiles_to_download_total > 0:
|
if self.tiles_to_download_total > 0:
|
||||||
self.progress_bg.geometry = 39, self.size[1]/2-1, self.size[0]-78,22
|
self.progress_bg.geometry = 39, self.size[1]/2-1, self.size[0]-78,22
|
||||||
self.progress.geometry = 40, self.size[1]/2, 1,20
|
self.progress.geometry = 40, self.size[1]/2, 1,20
|
||||||
|
@ -153,13 +165,12 @@ class TestView(edje.Edje):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#if all tiles are downloaded
|
#if all tiles are downloaded
|
||||||
border = 3
|
for i in xrange(2*self.border+1):
|
||||||
for i in xrange(2*border+1):
|
for j in xrange(2*self.border+1):
|
||||||
for j in xrange(2*border+1):
|
self.icons[(2*self.border+1)*i+j].file_set("%d/%d/%d.png"%(self.z,self.x+i-self.border,self.y+j-self.border))
|
||||||
self.icons[(2*border+1)*i+j].file_set("%d/%d/%d.png"%(self.z,self.x+i-border,self.y+j-border))
|
self.icons[(2*self.border+1)*i+j].set_position((i-self.border)*256+self.size[0]/2-self.offset_x,(j-self.border)*256+self.size[1]/2-self.offset_y)
|
||||||
self.icons[(2*border+1)*i+j].set_position((i-border)*256+self.size[0]/2-self.offset_x,(j-border)*256+self.size[1]/2-self.offset_y)
|
self.icons[(2*self.border+1)*i+j].size = 256,256
|
||||||
self.icons[(2*border+1)*i+j].size = 256,256
|
self.icons[(2*self.border+1)*i+j].fill = 0, 0, 256, 256
|
||||||
self.icons[(2*border+1)*i+j].fill = 0, 0, 256, 256
|
|
||||||
self.current_pos = (0,0)
|
self.current_pos = (0,0)
|
||||||
self.overlay.part_text_set("progress", "")
|
self.overlay.part_text_set("progress", "")
|
||||||
self.progress_bg.geometry = 0,0,0,0
|
self.progress_bg.geometry = 0,0,0,0
|
||||||
|
@ -231,7 +242,7 @@ class TestView(edje.Edje):
|
||||||
def on_mouse_up(self, emission, source):
|
def on_mouse_up(self, emission, source):
|
||||||
self.mouse_down = False
|
self.mouse_down = False
|
||||||
if not self.animate:
|
if not self.animate:
|
||||||
if abs(self.current_pos[0]) > 50 or abs(self.current_pos[1]) > 50:
|
if abs(self.current_pos[0]) > self.size[0]/2 or abs(self.current_pos[1]) > self.size[1]/2:
|
||||||
self.x = int(self.x) + (self.offset_x-self.current_pos[0])/256.0
|
self.x = int(self.x) + (self.offset_x-self.current_pos[0])/256.0
|
||||||
self.y = int(self.y) + (self.offset_y-self.current_pos[1])/256.0
|
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.offset_x, self.offset_y = int((self.x-int(self.x))*256),int((self.y-int(self.y))*256)
|
||||||
|
@ -269,7 +280,7 @@ class EvasCanvas(object):
|
||||||
|
|
||||||
self.evas_obj.title = TITLE
|
self.evas_obj.title = TITLE
|
||||||
self.evas_obj.name_class = (WM_NAME, WM_CLASS)
|
self.evas_obj.name_class = (WM_NAME, WM_CLASS)
|
||||||
self.evas_obj.fullscreen = False #fullscreen
|
self.evas_obj.fullscreen = fullscreen
|
||||||
self.evas_obj.size = size
|
self.evas_obj.size = size
|
||||||
self.evas_obj.show()
|
self.evas_obj.show()
|
||||||
|
|
||||||
|
@ -278,6 +289,7 @@ class EvasCanvas(object):
|
||||||
size = (w, h)
|
size = (w, h)
|
||||||
for key in evas_obj.data.keys():
|
for key in evas_obj.data.keys():
|
||||||
evas_obj.data[key].size = size
|
evas_obj.data[key].size = size
|
||||||
|
evas_obj.data["main"].init_redraw()
|
||||||
|
|
||||||
def on_delete_request(self, evas_obj):
|
def on_delete_request(self, evas_obj):
|
||||||
ecore.main_loop_quit()
|
ecore.main_loop_quit()
|
||||||
|
@ -310,7 +322,7 @@ class myOptionParser(OptionParser):
|
||||||
default=20,
|
default=20,
|
||||||
help="frames per second to use, default=%default")
|
help="frames per second to use, default=%default")
|
||||||
|
|
||||||
def parse_geometry(option, opt, value, parser):
|
def parse_geometry(self, option, opt, value, parser):
|
||||||
try:
|
try:
|
||||||
w, h = value.split("x")
|
w, h = value.split("x")
|
||||||
w = int(w)
|
w = int(w)
|
||||||
|
|
Loading…
Reference in a new issue