Skip to content

Commit

Permalink
Updated navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubBlaha committed Aug 2, 2018
1 parent d5dc3b5 commit 0162357
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 31 deletions.
69 changes: 41 additions & 28 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from easygui import diropenbox, fileopenbox
from _thread import start_new
import easygui
import yaml
import os
import win32api
import shutil
import ctypes
from random import randint
from _thread import start_new

import kivy
kivy.require('1.10.1')
Expand All @@ -23,26 +23,28 @@
from kivy.core.window import Window
from kivy.animation import Animation
from kivy.clock import Clock, mainthread
from kivy.storage.jsonstore import JsonStore
from kivy.network.urlrequest import UrlRequest
from kivy.adapters.listadapter import ListAdapter
from kivy.storage.jsonstore import JsonStore

from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.image import CoreImage
from custpagelayout import PageLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.scrollview import ScrollView
from kivy.graphics import Rectangle, Color
from kivy.uix.floatlayout import FloatLayout
from custpagelayout import PageLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.listview import ListItemButton
from kivy.uix.scrollview import ScrollView
from kivy.uix.popup import Popup
from kivy.properties import StringProperty, ObjectProperty, DictProperty, ListProperty, NumericProperty, BooleanProperty

from theme import *
from dll_updater import DllUpdater
from hovering_behavior import HoveringBehavior
from windowdragbehavior import WindowDragBehavior
from get_image_url import get_image_url_from_response, TEMPLATE, HEADERS
from theme import *

Window.clearcolor = sec

Expand All @@ -61,24 +63,22 @@ def wrapper(*args, **kwargs):
return wrapper


from kivy.uix.image import CoreImage
from kivy.graphics import Rectangle, Color

class NoiseTexture(Widget):
TEX_SIZE = 100, 100
noise_color = ListProperty((1, 1, 1, 1))

def __init__(self, **kw):
super().__init__(**kw)
def on_frame(*args):
tex = CoreImage('img/noise_texture.png').texture
tex.wrap = 'repeat'
tex.uvsize = self.width/self.TEX_SIZE[0], self.height/self.TEX_SIZE[1]
with self.canvas.before:
Color(rgba=self.noise_color)
Rectangle(pos=self.pos, size=self.size, texture=tex)

Clock.schedule_once(lambda *args: Clock.schedule_once(on_frame))
super().__init__(**kw)
Clock.schedule_once(lambda *args: Clock.schedule_once(self.on_noise_color))

def on_noise_color(self, *args):
tex = CoreImage('img/noise_texture.png').texture
tex.wrap = 'repeat'
tex.uvsize = self.width/self.TEX_SIZE[0], self.height/self.TEX_SIZE[1]
with self.canvas.before:
Color(rgba=self.noise_color)
Rectangle(pos=self.pos, size=self.size, texture=tex)

class HeaderLabel(Label, WindowDragBehavior, NoiseTexture):
current_icon = StringProperty('\ue78b')
Expand Down Expand Up @@ -507,24 +507,37 @@ class NavigationButton(CustButton):
page_index = NumericProperty()
icon = StringProperty()
highlight_height = NumericProperty()
highlight_width = NumericProperty()
highlight_width_ratio = .8
highlight_color = ListProperty(prim)

def highlight(self):
self.__active = True
Animation(
highlight_height=self.height, color=fg, d=.5,
highlight_height=self.height,
highlight_width=self.width,
highlight_color=sec,
color=fg,
d=.5,
t='out_expo').start(self)

def nohighghlight(self):
self.__active = False
Animation(highlight_height=0, d=.1, t='in_expo').start(self)
Animation(highlight_height=0,
highlight_width=self.width * self.highlight_width_ratio,
highlight_color=prim,
d=.1,
t='in_expo').start(self)

def on_leave(self, *args):
if not self.__active:
super().on_leave(*args)
super().on_leave()
Animation(highlight_height=0, d=.2, t='out_expo').start(self)

def on_enter(self, *args):
if not self.__active:
super().on_enter(*args)
super().on_enter()
Animation(highlight_height=3, d=.2, t='out_expo').start(self)

def on_release(self):
if not self.__active:
Expand Down Expand Up @@ -696,7 +709,7 @@ def set_dll_buttons_state(self, enabled):
@new_thread
def load_directory(self):
self.info('Popup created | Select a directory now')
self.load_dll_view_data(diropenbox())
self.load_dll_view_data(easygui.diropenbox())

@new_thread
def load_dll_view_data(self, path, quickupdate=False):
Expand Down Expand Up @@ -811,14 +824,14 @@ def goto_page(self, index):
self.ids.content.page = index

def game_path_button_callback(self):
path = diropenbox()
path = easygui.diropenbox()
if not path:
path = ''

self.ids.game_add_form_dir.text = path

def game_launch_path_button_callback(self):
path = fileopenbox(
path = easygui.fileopenbox(
filetypes=['*.exe', '*.url'],
default=self.ids.game_add_form_dir.text + '\\*.exe')
if not path:
Expand Down
8 changes: 5 additions & 3 deletions src/xtremeupdater.kv
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ RootLayout:
markup: True
size_hint_x: None
width: 120
highlight_width: self.width * self.highlight_width_ratio
background_color: theme.dark
bold: True
font_size: 17
background_normal: 'img/FFFFFF-0.png'
color_hovering: theme.prim

canvas.before:
Color:
rgba: theme.prim
rgba: root.highlight_color

Rectangle:
pos: self.pos
size: self.width, self.highlight_height
pos: self.x + (self.width - self.highlight_width) / 2, self.y
size: self.highlight_width, self.highlight_height

<IconNavigationButton@IconButton+NavigationButton>:
font_size: 18
Expand Down

0 comments on commit 0162357

Please sign in to comment.