def __init__(self, parent): fsui.Panel.__init__(self, parent, paintable=True) Skin.set_background_color(self) self.color_2 = Skin.get_background_color() if self.color_2 is not None: self.color_1 = self.color_2.copy().darken(0.08) if fsui.System.macosx: self.line_color_1 = self.color_2.copy().mix( fsui.Color(0x00, 0x00, 0x00), 0.25) self.line_color_2 = self.color_2.copy().mix( fsui.Color(0xff, 0xff, 0xff), 0.25) else: self.line_color_1 = self.color_2.copy().mix( fsui.Color(0xff, 0xff, 0xff)) self.line_color_2 = self.line_color_1 else: # self.color_1 = fsui.Color(0x00, 0x00, 0x00, 0x20) # self.color_2 = fsui.Color(0x00, 0x00, 0x00, 0x00) self.color_1 = fsui.Color(0xff, 0xff, 0xff, 0x60) self.color_2 = fsui.Color(0xff, 0xff, 0xff, 0x00) self.line_color_1 = fsui.Color(0xff, 0xff, 0xff, 0xa0) self.line_color_2 = self.line_color_1 self.border_color = fsui.Color(*BORDER_COLOR) self.white_color = fsui.Color(0xff, 0xff, 0xff, 0xff)
def __init__(self, parent): # fsui.VerticalItemView.__init__(self, parent) fsui.ItemChoice.__init__(self, parent) self.parent_uuid = "" self.items = [] # type: list [dict] # self.last_variants = LastVariants() self.icon = fsui.Image("launcher:res/fsuae_config_16.png") self.adf_icon = fsui.Image("launcher:res/adf_game_16.png") self.ipf_icon = fsui.Image("launcher:res/ipf_game_16.png") self.cd_icon = fsui.Image("launcher:res/cd_game_16.png") self.hd_icon = fsui.Image("launcher:res/hd_game_16.png") # self.missing_icon = fsui.Image( # "launcher:res/missing_game_16.png") self.missing_icon = fsui.Image("launcher:res/16x16/delete_grey.png") self.missing_color = fsui.Color(0xA8, 0xA8, 0xA8) self.blank_icon = fsui.Image("launcher:res/16x16/blank.png") self.bullet_icon = fsui.Image("launcher:res/16x16/bullet.png") self.manual_download_icon = fsui.Image( "launcher:res/16x16/arrow_down_yellow.png") self.auto_download_icon = fsui.Image( "launcher:res/16x16/arrow_down_green.png") self.up_icon = fsui.Image("launcher:res/16x16/thumb_up_mod.png") self.down_icon = fsui.Image("launcher:res/16x16/thumb_down_mod.png") self.fav_icon = fsui.Image("launcher:res/rating_fav_16.png") LauncherSettings.add_listener(self) self.on_setting("parent_uuid", LauncherSettings.get("parent_uuid"))
def _get_background_color(cls): value = LauncherSettings.get("ui_background_color") if len(value) == 7 and value[0] == "#": def convert(s): return int(s, 16) r = convert(value[1:3]) g = convert(value[3:5]) b = convert(value[5:7]) return fsui.Color(r, g, b) if fsbc.system.windows: return fsui.Color(LEVEL, LEVEL, LEVEL) elif fsbc.system.macosx: return fsui.Color(237, 237, 237) return None
def __init__(self, parent): # fsui.VerticalItemView.__init__(self, parent, border=(not Skin.fws())) fsui.VerticalItemView.__init__(self, parent, border=False) self.items = [] self.game_icon = fsui.Image("launcher:res/16/controller.png") self.config_icon = fsui.Image("launcher:res/fsuae_config_16.png") self.manual_download_icon = fsui.Image( "launcher:res/16/arrow_down_yellow.png") self.auto_download_icon = fsui.Image( "launcher:res/16/arrow_down_green.png") self.blank_icon = fsui.Image("launcher:res/16/blank.png") self.missing_color = fsui.Color(0xa8, 0xa8, 0xa8) self.platform_icons = {} from workspace.ui.theme import Theme theme = Theme.instance() self.set_row_height(28) # self.list_view.set_background_color(fsui.Color(0xeb, 0xeb, 0xeb)) self.setStyleSheet(""" QListView {{ background-color: {0}; outline: none; }} QListView::item {{ padding-left: 6px; border: 0px; }} QListView::item:selected {{ background-color: {1}; }} """.format(theme.sidebar_background.to_hex(), theme.selection_background.to_hex()))
def __init__(self, parent, title="", maximizable=True): if isinstance(parent, Application): parent.add_window(self) # parent = None self.__border = WindowBorder(None, title, self) super().__init__(self.__border) self.set_background_color(fsui.Color(0xF2, 0xF2, 0xF2)) self.layout = fsui.VerticalLayout() self.__title_layout = fsui.HorizontalLayout() self.layout.add(self.__title_layout, fill=True) self.__menu_button = WindowMenuButton(self) self.__title_layout.add(self.__menu_button) self.__title_panel = WindowTitlePanel(self) self.__title_layout.add(self.__title_panel, expand=True) self.__minimize_button = WindowMinimizeButton(self) self.__title_layout.add(self.__minimize_button) self._maximize_button = WindowMaximizeButton(self) self.__title_layout.add(self._maximize_button) if not maximizable: print("hiding") self._maximize_button.hide() self.__close_button = WindowCloseButton(self) self.__title_layout.add(self.__close_button) self.__content_added = False self.__menu = None
def __init__(self, parent=None): # if app.name == "fs-uae-arcade": title = "FS-UAE Arcade" # else: # title = "FS Game Center" border = True if maximized(): border = False super().__init__( parent, title, separator=False, border=border, menu=True, color=(0x00, 0x00, 0x00), ) self.set_background_color(fsui.Color(0x00, 0x00, 0x00)) self.layout = fsui.HorizontalLayout() self.quit_flag = False callbacks = Callbacks() callbacks.set_window(self) interval = 16 self.qt_window = QtWindow(callbacks, interval, window=self) self.adapter = fsui.Adapter(self, self.qt_window) self.adapter.set_min_size((960, 540)) self.layout.add(self.adapter, expand=True, fill=True) # self.set_size((960, 540)) # qt_window.setFocus() self.adapter.focus() self.shown.connect(self.on_show) self.closed.connect(self.on_close)
def __init__(self, parent): fsui.VerticalItemView.__init__(self, parent) self.items = [] self.game_icon = fsui.Image("launcher:res/16x16/controller.png") self.config_icon = fsui.Image("launcher:res/fsuae_config_16.png") LauncherSettings.add_listener(self) self.update_search() self.manual_download_icon = fsui.Image( "launcher:res/16x16/arrow_down_yellow.png") self.auto_download_icon = fsui.Image( "launcher:res/16x16/arrow_down_green.png") self.blank_icon = fsui.Image("launcher:res/16x16/blank.png") self.missing_color = fsui.Color(0xA8, 0xA8, 0xA8) self.unpublished_color = fsui.Color(0xCC, 0x00, 0x00) self.platform_icons = {}
def __init__( self, parent, title="", menu=False, minimizable=True, maximizable=True, separator=True, closable=True, background=None, ): super().__init__(parent) if background is None: background = (0xFF, 0xFF, 0xFF) background_color = fsui.Color(background) if background_color.to_hsl().l >= 0.6: self.foreground_color = (0x00, 0x00, 0x00) else: self.foreground_color = (0xFF, 0xFF, 0xFF) self.background_color = background_color self.set_background_color(background_color) self.set_normal_cursor() self.layout = fsui.VerticalLayout() hor_layout = fsui.HorizontalLayout() self.layout.add(hor_layout, fill=True) self.menu_button = WindowMenuButton(self) hor_layout.add(self.menu_button) if not menu: self.menu_button.hide() hor_layout.add_spacer(20 - TEXT_SPACING) self.title_panel = WindowTitlePanel(self) hor_layout.add(self.title_panel, expand=True) self.minimize_button = WindowMinimizeButton(self) hor_layout.add(self.minimize_button) if not minimizable: self.minimize_button.hide() self.maximize_button = WindowMaximizeButton(self) hor_layout.add(self.maximize_button) if not maximizable: self.maximize_button.hide() self.close_button = WindowCloseButton(self) hor_layout.add(self.close_button) if not closable: self.close_button.hide() if separator: self.separator = TitleSeparator(self) self.layout.add(self.separator, fill=True)
def on_paint(self): dc = self.create_dc() dc.set_font(self.get_font()) # SetFont(self.GetFont()) if self.text: text = self.text dc.set_text_color(fsui.Color(0x00, 0x80, 0x00)) elif self.event_name: text = self.event_name dc.set_text_color(fsui.Color(0x80, 0x80, 0x80)) else: text = "click to configure" dc.set_text_color(fsui.Color(0xff, 0x00, 0x00)) tw, th = dc.measure_text(text) y = (self.get_size()[1] - th) / 2 if self.direction > 0: x = 4 else: x = self.get_size()[0] - 4 - tw dc.draw_text(text, x, y)
def __init__(self): from fsui.qt import QPalette palette = QPalette() self.sidebar_list_background = fsui.Color( palette.color(QPalette.Base)) self.sidebar_list_row_height = 28 self.sidebar_list_row_text = fsui.Color( palette.color(QPalette.HighlightedText)) self.sidebar_list_row_background = fsui.Color( palette.color(QPalette.Highlight)) if Skin.fws(): from workspace.ui.theme import WorkspaceTheme as WorkspaceTheme ws_theme = WorkspaceTheme.instance() self.sidebar_list_background = ws_theme.sidebar_background self.sidebar_list_row_text = fsui.Color(0xff, 0xff, 0xff) self.sidebar_list_row_background = ws_theme.selection_background elif Skin.windows_10(): self.sidebar_list_background = fsui.Color(0xe2, 0xe2, 0xe2)
def draw_border(cls, widget, dc): size = widget.size() line_color_1 = Skin.get_background_color() if Skin.fws(): from workspace.ui.theme import Theme theme = Theme.instance() line_color_1 = theme.title_separator_color line_color_2 = line_color_1 elif line_color_1 is not None: line_color_1 = line_color_1.mix(fsui.Color(0xff, 0xff, 0xff)) line_color_2 = line_color_1 else: line_color_1 = fsui.Color(0xff, 0xff, 0xff, 0xa0) line_color_2 = line_color_1 # line_color_1 = fsui.Color(0xff, 0x00, 0x00, 0xff) # line_color_2 = fsui.Color(0x00, 0xff, 0x00, 0xff) dc.draw_line(0, size[1] - 2, size[0], size[1] - 2, line_color_1) dc.draw_line(0, size[1] - 1, size[0], size[1] - 1, line_color_2)
def _get_background_color(cls): # FIXME: Rename to launcher_bg/background_color and document. value = LauncherSettings.get("ui_background_color") if len(value) == 7 and value[0] == "#": def convert(s): return int(s, 16) r = convert(value[1:3]) g = convert(value[3:5]) b = convert(value[5:7]) return fsui.Color(r, g, b) if cls.windows_10(): return None elif cls.fws(): return None elif fsbc.system.windows: # FIXME: Should really just check for Windows XP here, or maybe # just remove it altogether. return fsui.Color(LEVEL, LEVEL, LEVEL) elif fsbc.system.macosx: return fsui.Color(237, 237, 237) return None
def __init__(self, parent, icon, title): super().__init__(parent) self.layout = fsui.HorizontalLayout() # FIXME: From Theme self.set_background_color(fsui.Color(0xFF, 0xFF, 0xFF)) self.title_label = fsui.HeadingLabel(self, title) font = fsui.Font("Roboto", 26) self.title_label.set_font(font) self.layout.add(self.title_label, expand=True, fill=True, margin=20) self.layout.add_spacer(20) self.layout.add(fsui.ImageView(self, icon.image(48)), margin_right=20)
def draw_selected_tab(cls, widget, dc): line_color_1 = Skin.get_background_color() if Skin.fws(): from workspace.ui.theme import Theme theme = Theme.instance() line_color_1 = theme.title_separator_color line_color_2 = line_color_1 elif fsbc.system.macosx and False: line_color_1 = fsui.Color(0xa7, 0xa7, 0xa7) line_color_2 = Skin.get_background_color().mix( fsui.Color(0xff, 0xff, 0xff)) elif line_color_1 is not None: line_color_2 = Skin.get_background_color().mix( fsui.Color(0xff, 0xff, 0xff)) else: line_color_1 = fsui.Color(0xff, 0xff, 0xff, 0x00) line_color_2 = fsui.Color(0xff, 0xff, 0xff, 0xa0) size = widget.size() dc.draw_vertical_gradient(0, 0, 2, size[1], line_color_1, line_color_2) dc.draw_vertical_gradient(size[0] - 2, 0, 2, size[1], line_color_1, line_color_2)
def add_divider(parent, layout, top_margin=12, bottom_margin=12): # return import fsui panel = fsui.Panel(parent) panel.set_background_color(fsui.Color(0xA2A2A2)) panel.set_min_height(1) layout.add( panel, fill=True, margin_top=top_margin, margin_bottom=bottom_margin, )
def __init__(self, parent, position, direction, name): fsui.Panel.__init__(self, parent) size = (120, 22) self.set_size(size) if direction < 0: position = (position[0] - size[0], position[1]) self.set_position(position) self.key_name = name self.event_name = None self.text = "" self.direction = direction self.set_hand_cursor() self.set_background_color(fsui.Color(0xff, 0xff, 0xff))
def __init__( self, parent, *, title="", size=None, menu=False, maximizable=True, minimizable=True, escape=False ): self.theme = get_launcher_theme(self) window_parent = None # window_parent = parent border = self.theme.titlebar_system() super().__init__( window_parent, title, border=border, maximizable=maximizable, minimizable=minimizable, escape=escape, ) if size is not None: self.set_size(size) self.layout = fsui.VerticalLayout() use_border = False if use_border: self.layout.set_padding(1, 1, 1, 1) self.borderwidget = fsui.Panel(self) self.borderwidget.set_background_color(fsui.Color(0xCCD6E4)) else: self.borderwidget = None self.set_background_color(self.theme.window_bgcolor()) if not self.theme.titlebar_system(): self.__titlebar = TitleBar( self, title=title, menu=menu, minimizable=minimizable, maximizable=maximizable, ) self.layout.add(self.__titlebar, fill=True)
def __init__(self): self.title_font = fsui.Font("Noto Sans", 15) # self.title_color = fsui.Color(0x80, 0x80, 0x80) self.title_color = fsui.Color(0x44, 0x44, 0x44) self.title_background = fsui.Color(0xFF, 0xFF, 0xFF) # self.title_separator_color = fsui.Color(0xe5, 0xe5, 0xe5) self.title_separator_color = fsui.Color(0xCC, 0xCC, 0xCC) self.window_background = fsui.Color(0xF2, 0xF2, 0xF2) # self.sidebar_background = fsui.Color(0xeb, 0xeb, 0xeb) self.sidebar_background = fsui.Color(0xE2, 0xE2, 0xE2) self.selection_background = fsui.Color(0x40, 0x80, 0xFF) self.title_glow_color = None
def __init__(self, parent): super().__init__(parent) # self.set_background_color(fsui.Color(0xff, 0xff, 0xff)) self.set_min_width(40) self.set_min_height(34) self.border_colors = [ fsui.Color(0xbc, 0xbc, 0xbc), fsui.Color(0xad, 0xad, 0xad), fsui.Color(0x8c, 0x8c, 0x8c) ] self.fill_colors = [ fsui.Color(0xff, 0xff, 0xff), fsui.Color(0xe6, 0xe6, 0xe6), fsui.Color(0xd4, 0xd4, 0xd4) ]
def __init__(self, parent): super().__init__(parent) # self.set_background_color(fsui.Color(0xff, 0xff, 0xff)) self.set_min_width(40) self.set_min_height(34) self.border_colors = [ fsui.Color(0xBC, 0xBC, 0xBC), fsui.Color(0xAD, 0xAD, 0xAD), fsui.Color(0x8C, 0x8C, 0x8C), ] self.fill_colors = [ fsui.Color(0xFF, 0xFF, 0xFF), fsui.Color(0xE6, 0xE6, 0xE6), fsui.Color(0xD4, 0xD4, 0xD4), ]
def __init__(self, parent): super().__init__(parent, paintable=True) self.set_min_height(40) self.set_background_color(fsui.Color(0xFF, 0xFF, 0xFF)) self.menu_button = fsui.Button(self, "=") self.minimize_button = fsui.Button(self, "_") self.minimize_button.activated.connect(self.on_minimize_button) self.maximize_button = fsui.Button(self, "^") self.maximize_button.activated.connect(self.on_maximize_button) self.close_button = fsui.Button(self, "X") self.close_button.activated.connect(self.on_close_button) self.layout = fsui.HorizontalLayout() self.layout.add(self.menu_button, fill=True) self.layout.add_spacer(0, expand=True) self.layout.add(self.minimize_button, fill=True) self.layout.add(self.maximize_button, fill=True) self.layout.add(self.close_button, fill=True) self.window_pos = (-1, -1) self.mouse_pos = (-1, -1)
def draw_background(cls, widget, dc, selected=False, hover=False, button_style=True): unused(button_style) if selected: cls.draw_selected_tab(widget, dc) else: cls.draw_border(widget, dc) size = widget.size() x = 0 y = 0 w = size[0] h = size[1] - 2 if Skin.fws(): from workspace.ui.theme import Theme theme = Theme.instance() white = fsui.Color(0xff, 0xff, 0xff) if selected: bg_color = theme.window_background bd_color = theme.title_separator_color elif hover: bg_color = theme.window_background.copy().mix( theme.title_background) bd_color = theme.title_separator_color.copy().mix( theme.title_background) else: bg_color = theme.title_background bd_color = theme.title_background # dc.draw_rectangle(0, 0, w, h, bd_color) if selected or hover: dc.draw_vertical_gradient(0, 0, 2, size[1], white, bd_color) dc.draw_vertical_gradient(size[0] - 2, 0, 2, size[1], theme.title_background, bd_color) # dc.draw_rectangle(2, 2, w - 4, h - 2, bg_color) dc.draw_vertical_gradient(2, 0, size[0] - 4, size[1], theme.title_background, bg_color) if hover and not selected: dc.draw_rectangle(0, size[1] - 2, size[0], 2, theme.title_separator_color) else: dc.draw_rectangle(0, 0, w, h, bd_color) return if fsbc.system.macosx: # dc.draw_line(0, 0, w, 0, fsui.Color(198, 198, 198)) # dc.draw_line(0, 0, w, 0, fsui.Color(188, 188, 188)) dc.draw_line(0, 0, w, 0, fsui.Color(248, 248, 248)) y += 1 h -= 1 if selected: x += 2 w -= 4 h += 2 # if button_style and hover: # x += 6 # y += 6 # w -= 12 # h -= 12 color_1 = Skin.get_background_color() if fsbc.system.macosx and False: if selected: color_2 = color_1 color_1 = fsui.Color(0xa7, 0xa7, 0xa7) elif hover: color_1 = fsui.Color(0xa7, 0xa7, 0xa7) color_2 = fsui.Color(0xef, 0xef, 0xef) else: color_1 = fsui.Color(0xa7, 0xa7, 0xa7) color_2 = fsui.Color(0xc0, 0xc0, 0xc0) elif color_1 is not None: if selected: color_2 = color_1 elif hover: color_2 = color_1.copy().lighten() else: color_2 = color_1.copy().darken(0.08) else: if selected: return # color_1 = fsui.Color(0x00, 0x00, 0x00, 0x00) # color_2 = color_1 elif hover: color_1 = fsui.Color(0xff, 0xff, 0xff, 0x00) color_2 = fsui.Color(0xff, 0xff, 0xff, 0x40) else: color_1 = fsui.Color(0x00, 0x00, 0x00, 0x00) color_2 = fsui.Color(0x00, 0x00, 0x00, 0x20) dc.draw_vertical_gradient(x, y, w, h, color_1, color_2) if fsbc.system.macosx and False and not selected and not hover: dc.draw_line(x, y + h - 1, x + w, y + h - 1, fsui.Color(0xa8, 0xa8, 0xa8))
def on_paint(self): dc = self.create_dc() self.draw_background(dc) if self.cover_on_right: x = self.get_size()[0] - 10 - Constants.COVER_SIZE[0] text_x = 10 else: x = 10 text_x = 10 + Constants.COVER_SIZE[0] + 20 y = 2 + 20 size = self.size() image = self.image # dc.draw_image(image, x, y) if image.size[0] == image.size[1]: # cover_overlay = self.cover_overlay_square y_offset = 14 # title_x = 10 else: y_offset = 0 cover_overlay = self.cover_overlay if image.size[0] == image.size[1]: dc.draw_rectangle(x + 1, y + 1, Constants.COVER_SIZE[0], Constants.COVER_SIZE[1], fsui.Color(0x0, 0x0, 0x0)) dc.draw_image(image, x + 1, y + 1 + y_offset) dc.draw_image(cover_overlay, x - 10, y - 10) font = dc.get_font() font.set_bold(True) dc.set_font(font) dc.draw_text(self.title, text_x, y) # tw, th = \ dc.measure_text(self.title) # y += int(th * 1.2) y += 24 color = dc.get_text_color() color.mix(self.get_background_color(), 0.33) dc.set_text_color(color) if self.year: twy, thy = dc.measure_text(self.year) dc.draw_text(self.year, text_x, y) twy += 10 else: twy = 0 font.set_bold(False) dc.set_font(font) if self.companies: dc.draw_text(self.companies, text_x + twy, y) background = fsui.Color(0x00, 0x00, 0x00, 0x20) y = 80 h = 30 tw, th = dc.measure_text(self.sub_title) if self.cover_on_right: dc.draw_rectangle(text_x, y, size[0] - Constants.COVER_SIZE[0] - 20 - 20, h, background) dc.draw_text(self.sub_title, text_x + 6, y + (h - th) // 2) else: dc.draw_rectangle(text_x - 18, y, size[0] - text_x + 18, h, background) dc.draw_text(self.sub_title, text_x, y + (h - th) // 2)