def init_global_controls(self): #self.log(' init_global_controls start') loading_img = xbmc.validatePath('/'.join((ADDON_PATH, 'resources', 'skins', 'Default', 'media', 'srr_busy.gif' ))) self.loading_control = ControlImage(576, 296, 128, 128, loading_img) self.preload_control = ControlImage(-1, -1, 1, 1, '') self.background_control = ControlImage(0, 0, 1280, 720, '') self.global_controls = [ self.preload_control, self.background_control, self.loading_control ] self.xbmc_window.addControls(self.global_controls)
def display_results(self, function='true'): if function == 'true': self.img_results = ControlImage(932, 40, 320, 144, '', aspectRatio=0) self.addControl(self.img_results) self.img_results.setVisible(False) self.img_results.setImage(self.image_speedtestresults) self.img_results.setAnimations([( 'conditional', 'effect=fade start=100 end=0 time=300 delay=1000 condition=!Control.IsEnabled(%d)' % self.img_results.getId() )]) self.img_results.setVisible(True) self.ping_textbox = ControlLabel(955, 133, 75, 50, label='', textColor='0xFFFFFFFF') self.addControl(self.ping_textbox) self.dl_textbox = ControlLabel(1035, 133, 75, 50, label='', textColor='0xFFFFFFFF') self.addControl(self.dl_textbox) self.ul_textbox = ControlLabel(1153, 133, 75, 50, label='', textColor='0xFFFFFFFF') self.addControl(self.ul_textbox) elif function == 'visible': self.img_results.setEnabled(True) self.img_results.setVisible(True) else: self.img_results.setEnabled(False) self.dl_textbox.setLabel('') self.ul_textbox.setLabel('') self.ping_textbox.setLabel('')
def display_progress_bar(self, function='true'): if function == 'true': self.img_progress = ControlImage(340, 640, 600, 20, '', aspectRatio=0, colorDiffuse="0xFF00AACC") self.addControl(self.img_progress) self.img_progress.setVisible(False) self.img_progress.setImage(self.image_progress) self.img_progress.setAnimations([( 'conditional', 'effect=fade start=0 end=100 time=500 condition=Control.IsVisible(%d)' % self.img_progress.getId() ), ( 'conditional', 'effect=fade start=100 end=0 time=300 condition=!Control.IsEnabled(%d)' % self.img_progress.getId() )]) self.img_progress.setVisible(True) img_progressx = int((self.screenx / 3) - (200 / 2)) img_progressy = int((self.screeny / 3) - (50 / 2) + 270) self.please_wait_textbox = ControlLabel(img_progressx, img_progressy, 200, 50, label='Please wait...', textColor='0xFFFFFFFF', alignment=2 | 4) self.addControl(self.please_wait_textbox) elif function == 'visible': self.please_wait_textbox.setVisible(True) self.img_progress.setEnabled(True) self.img_progress.setVisible(True) else: self.please_wait_textbox.setVisible(False) self.img_progress.setEnabled(False) self.img_progress.setVisible(False)
def display_button_close(self, function='true'): if function == 'true': self.button_close_glow = ControlImage(880, 418, 300, 122, '', aspectRatio=0) self.addControl(self.button_close_glow) self.button_close_glow.setVisible(False) self.button_close_glow.setImage(self.image_button_run_glow) self.button_close_glow.setAnimations([( 'conditional', 'effect=fade start=0 time=1000 delay=2000 pulse=true condition=Control.IsVisible(%d)' % self.button_close_glow.getId() )]) self.button_close = ControlButton(99999, 99999, 300, 122, localize(30951), focusTexture=self.image_button_run, noFocusTexture=self.image_button_run, alignment=2 | 4, textColor='0xFF000000', focusedColor='0xFF000000', shadowColor='0xFFCCCCCC', disabledColor='0xFF000000') self.addControl(self.button_close) self.button_close.setVisible(False) self.button_close.setPosition(880, 418) self.button_close_id = self.button_close.getId() self.button_close.setAnimations([( 'conditional', 'effect=fade start=0 end=100 delay=1000 time=1000 condition=Control.IsVisible(%d)' % self.button_close.getId() )]) elif function == 'visible': self.button_close.setVisible(True) self.button_close_glow.setVisible(True) self.setFocus(self.button_close) else: self.button_close.setVisible(False) self.button_close_glow.setVisible(False)
def display_button_run(self, function='true'): if function == 'true': button_run_glowx = int((self.screenx / 3) - (300 / 2)) button_run_glowy = int((self.screeny / 3) - (122 / 2) + 50) self.button_run_glow = ControlImage(button_run_glowx, button_run_glowy, 300, 122, '', aspectRatio=0) self.addControl(self.button_run_glow) self.button_run_glow.setVisible(False) self.button_run_glow.setImage(self.image_button_run_glow) self.button_run_glow.setAnimations([ ('conditional', 'effect=fade start=0 time=1000 condition=true pulse=true') ]) self.button_run = ControlButton(button_run_glowx, button_run_glowy, 300, 122, localize(30950), focusTexture=self.image_button_run, noFocusTexture=self.image_button_run, alignment=2 | 4, textColor='0xFF000000', focusedColor='0xFF000000', shadowColor='0xFFCCCCCC', disabledColor='0xFF000000') self.addControl(self.button_run) self.setFocus(self.button_run) self.button_run.setVisible(False) self.button_run.setAnimations([( 'conditional', 'effect=fade start=100 end=0 time=300 condition=!Control.IsEnabled(%d)' % self.button_run.getId() )]) self.button_run_id = self.button_run.getId() self.button_run.setEnabled(True) self.button_run.setVisible(True) self.button_run_glow.setEnabled(True) self.button_run_glow.setVisible(True) else: self.button_run.setEnabled(False) self.button_run.setVisible(False) self.button_run_glow.setEnabled(False) self.button_run_glow.setVisible(False)
def stack_cycle_controls(self): for txt_ctl, img_ctl in self.tni_controls: self.xbmc_window.addControl(img_ctl) if self.SHOW_TITLE: self.txt_background = ControlImage(0, 685, 1280, 40, 'srr_dialog-bg.png', aspectRatio=1) self.xbmc_window.addControl(self.txt_background) #ControlLabel(x, y, width, height, label, font=None, textColor=None, disabledColor=None, alignment=0, hasPath=False, angle=0) self.image_label = ControlLabel(10, 688, 1280, 30, '', font='font16', textColor='', disabledColor='', alignment=6, hasPath=False, angle=0) self.xbmc_window.addControl(self.image_label)
def show_end_result(self): self.img_final_results = ControlImage(932, 40, 320, 144, '', aspectRatio=0) self.addControl(self.img_final_results) self.img_final_results.setVisible(False) self.img_final_results.setEnabled(False) self.img_final_results.setImage(IMAGE_RESULT) self.img_final_results.setAnimations([ ('conditional', 'effect=fade start=0 end=100 time=1000 delay=100 condition=Control.IsVisible(%d)' % self.img_final_results.getId()), ('conditional', 'effect=zoom end=175 start=100 center=%s time=2000 delay=3000 condition=Control.IsVisible(%d)' % ('auto', self.img_final_results.getId())), ('conditional', 'effect=slide end=-100,25 time=2000 delay=3000 tween=linear easing=in condition=Control.IsVisible(%d)' % self.img_final_results.getId()) ]) self.img_final_results.setVisible(True) self.img_final_results.setEnabled(True)
def __init__(self, w=0.5, h=0.15, y_offset=0, label_padding=15, label_h=43): window_width, window_height = get_resolution() self._window = Window(WINDOW_FULLSCREEN_VIDEO) self._shown = False logging.debug("Using window width=%d and height=%d", window_width, window_height) total_label_h = 3 * label_h w = int(w * window_width) h = max(int(h * window_height), total_label_h + 2 * label_padding) x = (window_width - w) // 2 y = int((3 * window_height / 4) - (h / 2) + 0.5) + y_offset label_x = x + label_padding label_w = w - 2 * label_padding label_y = y + int((h - total_label_h) / 2 + 0.5) self._label1 = ControlLabel(label_x, label_y, label_w, label_h, "", alignment=0x2 | 0x4) label_y += label_h self._label2 = ControlLabel(label_x, label_y, label_w, label_h, "", alignment=0x2 | 0x4) label_y += label_h self._label3 = ControlLabel(label_x, label_y, label_w, label_h, "", alignment=0x2 | 0x4) self._background = ControlImage( x, y, 0, 0, os.path.join(ADDON_PATH, "resources", "images", "black.png"), colorDiffuse="0xD0000000") self._controls = [self._background, self._label1, self._label2, self._label3] self._window.addControls(self._controls) # We are only able to update visibility after adding elements, so to make them not visible # we have to create them with 0 width and height and then update the controls after adding # them to the window for c in self._controls: c.setVisible(self._shown) self._background.setWidth(w) self._background.setHeight(h)
def display_gauge_test(self, function='true'): if function == 'true': img_gaugex = int((self.screenx / 3) - (548 / 2)) img_gaugey = int((self.screeny / 3) - (400 / 2)) img_gauge_arrowx = int((self.screenx / 3) - (66 / 2) - 5) img_gauge_arrowy = int((self.screeny / 3) - (260 / 2) - 60) self.img_gauge = ControlImage(img_gaugex, img_gaugey, 548, 400, '', aspectRatio=0) self.img_gauge_arrow = ControlImage(img_gauge_arrowx, img_gauge_arrowy, 66, 260, '', aspectRatio=0) self.addControl(self.img_gauge) self.addControl(self.img_gauge_arrow) self.img_gauge.setVisible(False) self.img_gauge_arrow.setVisible(False) self.img_gauge.setImage(self.image_gauge) self.img_gauge_arrow.setImage(self.image_gauge_arrow) self.img_gauge.setAnimations([( 'conditional', 'effect=fade start=0 end=100 delay=1000 time=1000 condition=Control.IsVisible(%d)' % self.img_gauge.getId() ), ( 'conditional', 'effect=fade start=100 end=0 time=300 condition=!Control.IsEnabled(%d)' % self.img_gauge.getId() )]) self.img_gauge_arrow.setAnimations([( 'conditional', 'effect=fade start=0 end=100 time=1000 condition=Control.IsVisible(%d)' % self.img_gauge_arrow.getId() ), ( 'conditional', 'effect=fade start=100 end=0 time=300 condition=!Control.IsEnabled(%d)' % self.img_gauge_arrow.getId() )]) dlul_prog_textboxx = int((self.screenx / 3) - (200 / 2)) dlul_prog_textboxy = int((self.screeny / 3) - (50 / 2) + 170) self.dlul_prog_textbox = ControlLabel(dlul_prog_textboxx, dlul_prog_textboxy, 200, 50, label='', textColor='0xFFFFFFFF', font='font30', alignment=2 | 4) self.addControl(self.dlul_prog_textbox) elif function == 'visible': self.img_gauge.setEnabled(True) self.img_gauge.setVisible(True) self.img_gauge_arrow.setEnabled(True) self.img_gauge_arrow.setVisible(True) else: self.img_gauge.setEnabled(False) self.img_gauge.setVisible(False) self.img_gauge_arrow.setEnabled(False) self.img_gauge_arrow.setVisible(False) self.dlul_prog_textbox.setLabel('')
def display_ping_test(self, function='true'): if function == 'true': img_centertextx = int((self.screenx / 3) - (320 / 2)) img_centertexty = int((self.screeny / 3) - (130 / 2) + 50) self.img_centertext = ControlImage(img_centertextx, img_centertexty, 320, 130, ' ', aspectRatio=0) self.addControl(self.img_centertext) img_pingx = int((self.screenx / 3) - (600 / 2)) img_pingy = int((self.screeny / 3) - (400 / 2)) self.img_ping = ControlImage(img_pingx, img_pingy, 600, 400, '', aspectRatio=1) self.img_ping_glow = ControlImage(img_pingx, img_pingy, 600, 400, '', aspectRatio=1) self.addControl(self.img_ping) self.addControl(self.img_ping_glow) self.img_ping.setVisible(False) self.img_ping_glow.setVisible(False) self.img_ping.setImage(self.image_ping) self.img_ping_glow.setImage(self.image_ping_glow) self.img_ping.setAnimations([( 'conditional', 'effect=fade start=0 end=100 delay=1000 time=1000 condition=Control.IsVisible(%d)' % self.img_ping.getId() ), ( 'conditional', 'effect=fade start=100 end=0 time=300 condition=!Control.IsEnabled(%d)' % self.img_ping.getId() )]) self.img_ping_glow.setAnimations([( 'conditional', 'effect=fade start=0 time=1000 pulse=true condition=Control.IsEnabled(%d)' % self.img_ping_glow.getId() ), ( 'conditional', 'effect=fade start=0 end=100 delay=1000 time=1000 condition=Control.IsVisible(%d)' % self.img_ping_glow.getId() ), ( 'conditional', 'effect=fade start=100 end=0 time=300 condition=!Control.IsEnabled(%d)' % self.img_ping_glow.getId() )]) self.img_centertext.setAnimations([( 'conditional', 'effect=fade start=70 time=1000 condition=true pulse=true' )]) elif function == 'visible': self.img_ping.setVisible(True) self.img_ping_glow.setVisible(True) else: self.img_ping.setVisible(False) self.img_ping_glow.setVisible(False) self.img_centertext.setVisible(False)
def init_cycle_controls(self): for _ in xrange(self.IMAGE_CONTROL_COUNT): img_control = ControlImage( 0, 0, 0, 0, '', aspectRatio=2 ) #(values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars) txt_control = ControlTextBox(0, 0, 0, 0, font='font16') self.tni_controls.append([txt_control, img_control])
def init_global_controls(self): #self.log(' init_global_controls start') loading_img = xbmcvfs.validatePath('/'.join( (ADDON_PATH, 'resources', 'skins', 'Default', 'media', 'srr_busy.gif'))) xbmc_window_half_width = int(self.xbmc_window.getWidth() / 2) xbmc_window_half_height = int(self.xbmc_window.getHeight() / 2) self.loading_control = ControlImage(xbmc_window_half_width - 64, xbmc_window_half_height - 64, 128, 128, loading_img) self.preload_control = ControlImage(-1, -1, 1, 1, '') self.background_control = ControlImage(0, 0, self.xbmc_window.getWidth(), self.xbmc_window.getHeight(), '') self.global_controls = [ self.preload_control, self.background_control, self.loading_control ] self.xbmc_window.addControls(self.global_controls)
def init_global_controls(self): self.log('init_global_controls start') loading_img = xbmc.validatePath('/'.join( (ADDON_PATH, 'resources', 'media', 'loading.gif'))) logo_img = xbmc.validatePath('/'.join( (ADDON_PATH, 'resources', 'media', 'logo.png'))) self.loading_control = ControlImage(480, 250, 400, 219, loading_img) self.preload_control = ControlImage(-1, -1, 1, 1, '') self.background_control = ControlImage(0, 0, 1280, 720, '') self.logo_control = ControlImage(25, 625, 250, 65, logo_img) self.logo_label = ControlLabel(98, 680, 250, 25, '', textColor='FFFFFFFF') self.global_controls = [ self.preload_control, self.background_control, self.loading_control, self.logo_control, self.logo_label ] self.xbmc_window.addControls(self.global_controls) self.log('init_global_controls end')
def init_cycle_controls(self): #self.log(' init_cycle_controls start') for _ in xrange(self.IMAGE_CONTROL_COUNT): img_control = ControlImage(0, 0, 0, 0, '', aspectRatio=2) #(values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars) txt_control = ControlTextBox(0, 0, 0, 0, font='font16') # xbfont_left = 0x00000000 # xbfont_right = 0x00000001 # xbfont_center_x = 0x00000002 # xbfont_center_y = 0x00000004 # xbfont_truncated = 0x00000008 #ControlLabel(x, y, width, height, label, font=None, textColor=None, disabledColor=None, alignment=0, hasPath=False, angle=0) #txt_control = ControlLabel(0, 0, 0, 0, '', font='font30', textColor='', disabledColor='', alignment=6, hasPath=False, angle=0) #self.image_controls.append(img_control) self.tni_controls.append([txt_control,img_control])
def init_cycle_controls(self): self.log('init_cycle_controls start') for i in xrange(self.IMAGE_CONTROL_COUNT): img_control = ControlImage(0, 0, 0, 0, '', aspectRatio=1) self.image_controls.append(img_control) self.log('init_cycle_controls end')