per gli svg? non so bene come si trattano...ma credo che siano come immagini che si adattano a ogni risoluzione giusto? Cioè se disegno un cerchio di raggio 5 unità (?) su un display piccolo lo vedo in un modo e in quello grande lo vedo uguale? Ma l'immagine, facendo il blit() si adatta automaticamente? Scusate ma sono proprio nuovo su svg
Winfile Porting...
#21
OFFLINE
Posted 08 September 2010 - 19:48
per gli svg? non so bene come si trattano...ma credo che siano come immagini che si adattano a ogni risoluzione giusto? Cioè se disegno un cerchio di raggio 5 unità (?) su un display piccolo lo vedo in un modo e in quello grande lo vedo uguale? Ma l'immagine, facendo il blit() si adatta automaticamente? Scusate ma sono proprio nuovo su svg
#22
OFFLINE
Posted 08 September 2010 - 20:59
per quanto riguarda gli svg potresti dare un'occhiata qui http://www.nokioteca...howtopic=146743
#23
OFFLINE
Posted 18 September 2010 - 11:24
Faccio un esempio: in alcune funzioni di disegno, viene disegnata la barra laterale. In ogni funzione ho fatto praticamente un copia incolla delle stesse istruzioni, ma ciò oltre che a essere poco efficiente, provoca anche un grosso problema: se cambio qualcosa da una parte devo cambiare dappertutto e magari inavvertitamente aggiungo un bug che da una parte non c'è. Molte cose le avevo già sistemate, ma altre ancora no.
Fatte queste cose direi che rilascio una beta ancora 2nd ed. Poi una versione stabile e poi procedo con il port (credo tra un mesetto forse posterò già qualcosa)
#24
OFFLINE
#25
OFFLINE
Posted 24 October 2010 - 12:29
ancora precedenza ai 2nd??
No! Lavoro in parallelo
Adesso mi sa che mi conviene dividere i sorgenti nelle parti in cui ci sono troppe differenze per facilitare il tutto.
Comunque tutto procede benone, solo alcune domande:
1. Come posso implementare lo scrolling delle liste, menu ecc..? Dovrei scrivere io da zero qualcosa? Intendo anche il kinetic scroll!
EDIT:: ah! scusate! infatti ho guardato sys.path e sembra bisogna sempre definire una directory...poi vedrò in app standalone!
EDIT2: ah! ora pure i moduli py devono essere case sensitive
Edited by memoryn70, 24 October 2010 - 12:41.
#26
OFFLINE
Posted 26 October 2010 - 22:31
#27
OFFLINE
Posted 02 November 2010 - 18:12
riguardo al programma in se ho fatto solo qualche ritocco...intanto però sto creando la classe per la gestione delle barre (siano laterali (di scorrimento) oppure di stato (avanzamento)). Ho già tirato fuori qualcosa di funzionante (ovviamente anche con il touch screen) e devo dire che sono soddisfatto. Ovviamente c'è molto ancora da fare (soprattutto per il supporto al touch).
Da fare:
- classe bottoni
- classe kinetic, per gestire lo scroll di tutti gli elementi "scrollabili" (
- sistemare la grafica in modo che si adatti in base a percentuali (cosi su ogni schermo si vedono gli spazi simili)
Ecco qui la classe con due barre di esempio, per chi volesse provare. Faccio notare che il codice non è ottimizzato e contiene ancora, magari, calcoli/variabili/assegnazioni inutili. Anche la logica di funzionamento probabilmente sarà modificata.
Se avete dei consigli oppure notate bug ecc... non esitate a dirmelo anzi ne sarò molto felice
import appuifw
from key_codes import *
class ScrollBar:
#A class to mangage screen bars, with touch event support
#by Memory
#Version: 0.1 alpha
def __init__(s, img, feedback=1):
s.img = img #Where to draw everything
s.id = 0 #default 0
s.description = None #a short press of the area to show up this message
s.orientation = 'horizontal' # or horizontal
s.type = 'statusbar' # or sidebar
s.position = (0,0) #position of the first edge on the bar
s.lenght = 100
s.height = 10
s.bg_fill_color = None #None if no background (transparent), otherwise a color
s.bg_outline_color = 0
s.bar_fill_color = 0 #or None for transparent
s.bar_outline_color = 0 #or None
#s.pattern = None
s.max_value = 100
s.min_value = 0
s.range = float(abs(s.max_value - s.min_value))
s.actual_value = 0
s.step = 1 #default step
#Calculation of some values
s.init_values()
s.feedback = feedback
s.callback = None #If set, use this in some functions instead of ScrollBar.draw()
# if s.feedback:
#set touch screen feedback
# s.set_touch()
def set_touch(s, canvas):
canvas.bind(EDrag, s.touch_event, s.coords_touch)
def touch_event(s, pos):
# !!! values are float !!! Remember it for calculation precision
if s.orientation == 'vertical':
unit = abs(pos[1]-s.coords[0][1])
scale = s.range / s.rect[1][1]
elif s.orientation == 'horizontal':
unit = abs(pos[0]-s.coords[0][0])
scale = s.range / s.rect[1][0]
if s.type == 'statusbar':
#print "Moved to:",pos , unit
val = unit * scale
if val>s.max_value:
val = s.max_value
if val<s.min_value:
val = s.min_value
s.actual_value = val
#print val
if s.callback:
s.callback()
else:
s.draw()
def set_default(s):
init_values()
def init_values(s):
#Initialize coords and other values
if s.orientation == 'horizontal':
s.rect = [(0,0),(s.lenght, s.height)]
elif s.orientation == 'vertical':
s.rect = [(0,0),(s.height, s.lenght)]
s.coords = [ s.position, (s.rect[1][0]+s.position[0], s.rect[1][1]+s.position[1]) ]
#Here the coords for touch event. They are approx 5% "bigger" than the rectangle of the bar to increase sensitivity
#TODO: add a specific variable to define this, maybe ?
s.coords_touch = [ (int(s.position[0]*0.95), int(s.position[1]*0.95)) , (int((s.rect[1][0]+s.position[0]) * 1.05), int((s.rect[1][1]+s.position[1]) * 1.05)) ]
print s.coords, s.rect
def percentage(s):
return float(s.actual_value) / s.max_value * 100.0
def draw(s):
#s.img.clear(0xffffff) #to be removed!!!
s.img.rectangle(s.coords, None, s.bg_fill_color)
if s.type == 'statusbar':
perc = float(s.actual_value) / s.max_value
if s.orientation == 'vertical':
s.img.rectangle( (s.position, (s.coords[1][0], s.position[1]+int(s.rect[1][1]*perc)) ), s.bar_outline_color, s.bar_fill_color)
elif s.orientation == 'horizontal':
s.img.rectangle( (s.position, (s.position[0]+int(s.rect[1][0]*perc), s.coords[1][1]) ), s.bar_outline_color, s.bar_fill_color)
s.img.rectangle(s.coords, s.bg_outline_color, None)
def increase(s, v=1):
s.actual_value += v
def decrease(s, v=1):
s.actual_value -= v
bars = []
def draw(rect=None):
c.clear(0xffffff) #Clean the screen for this example application
for bar in bars:
bar.draw() #Request redraw for each registered bar
c=appuifw.Canvas(redraw_callback=draw)
appuifw.app.body=c
#First bar
s=ScrollBar(c)
s.position = (100,100)
s.lenght = 200
s.height = 20
s.callback = draw
s.init_values()
s.set_touch(c)
bars.append(s)
#s.draw()
#
#Second bar
s1=ScrollBar(c)
s1.position = (50,100)
s1.orientation = 'vertical'
s1.lenght = 200
s1.height = 20
s.bg_fill_color = 0xaaaaaa #None if no background (transparent), otherwise a color
s.bg_outline_color = 0
s.bar_fill_color = 0 #or None for transparent
s.bar_outline_color = 0xff #or None
s.callback = draw
s1.init_values()
s1.set_touch(c)
bars.append(s1)
#s1.draw()
#
draw() # first draw
import e32
l=e32.Ao_lock()
l.wait()
#28
OFFLINE
Posted 02 November 2010 - 18:58
Manca la parte scritta...e molte altre cosette, ovviamente, come prima!
import appuifw
from key_codes import *
class ScrollBar:
#A class to mangage screen bars, with touch event support
#by Memory
#Version: 0.1 alpha
def __init__(s, img, feedback=1):
s.img = img #Where to draw everything
s.id = 0 #default 0
s.description = None #a short press of the area to show up this message
s.orientation = 'horizontal' # or horizontal
s.type = 'statusbar' # or sidebar
s.position = (0,0) #position of the first edge on the bar
s.lenght = 100
s.height = 10
s.bg_fill_color = None #None if no background (transparent), otherwise a color
s.bg_outline_color = 0
s.bar_fill_color = 0 #or None for transparent
s.bar_outline_color = 0 #or None
#s.pattern = None
s.max_value = 100
s.min_value = 0
s.range = float(abs(s.max_value - s.min_value))
s.actual_value = 0
s.step = 1 #default step
#Calculation of some values
s.init_values()
s.feedback = feedback
s.callback = None #If set, use this in some functions instead of ScrollBar.draw()
# if s.feedback:
#set touch screen feedback
# s.set_touch()
def set_touch(s, canvas):
canvas.bind(EDrag, s.touch_event, s.coords_touch)
def touch_event(s, pos):
# !!! values are float !!! Remember it for calculation precision
if s.orientation == 'vertical':
unit = abs(pos[1]-s.coords[0][1])
scale = s.range / s.rect[1][1]
elif s.orientation == 'horizontal':
unit = abs(pos[0]-s.coords[0][0])
scale = s.range / s.rect[1][0]
if s.type == 'statusbar':
#print "Moved to:",pos , unit
val = unit * scale
if val>s.max_value:
val = s.max_value
if val<s.min_value:
val = s.min_value
s.actual_value = val
#print val
if s.callback:
s.callback()
else:
s.draw()
def set_default(s):
init_values()
def init_values(s):
#Initialize coords and other values
if s.orientation == 'horizontal':
s.rect = [(0,0),(s.lenght, s.height)]
elif s.orientation == 'vertical':
s.rect = [(0,0),(s.height, s.lenght)]
s.coords = [ s.position, (s.rect[1][0]+s.position[0], s.rect[1][1]+s.position[1]) ]
#Here the coords for touch event. They are approx 5% "bigger" than the rectangle of the bar to increase sensitivity
#TODO: add a specific variable to define this, maybe ?
s.coords_touch = [ (int(s.position[0]*0.95), int(s.position[1]*0.95)) , (int((s.rect[1][0]+s.position[0]) * 1.05), int((s.rect[1][1]+s.position[1]) * 1.05)) ]
print s.coords, s.rect
def percentage(s):
return float(s.actual_value) / s.max_value * 100.0
def draw(s):
#s.img.clear(0xffffff) #to be removed!!!
s.img.rectangle(s.coords, None, s.bg_fill_color)
if s.type == 'statusbar':
perc = float(s.actual_value) / s.max_value
if s.orientation == 'vertical':
s.img.rectangle( (s.position, (s.coords[1][0], s.position[1]+int(s.rect[1][1]*perc)) ), s.bar_outline_color, s.bar_fill_color)
elif s.orientation == 'horizontal':
s.img.rectangle( (s.position, (s.position[0]+int(s.rect[1][0]*perc), s.coords[1][1]) ), s.bar_outline_color, s.bar_fill_color)
s.img.rectangle(s.coords, s.bg_outline_color, None)
def increase(s, v=1):
s.actual_value += v
def decrease(s, v=1):
s.actual_value -= v
class Button:
#A class to mangage a button element, with touch event support
#version 0.1 alpha
def __init__(s, img):
s.img = img #where to draw it
s.description = None #A short description of the button
s.callback = None #Callback assigned with it
s.caption = None #Label of the button
s.font = ('normal', 14)
s.position = (0,0)
s.size = (30,15) #The size (width, height)
s.bg_fill_color = None #None if no background (transparent), otherwise a color
s.bg_outline_color = 0
s.bg_img = None #If you want to use an image...It will be stretched if too small / large!
s.init_values()
def init_values(s):
#Initialize coords and other values
s.rect = [(0,0),s.size]
s.coords = [ s.position, (s.rect[1][0]+s.position[0], s.rect[1][1]+s.position[1]) ]
#Here the coords for touch event. They are approx 5% "bigger" than the rectangle of the bar to increase sensitivity
#TODO: add a specific variable to define this, maybe ?
#s.coords_touch = [ (int(s.position[0]*0.95), int(s.position[1]*0.95)) , (int((s.rect[1][0]+s.position[0]) * 1.05), int((s.rect[1][1]+s.position[1]) * 1.05)) ]
print s.coords, s.rect
def set_touch(s, canvas):
canvas.bind(EButton1Up, s.pressed, s.coords)
canvas.bind(EButton1Down, s.pressing, s.coords)
####
#To remove the state of pressed
#canvas.bind(EButton1Up, s.draw) #Warning: this isn't safe!!!
###
def pressed(s, pos):
if s.callback:
s.callback()
s.draw()
def pressing(s, pos):
s.draw(1)
def draw(s, pressing = 0):
if pressing:
s.img.rectangle(s.coords, None, s.bg_outline_color)
s.img.rectangle(s.coords, s.bg_fill_color, None)
else:
s.img.rectangle(s.coords, None, s.bg_fill_color)
s.img.rectangle(s.coords, s.bg_outline_color, None)
bars = []
def draw(rect=None):
c.clear(0xffffff) #Clean the screen for this example application
for bar in bars:
bar.draw() #Request redraw for each registered bar
c=appuifw.Canvas(redraw_callback=draw)
appuifw.app.body=c
#First bar
s=ScrollBar(c)
s.position = (100,100)
s.lenght = 200
s.height = 20
s.callback = draw
s.init_values()
s.set_touch(c)
bars.append(s)
#s.draw()
#
#Second bar
s1=ScrollBar(c)
s1.position = (50,100)
s1.orientation = 'vertical'
s1.lenght = 200
s1.height = 20
s.bg_fill_color = 0xaaaaaa #None if no background (transparent), otherwise a color
s.bg_outline_color = 0
s.bar_fill_color = 0 #or None for transparent
s.bar_outline_color = 0xff #or None
s.callback = draw
s1.init_values()
s1.set_touch(c)
bars.append(s1)
#s1.draw()
#
btn = Button(c)
btn.position = (100,20)
btn.size = (60, 25)
btn.bg_fill_color = 0x0033CC
btn.bg_outline_color = 0xffffff
btn.init_values()
btn.callback = lambda: appuifw.note(u"Ciao!")
btn.set_touch(c)
bars.append(btn)
draw() # first draw
import e32
l=e32.Ao_lock()
l.wait()
#29
OFFLINE
Posted 12 February 2011 - 17:09
Per più informazioni leggete il post in programmi 2nd...
#30
OFFLINE
Posted 13 February 2011 - 10:03
Come ho scritto nel post ufficiale 2nd edition, sto facendo molti progressi per il porting!!
Per più informazioni leggete il post in programmi 2nd...
Colgo l'occasione per chiedere se python gira anche su symbian^3! Se ci sono eventuali problemi ecc...
Grazie













