- Added Background highlight option for voice chat
This commit is contained in:
parent
70feb71b09
commit
b21c05c02e
2 changed files with 50 additions and 20 deletions
|
|
@ -49,6 +49,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
self.icon_only = True
|
||||
self.talk_col = [0.0, 0.6, 0.0, 0.1]
|
||||
self.text_col = [1.0, 1.0, 1.0, 1.0]
|
||||
self.text_hili_col = [1.0, 1.0, 1.0, 1.0]
|
||||
self.norm_col = [0.0, 0.0, 0.0, 0.5]
|
||||
self.wind_col = [0.0, 0.0, 0.0, 0.0]
|
||||
self.mute_col = [0.7, 0.0, 0.0, 1.0]
|
||||
|
|
@ -97,6 +98,13 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
self.hili_col = highlight_colour
|
||||
self.redraw()
|
||||
|
||||
def set_fg_hi(self, highlight_colour):
|
||||
"""
|
||||
Set the colour of background for speaking users
|
||||
"""
|
||||
self.text_hili_col = highlight_colour
|
||||
self.redraw()
|
||||
|
||||
def set_avatar_size(self, size):
|
||||
"""
|
||||
Set the size of the avatar icons
|
||||
|
|
@ -177,24 +185,12 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
"""
|
||||
self.col(self.wind_col)
|
||||
|
||||
def set_text_col(self):
|
||||
"""
|
||||
Use text colour to draw
|
||||
"""
|
||||
self.col(self.text_col)
|
||||
|
||||
def set_norm_col(self):
|
||||
"""
|
||||
Use background colour to draw
|
||||
"""
|
||||
self.col(self.norm_col)
|
||||
|
||||
def set_hili_col(self):
|
||||
"""
|
||||
Use highlight colour to draw
|
||||
"""
|
||||
self.col(self.hili_col)
|
||||
|
||||
def set_talk_col(self, alpha=1.0):
|
||||
"""
|
||||
Use talking colour to draw
|
||||
|
|
@ -348,6 +344,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
mute = False
|
||||
deaf = False
|
||||
bg_col = None
|
||||
fg_col = None
|
||||
|
||||
if "mute" in user and user["mute"]:
|
||||
mute = True
|
||||
|
|
@ -357,8 +354,10 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
colour = self.talk_col
|
||||
if "speaking" in user and user["speaking"] and not deaf and not mute:
|
||||
bg_col = self.hili_col
|
||||
fg_col = self.text_hili_col
|
||||
else:
|
||||
bg_col = self.norm_col
|
||||
fg_col = self.text_col
|
||||
|
||||
pix = None
|
||||
if user["id"] in self.avatars:
|
||||
|
|
@ -369,6 +368,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
context, user["friendlyname"],
|
||||
self.width - self.avatar_size - self.horz_edge_padding,
|
||||
pos_y,
|
||||
fg_col,
|
||||
bg_col
|
||||
)
|
||||
self.draw_avatar_pix(
|
||||
|
|
@ -390,6 +390,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
user["friendlyname"],
|
||||
self.avatar_size + self.horz_edge_padding,
|
||||
pos_y,
|
||||
fg_col,
|
||||
bg_col
|
||||
)
|
||||
self.draw_avatar_pix(
|
||||
|
|
@ -400,7 +401,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
elif mute:
|
||||
self.draw_mute(context, self.horz_edge_padding, pos_y)
|
||||
|
||||
def draw_text(self, context, string, pos_x, pos_y, bg_col):
|
||||
def draw_text(self, context, string, pos_x, pos_y, tx_col, bg_col):
|
||||
"""
|
||||
Draw username & background at given position
|
||||
"""
|
||||
|
|
@ -417,7 +418,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
text_height = logical_rect.height
|
||||
text_width = logical_rect.width
|
||||
|
||||
self.set_text_col()
|
||||
self.col(tx_col)
|
||||
height_offset = (self.avatar_size / 2) - (text_height / 2)
|
||||
text_y_offset=height_offset + self.text_baseline_adj
|
||||
|
||||
|
|
@ -432,7 +433,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
)
|
||||
context.fill()
|
||||
|
||||
self.set_text_col()
|
||||
self.col(tx_col)
|
||||
context.move_to(
|
||||
pos_x - text_width - self.text_pad,
|
||||
pos_y + text_y_offset
|
||||
|
|
@ -449,7 +450,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
)
|
||||
context.fill()
|
||||
|
||||
self.set_text_col()
|
||||
self.col(tx_col)
|
||||
context.move_to(
|
||||
pos_x + self.text_pad,
|
||||
pos_y + text_y_offset
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
self.tk_col = None
|
||||
self.mt_col = None
|
||||
self.hi_col = None
|
||||
self.t_hi_col = None
|
||||
self.avatar_size = None
|
||||
self.icon_spacing = None
|
||||
self.text_padding = None
|
||||
|
|
@ -83,6 +84,8 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
"main", "bg_col", fallback="[0.0,0.0,0.0,0.5]"))
|
||||
self.fg_col = json.loads(config.get(
|
||||
"main", "fg_col", fallback="[1.0,1.0,1.0,1.0]"))
|
||||
self.t_hi_col = json.loads(config.get(
|
||||
"main", "fg_hi_col", fallback="[1.0,1.0,1.0,1.0]"))
|
||||
self.tk_col = json.loads(config.get(
|
||||
"main", "tk_col", fallback="[0.0,0.7,0.0,1.0]"))
|
||||
self.mt_col = json.loads(config.get(
|
||||
|
|
@ -123,6 +126,7 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
self.overlay.set_tk(self.tk_col)
|
||||
self.overlay.set_mt(self.mt_col)
|
||||
self.overlay.set_hi(self.hi_col)
|
||||
self.overlay.set_fg_hi(self.t_hi_col)
|
||||
self.overlay.set_avatar_size(self.avatar_size)
|
||||
self.overlay.set_icon_spacing(self.icon_spacing)
|
||||
self.overlay.set_text_padding(self.text_padding)
|
||||
|
|
@ -160,6 +164,8 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
config.set("main", "tk_col", json.dumps(self.tk_col))
|
||||
config.set("main", "mt_col", json.dumps(self.mt_col))
|
||||
config.set("main", "hi_col", json.dumps(self.hi_col))
|
||||
config.set("main", "fg_hi_col", json.dumps(self.t_hi_col))
|
||||
|
||||
config.set("main", "avatar_size", "%d" % (self.avatar_size))
|
||||
config.set("main", "icon_spacing", "%d" % (self.icon_spacing))
|
||||
config.set("main", "text_padding", "%d" % (self.text_padding))
|
||||
|
|
@ -224,16 +230,25 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
self.hi_col[1],
|
||||
self.hi_col[2],
|
||||
self.hi_col[3]))
|
||||
t_hi_col_label = Gtk.Label.new("Talking Text colour")
|
||||
t_hi_col = Gtk.ColorButton.new_with_rgba(
|
||||
Gdk.RGBA(
|
||||
self.t_hi_col[0],
|
||||
self.t_hi_col[1],
|
||||
self.t_hi_col[2],
|
||||
self.t_hi_col[3]))
|
||||
bg_col.set_use_alpha(True)
|
||||
fg_col.set_use_alpha(True)
|
||||
tk_col.set_use_alpha(True)
|
||||
mt_col.set_use_alpha(True)
|
||||
hi_col.set_use_alpha(True)
|
||||
t_hi_col.set_use_alpha(True)
|
||||
bg_col.connect("color-set", self.change_bg)
|
||||
fg_col.connect("color-set", self.change_fg)
|
||||
tk_col.connect("color-set", self.change_tk)
|
||||
mt_col.connect("color-set", self.change_mt)
|
||||
hi_col.connect("color-set", self.change_hi)
|
||||
t_hi_col.connect("color-set", self.change_t_hi)
|
||||
|
||||
# Avatar size
|
||||
avatar_size_label = Gtk.Label.new("Avatar size")
|
||||
|
|
@ -382,10 +397,12 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
box.attach(hi_col, 1, 3, 1, 1)
|
||||
box.attach(fg_col_label, 0, 4, 1, 1)
|
||||
box.attach(fg_col, 1, 4, 1, 1)
|
||||
box.attach(tk_col_label, 0, 5, 1, 1)
|
||||
box.attach(tk_col, 1, 5, 1, 1)
|
||||
box.attach(mt_col_label, 0, 6, 1, 1)
|
||||
box.attach(mt_col, 1, 6, 1, 1)
|
||||
box.attach(t_hi_col_label, 0, 5, 1, 1)
|
||||
box.attach(t_hi_col, 1, 5, 1, 1)
|
||||
box.attach(tk_col_label, 0, 6, 1, 1)
|
||||
box.attach(tk_col, 1, 6, 1, 1)
|
||||
box.attach(mt_col_label, 0, 7, 1, 1)
|
||||
box.attach(mt_col, 1, 7, 1, 1)
|
||||
box.attach(avatar_size_label, 0, 8, 1, 1)
|
||||
box.attach(avatar_size, 1, 8, 1, 1)
|
||||
box.attach(align_label, 0, 9, 1, 5)
|
||||
|
|
@ -482,6 +499,18 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
self.hi_col = colour
|
||||
self.save_config()
|
||||
|
||||
|
||||
def change_t_hi(self, button):
|
||||
"""
|
||||
Speaking background colour changed
|
||||
"""
|
||||
colour = button.get_rgba()
|
||||
colour = [colour.red, colour.green, colour.blue, colour.alpha]
|
||||
self.overlay.set_fg_hi(colour)
|
||||
|
||||
self.t_hi_col = colour
|
||||
self.save_config()
|
||||
|
||||
def change_avatar_size(self, button):
|
||||
"""
|
||||
Avatar size setting changed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue