the end-point for setting the knob values has been created
This commit is contained in:
11
knob.py
11
knob.py
@ -2,6 +2,8 @@ import pygame
|
||||
import math
|
||||
from .colors import *
|
||||
|
||||
FADE_COUNT_DOWN = 150
|
||||
|
||||
class Knob:
|
||||
|
||||
def __init__(self, group, name, radius, position, value = 0):
|
||||
@ -12,12 +14,13 @@ class Knob:
|
||||
self.position = position
|
||||
self.value = value
|
||||
self.focused = False
|
||||
self.fade_count_down = 150
|
||||
self.count_down = FADE_COUNT_DOWN
|
||||
self.vanish_label_path = False
|
||||
self.label_path = []
|
||||
|
||||
def set_value(self, value):
|
||||
self.value = value
|
||||
self.count_down = FADE_COUNT_DOWN
|
||||
|
||||
def set_color(self, color):
|
||||
self.color = color
|
||||
@ -29,7 +32,7 @@ class Knob:
|
||||
else:
|
||||
self.focused = False
|
||||
self.color = color_primary
|
||||
self.fade_count_down = 150
|
||||
self.count_down = FADE_COUNT_DOWN
|
||||
if not self.vanish_label_path: self.label_path = []
|
||||
|
||||
def get_position(self):
|
||||
@ -51,9 +54,9 @@ class Knob:
|
||||
pos = pygame.mouse.get_pos()
|
||||
if math.sqrt(math.pow(pos[0]-self.position[0],2) + math.pow(pos[1]-self.position[1],2)) < self.radius:
|
||||
self.group.set_focused(self)
|
||||
if self.focused: self.fade_count_down -= 1
|
||||
if self.focused: self.count_down -= 1
|
||||
|
||||
if self.fade_count_down == 0:
|
||||
if self.count_down == 0:
|
||||
self.vanish_label_path = True
|
||||
self.set_focused(False)
|
||||
pygame.draw.circle(surface, self.color + (self.group.opacity,), self.position, self.radius)
|
||||
|
||||
Reference in New Issue
Block a user