added menu prototypes and fixed small bugs

git-svn-id: http://www.neo1973-germany.de/svn@28 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
josch 2008-03-12 07:57:10 +00:00
parent 9d3975ccc0
commit 5cf999b48c
2 changed files with 248 additions and 149 deletions

View file

@ -1,6 +1,9 @@
fonts { fonts {
font: "DejaVuSansMono.ttf" "Sans"; font: "DejaVuSansMono.ttf" "Sans";
} }
images {
image: "button.png" COMP;
}
collections { collections {
group { group {
@ -23,63 +26,63 @@ collections {
} }
} }
part { part {
name: "minus"; name: "minus";
type: RECT; type: RECT;
description { description {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
relative: 0.0 0.9; relative: 0.0 0.9;
offset: 0 0; offset: 0 0;
} }
rel2 { rel2 {
relative: 0.2 1.0; relative: 0.2 1.0;
offset: -1 -1; offset: -1 -1;
} }
} }
} }
part { part {
name: "plus"; name: "plus";
type: RECT; type: RECT;
description { description {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
relative: 0.8 0.9; relative: 0.8 0.9;
offset: 0 0; offset: 0 0;
} }
rel2 { rel2 {
relative: 1.0 1.0; relative: 1.0 1.0;
offset: -1 -1; offset: -1 -1;
} }
} }
} }
} }
} }
group { group {
name: "overlay"; name: "overlay";
parts { parts {
part { part {
name: "label"; name: "label";
type: TEXT; type: TEXT;
effect: SOFT_OUTLINE; effect: SOFT_OUTLINE;
mouse_events: 0; mouse_events: 0;
description { description {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
relative: 0.0 0.0; relative: 0.0 0.0;
offset: 0 0; offset: 0 0;
} }
rel2 { rel2 {
relative: 1.0 0.1; relative: 1.0 0.1;
offset: -1 -1; offset: -1 -1;
} }
text { text {
font: "Sans"; font: "Sans";
size: 1; size: 1;
fit: 1 1; fit: 1 1;
align: 0.5 0.0; align: 0.5 0.0;
} }
} }
} }
part { part {
name: "center"; name: "center";
type: RECT; type: RECT;
@ -97,101 +100,186 @@ collections {
} }
} }
part { part {
name: "progress"; name: "progress";
type: TEXT; type: TEXT;
effect: SOFT_OUTLINE; effect: SOFT_OUTLINE;
mouse_events: 0; mouse_events: 0;
description { description {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
relative: 0.05 0.4; relative: 0.05 0.4;
offset: 0 0; offset: 0 0;
} }
rel2 { rel2 {
relative: 0.95 0.5; relative: 0.95 0.5;
offset: -1 -1; offset: -1 -1;
} }
text { text {
font: "Sans"; font: "Sans";
size: 1; size: 1;
fit: 1 1; fit: 1 1;
align: 0.5 1.0; align: 0.5 1.0;
} }
} }
} }
part { part {
name: "minus"; name: "minus";
type: TEXT; type: TEXT;
effect: SOFT_OUTLINE; effect: SOFT_OUTLINE;
mouse_events: 0; mouse_events: 0;
description { description {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
relative: 0.0 0.9; relative: 0.0 0.9;
offset: 0 0; offset: 0 0;
} }
rel2 { rel2 {
relative: 0.2 1.0; relative: 0.2 1.0;
offset: -1 -1; offset: -1 -1;
} }
text { text {
text: "[-]"; text: "[-]";
font: "Sans"; font: "Sans";
size: 1; size: 1;
fit: 1 1; fit: 1 1;
align: 0.5 0.5; align: 0.5 0.5;
} }
} }
} }
part { part {
name: "bar"; name: "bar";
type: TEXT; type: TEXT;
effect: SOFT_OUTLINE; effect: SOFT_OUTLINE;
mouse_events: 0; mouse_events: 0;
description { description {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
relative: 0.2 0.9; relative: 0.2 0.9;
offset: 0 0; offset: 0 0;
} }
rel2 { rel2 {
relative: 0.8 1.0; relative: 0.8 1.0;
offset: -1 -1; offset: -1 -1;
} }
text { text {
text: "|||||||||||||+||||"; text: "|||||||||||||+||||";
font: "Sans"; font: "Sans";
size: 1; size: 1;
fit: 1 1; fit: 1 1;
align: 0.5 0.5; align: 0.5 0.5;
} }
visible:0; visible:0;
} }
} }
part { part {
name: "plus"; name: "plus";
type: TEXT; type: TEXT;
effect: SOFT_OUTLINE; effect: SOFT_OUTLINE;
mouse_events: 0; mouse_events: 0;
description { description {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
relative: 0.8 0.9; relative: 0.8 0.9;
offset: 0 0; offset: 0 0;
} }
rel2 { rel2 {
relative: 1.0 1.0; relative: 1.0 1.0;
offset: -1 -1; offset: -1 -1;
} }
text { text {
text: "[+]"; text: "[+]";
font: "Sans"; font: "Sans";
size: 1; size: 1;
fit: 1 1; fit: 1 1;
align: 0.5 0.5; 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");
}
}
} }

View file

@ -84,11 +84,11 @@ class Pylgrim(edje.Edje):
self.tiles_to_preload = [] self.tiles_to_preload = []
#initial lat,lon,zoom #initial lat,lon,zoom
self.lat = 0 self.lat = initial_lat
self.lon = 0 self.lon = initial_lon
self.x = 0 self.x = 0
self.y = 0 self.y = 0
self.z = 0 self.z = initial_zoom
self.offset_x = 0 self.offset_x = 0
self.offset_y = 0 self.offset_y = 0
@ -113,6 +113,14 @@ class Pylgrim(edje.Edje):
self.progress.layer = 4 self.progress.layer = 4
self.progress.show() 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 #calculate size of tile raster
self.border_x = int(math.ceil(self.size[0]/256.0)) self.border_x = int(math.ceil(self.size[0]/256.0))
self.border_y = int(math.ceil(self.size[1]/256.0)) self.border_y = int(math.ceil(self.size[1]/256.0))
@ -153,6 +161,13 @@ class Pylgrim(edje.Edje):
print 'LocationFeed', e print 'LocationFeed', e
return True 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): def on_key_down(self, obj, event):
if event.keyname in ("F6", "f"): if event.keyname in ("F6", "f"):
self.evas_canvas.evas_obj.fullscreen = not self.evas_canvas.evas_obj.fullscreen self.evas_canvas.evas_obj.fullscreen = not self.evas_canvas.evas_obj.fullscreen
@ -211,15 +226,11 @@ class Pylgrim(edje.Edje):
if os.path.exists(filename): if os.path.exists(filename):
os.unlink(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 #jump to coordinates
def set_current_tile(self, lat, lon, z): 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 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 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) 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.overlay.part_text_set("progress", "")
self.progress_bg.geometry = 0,0,0,0 self.progress_bg.geometry = 0,0,0,0
self.progress.geometry = 0,0,0,0 self.progress.geometry = 0,0,0,0
self.update_coordinates()
self.animate = False self.animate = False
return 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.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)
self.init_redraw() self.init_redraw()
self.update_coordinates()
if abs(self.current_pos[0]) > 0 or abs(self.current_pos[1]) > 0: if abs(self.current_pos[0]) > 0 or abs(self.current_pos[1]) > 0:
#on mouse up + move: update current coordinates #on mouse up + move: update current coordinates
self.update_coordinates() self.update_coordinates()