Beispiel #1
0
 def __init__(self, id, x=0, y=0, rot=0, scale = 1, angle = math.pi/12, icon = "", poly_bound = [], layout = "PIE", calc_mode = "ANGLE", close = True):
     
     self.type = "OP"
     self.id = id
     self.x = x
     self.y = y
     self.rot = rot
     self.scale = scale
     self.angle_cw = angle  #1/2 * 2*pi/n => pi/n typically in the symetric case
     self.angle_ccw = angle
     self.icon = icon
     self.tex_coords = (0,0)*4
     if self.icon:
         self.tex_coords = icon_util.icon_name_to_texture_coord(self.icon)
         
     self.icon_quad = []
     self.img = ""
     self.img_poly = []
     self.poly_bound = poly_bound
     self.calc_mode = calc_mode #ANGLE, ICON_QUAD, POLY_LOOP
     self.layout = layout  #PIE, PREDEF
     self.close_menu = close
     
     #this will be update based on x,y, ang and scale only when self.update_local_to_screen
     #use these for drawing, but use self.calc to mouse test.  That way only the mouse coord
     #gets transformed for the test and you only have to recalc everything to draw when
     #position/loc/scale or menu changes.
     self.screen_icon_quad = []
     self.screen_poly_bound = []
     self.screen_img_poly = []
     self.screen_pie = []
Beispiel #2
0
    def update_local_to_screen(self):
        '''
        translate, rotates and scales the appropriate components of the slider
        '''
        self.pull_from_prop()
        if self.on:
            self.id = "On"
            self.icon = "RADIOBUT_ON"
        else:
            self.id = "Off"
            self.icon = "RADIOBUT_OFF"

        self.tex_coords = icon_util.icon_name_to_texture_coord(self.icon)

        j = len(self.icon_quad)
        if j > 0:
            self.screen_icon_quad = [[0, 1]] * j
            center = Vector((0, 0))
            for i in range(0, j):
                center += Vector((self.icon_quad[i][0], self.icon_quad[i][1]))
            center *= 1 / j

            for i in range(0, j):
                vec = Vector(
                    (self.icon_quad[i][0], self.icon_quad[i][1]
                     )) - center  #move the object to the MenuItem origin
                vec = self.scale * vec  #scale it
                vec += self.scale * Matrix.Rotation(
                    self.rot, 2
                ) * center  #move it to a rotated scaled center in MenuItem space
                vec += Vector(
                    (self.x, self.y))  # Place it in Menu/Screen space
                self.screen_icon_quad[i] = vec

        j = len(self.poly_bound)
        if j > 0:
            self.screen_poly_bound = [[0, 1]] * j
            for i in range(0, j):
                vec = Vector((self.poly_bound[i][0], self.poly_bound[i][1]))
                vec = self.scale * vec
                vec = Matrix.Rotation(self.rot, 2) * vec
                vec += Vector((self.x, self.y))
                self.screen_poly_bound[i] = vec
Beispiel #3
0
    def __init__(self, id, data, property, x, y, rot=0, scale=1):
        self.type = "RADIO"
        self.id = id
        self.data = data
        self.prop = property
        self.x = x
        self.y = y
        self.rot = rot
        self.scale = scale
        #self.corner_radius = rad
        self.calc_mode = "POLY_LOOP"  #only optoin for radios
        self.layout = "PREDEF"  #only option for radios
        self.close_menu = False  #only option

        self.poly_bound = []
        self.cheap_box = []  #TODO: implement this for faster mouse testing
        self.on = False
        self.icon = "RADIOBUT_OFF"
        self.tex_coords = icon_util.icon_name_to_texture_coord(self.icon)
        self.icon_quad = []
Beispiel #4
0
 def __init__(self, id, data, property, x, y, rot = 0, scale = 1):
     self.type = "RADIO"
     self.id = id
     self.data = data
     self.prop =  property
     self.x = x
     self.y = y
     self.rot = rot
     self.scale = scale
     #self.corner_radius = rad
     self.calc_mode = "POLY_LOOP" #only optoin for radios
     self.layout = "PREDEF" #only option for radios
     self.close_menu = False #only option
     
     self.poly_bound = []
     self.cheap_box = [] #TODO: implement this for faster mouse testing
     self.on = False
     self.icon = "RADIOBUT_OFF"
     self.tex_coords = icon_util.icon_name_to_texture_coord(self.icon)
     self.icon_quad = []
Beispiel #5
0
 def update_local_to_screen(self):
     '''
     translate, rotates and scales the appropriate components of the slider
     '''
     self.pull_from_prop()
     if self.on:
         self.id = "On"
         self.icon = "RADIOBUT_ON"
     else:
         self.id = "Off"
         self.icon = "RADIOBUT_OFF"
         
     self.tex_coords = icon_util.icon_name_to_texture_coord(self.icon)
     
     j = len(self.icon_quad)  
     if j > 0:
         self.screen_icon_quad = [[0,1]]*j
         center = Vector((0,0))
         for i in range(0,j):
             center += Vector((self.icon_quad[i][0],self.icon_quad[i][1])) 
         center *= 1/j
         
         for i in range(0,j):
             vec = Vector((self.icon_quad[i][0],self.icon_quad[i][1]))-center #move the object to the MenuItem origin
             vec = self.scale*vec #scale it
             vec += self.scale*Matrix.Rotation(self.rot,2)*center #move it to a rotated scaled center in MenuItem space
             vec += Vector((self.x,self.y)) # Place it in Menu/Screen space
             self.screen_icon_quad[i] = vec
     
     j = len(self.poly_bound)  
     if j > 0:
         self.screen_poly_bound = [[0,1]]*j
         for i in range(0,j):
             vec = Vector((self.poly_bound[i][0],self.poly_bound[i][1]))
             vec = self.scale*vec
             vec = Matrix.Rotation(self.rot,2)*vec
             vec += Vector((self.x,self.y))
             self.screen_poly_bound[i] = vec