Commit 571e01e0 authored by Bruno Coudoin's avatar Bruno Coudoin

braille char: changed the layout a little bit to make more room for the dots.

parent 9ce8cbab
# gcompris - BrailleChar.py
#
# Copyright (C) 2011 xxxx
# Copyright (C) 2011 Bruno Coudoin | Srishti Sethi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -26,10 +26,9 @@ import gcompris.utils
import gcompris.skin
import goocanvas
import pango
import gcompris.sound
import string
from gcompris import gcompris_gettext as _
# For ASCII each letter, this represent the active dots in Braille.
BRAILLE_LETTERS = {
"A": [1], "B": [1, 2], "C": [1, 4], "D": [1, 4, 5], "E": [1, 5],
"F": [1, 2, 4], "G": [1, 2, 4, 5], "H": [1, 2, 5], "I": [2, 4],
......@@ -37,51 +36,52 @@ BRAILLE_LETTERS = {
"N": [1, 3, 4, 5], "O": [1, 3, 5], "P": [1, 2, 3, 4], "Q": [1, 2, 3, 4, 5],
"R": [1, 2, 3, 5], "S": [2, 3, 4], "T": [2, 3, 4, 5], "U": [1, 3, 6],
"V": [1, 2, 3, 6], "W": [2, 4, 5, 6], "X": [1, 3, 4, 6], "Y": [1, 3, 4, 5, 6],
"Z": [1, 3, 5, 6], "+" : [3,4,6], "_": [3,6], "*" : [1,6],"/" : [3,4],
"#" : [3,4,5,6],1: [1],2 :[1, 2], 3 : [1, 4], 4: [1, 4, 5],5 : [1, 5],
6 : [1,2,4],7 : [1,2,4,5],8 : [1,2,5], 9 : [2,4],0 :[3,5,6]
"Z": [1, 3, 5, 6], "+" : [3,4,6], "_": [3,6], "*" : [1,6], "/" : [3,4],
"#" : [3,4,5,6],1: [1],2 :[1, 2], 3 : [1, 4], 4: [1, 4, 5], 5 : [1, 5],
6 : [1, 2, 4], 7 : [1, 2, 4, 5], 8 : [1, 2, 5], 9 : [2, 4], 0 :[3, 5, 6]
}
class BrailleChar:
"""Braille Char"""
def __init__(self, rootitem,
x, y, width, letter,DOT_ON,
DOT_OFF,fill,stroke,display_letter, clickable,
rectangle,callback, braille_letter = "alphabet"):
x, y, width, letter,
dot_on, dot_off,
fill_color, stroke_color,
display_letter, clickable,
rectangle, callback, braille_letter = "alphabet"):
self.letter = letter
self.callback = callback
self.display_letter = display_letter
self.clickable = clickable
self.DOT_ON = DOT_ON
self.DOT_OFF = DOT_OFF
self.fill = fill
self.stroke = stroke
self.dot_on = dot_on
self.dot_off = dot_off
self.fill_color = fill_color
self.stroke_color = stroke_color
self.rectangle = rectangle
self.braille_letter = braille_letter
height = width * 1.33
cell_radius = (width / 7.5)
self.rootitem = goocanvas.Group(parent=rootitem)
self.rootitem = goocanvas.Group(parent = rootitem)
if(letter == '' or rectangle == False):
"""no rect"""
else :
self.item = goocanvas.Rect(parent=self.rootitem,
x=x,
y=y,
width=width,
height=height,
stroke_color = self.stroke,
fill_color = self.fill,
line_width=2.0)
self.text = goocanvas.Text(parent=self.rootitem,
x=x + (width / 2.0),
y=y + height + 15,
text=str(letter),
fill_color=self.stroke,
alignment=pango.ALIGN_CENTER,
self.item = goocanvas.Rect(parent = self.rootitem,
x = x,
y = y,
width = width,
height = height,
stroke_color = self.stroke_color,
fill_color = self.fill_color,
line_width=2.0)
self.text = goocanvas.Text(parent = self.rootitem,
x = x + (width / 2.0),
y = y + height + 15,
text = str(letter),
fill_color = self.stroke_color,
alignment = pango.ALIGN_CENTER,
anchor = gtk.ANCHOR_CENTER,
font = 'Sans BOLD')
if not display_letter:
......@@ -90,16 +90,28 @@ class BrailleChar:
dot = 1
self.dot_items = []
self.cell_array = []
cell_radius = (width / 6.3)
for u in range(2):
for v in range(3):
self.cell = goocanvas.Ellipse(parent=self.rootitem,
center_x=x + width / 3.0 * ( u + 1 ),
center_y=y + height / 4.0 * ( v + 1 ),
radius_x=cell_radius,
radius_y=cell_radius,
stroke_color=self.stroke,
fill_color=self.fill,
line_width=width/25)
xx = x + width / 3.0 * ( u + 1 ) - width / 20
yy = y + height / 4.0 * ( v + 1 ) - height / 20
if u:
xx = x + width / 3.0 * ( u + 1 ) + width / 20
if v == 1:
yy = y + height / 4.0 * ( v + 1 )
if v == 2:
yy = y + height / 4.0 * ( v + 1 ) + height / 20
self.cell = \
goocanvas.Ellipse(parent = self.rootitem,
center_x = xx,
center_y = yy,
radius_x = cell_radius,
radius_y = cell_radius,
stroke_color = self.stroke_color,
fill_color = self.fill_color,
line_width = width/25)
self.cell_array.append(self.cell)
# To fill the circles in lower board with red color
......@@ -115,9 +127,9 @@ class BrailleChar:
if fillings == None:
"""only braille self.cell"""
elif dot in fillings:
self.cell.set_property("fill_color_rgba", self.DOT_ON)
self.cell.set_property("fill_color_rgba", self.dot_on)
else :
self.cell.set_property("fill_color_rgba", self.DOT_OFF)
self.cell.set_property("fill_color_rgba", self.dot_off)
self.dot_items.append(self.cell)
dot += 1
......@@ -132,7 +144,7 @@ class BrailleChar:
# Create the dot list
for l in range(6):
if(self.dot_items[l].get_property("fill_color_rgba") == self.DOT_ON):
if(self.dot_items[l].get_property("fill_color_rgba") == self.dot_on):
cells.append(l+1)
self.letter = ''
......@@ -152,10 +164,10 @@ class BrailleChar:
def dot_event(self, event, target, item):
"""A dot has been clicked, change its state and calculate our new letter value"""
if target.get_property("fill_color_rgba") == self.DOT_ON:
target.set_property("fill_color_rgba", self.DOT_OFF)
if target.get_property("fill_color_rgba") == self.dot_on:
target.set_property("fill_color_rgba", self.dot_off)
else:
target.set_property("fill_color_rgba", self.DOT_ON)
target.set_property("fill_color_rgba", self.dot_on)
self.calculate_char()
#### This function has been added specially for BrailleLotto Activity
......@@ -163,4 +175,4 @@ class BrailleChar:
def ticket_focus(self, rectangle, number_cross_function, counter):
for index in range(6):
gcompris.utils.item_focus_init(self.cell_array[index], rectangle)
self.cell_array[index].connect("button_press_event", number_cross_function, counter)
\ No newline at end of file
self.cell_array[index].connect("button_press_event", number_cross_function, counter)
# gcompris - BrailleMap.py
#
# Copyright (C) 2011 xxxx
# Copyright (C) 2011 Bruno Coudoin | Srishti Sethi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -29,14 +29,14 @@ import pango
from BrailleChar import *
from gcompris import gcompris_gettext as _
SYMBOL = ['+','_','*','/']
SYMBOL = ['+', '_', '*', '/', '#']
CELL_WIDTH = 30
class BrailleMap:
"""Braille Map"""
def __init__(self, rootitem, color_on, color_off, circle_fill, circle_stroke):
#Place alphabets & numbers in array format
# Place alphabets & numbers in array format
for index, letter in enumerate(string.ascii_uppercase[:10]):
BrailleChar(rootitem, index*(CELL_WIDTH+40)+60,
40, 38, letter ,color_on, color_off, circle_fill,
......@@ -60,11 +60,8 @@ class BrailleMap:
circle_stroke, True ,False ,True , None)
# The math operators +-*/
for index in range(4):
BrailleChar(rootitem,index * (CELL_WIDTH + 40) + 60,
400 , 38,SYMBOL[index], color_on, color_off, circle_fill,
circle_stroke,True ,False ,True , None)
for index, value in enumerate( SYMBOL ):
BrailleChar(rootitem,index * (CELL_WIDTH + 40) + 60,
400 , 38,SYMBOL[index], color_on, color_off, circle_fill,
circle_stroke,True ,False ,True , None)
BrailleChar(rootitem, 5 *(CELL_WIDTH + 40) + 60, 400, 38,
"#", color_on, color_off, circle_fill,
circle_stroke, True ,False ,True , None)
......@@ -127,12 +127,10 @@ class Gcompris_braille_alphabets:
self.start()
def config(self):
print("learnbraille config.")
pass
def key_press(self, keyval, commit_str, preedit_str):
utf8char = gtk.gdk.keyval_to_unicode(keyval)
strn = u'%c' % utf8char
print("Gcompris_learnbraille key press keyval=%i %s" % (keyval, strn))
pass
def pause(self,pause):
if(pause == 0):
......@@ -294,7 +292,7 @@ class Gcompris_braille_alphabets:
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
"braille_alphabets/mosaic.svgz")
#Translators : Do not translate the token {letter}
# Translators : Do not translate the token {letter}
goocanvas.Text(parent = self.rootitem,
x = 100,
y = 200,
......@@ -307,8 +305,10 @@ class Gcompris_braille_alphabets:
text=_("Braille Cell"),
fill_color="black",
font='Sans BOLD')
BrailleChar(self.rootitem, 150, 270, 120, '',COLOR_ON ,COLOR_OFF,CIRCLE_FILL,CIRCLE_STROKE,
False,True,False,callback = self.letter_change , braille_letter = self.letter)
BrailleChar(self.rootitem, 150, 270, 120, '',
COLOR_ON ,COLOR_OFF, CIRCLE_FILL, CIRCLE_STROKE,
False, True, False, callback = self.letter_change,
braille_letter = self.letter)
for i in range(2):
for j in range(3):
goocanvas.Text(parent=self.rootitem,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment