SHARE
TWEET

Untitled

a guest Mar 19th, 2019 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class SubWindow(Widget):
  2. tPosRel = ListProperty()
  3. bColor = ListProperty()
  4. innerColor = ListProperty()
  5. buttonPos = ListProperty()
  6. innerPos = ListProperty()
  7. innerSize = ListProperty()
  8.  
  9. def __init__(self, **kwargs):
  10.     self.innerPos = (self.pos[0] + 5, self.pos[1] + 40)
  11.     self.innerSize = (90, 265)
  12.     self.innerColor = (.2, .2, .2, 1)
  13.     self.bColor = (0, 0, 0, 1)
  14.     brightnessAvg = (self.bColor[0] + self.bColor[1] + self.bColor[2])/3.0
  15.     if brightnessAvg > .5:
  16.         self.innerColor = (kwargs["bColor"][0] - .2, kwargs["bColor"][1] - .2, kwargs["bColor"][2] - .2, 1)
  17.     else:
  18.         self.innerColor = (kwargs["bColor"][0] + .2, kwargs["bColor"][1] + .2, kwargs["bColor"][2] + .2, 1)
  19.     #print(self.innerColor)
  20.     self.buttonPos = (self.size[0] - 30, self.size[1] - 30)
  21.     #print(self.pos)
  22.     super().__init__(**kwargs)
  23.     self.innerPos = (self.pos[0] + 5, self.pos[1] + 5)
  24.     #print(self.pos)
  25.     #print(self.bColor)
  26.     #print(self.size)
  27.     self.buttonPos = (self.pos[0] + self.size[0] - 25, self.pos[1] + self.size[1] - 25)
  28.  
  29. def on_pos(self, *args):
  30.     self.innerPos = (self.pos[0] + 5, self.pos[1] + 5)
  31.     self.buttonPos = (self.pos[0] + self.size[0] - 25, self.pos[1] + self.size[1] - 25)
  32.     if self.ready:
  33.         for x in self.ids["content"].children:
  34.             x.pos = self.ids["content"].pos
  35.     #print(self.innerColor)
  36.  
  37. def on_size(self, *args):
  38.     self.innerSize = (self.size[0] - 10, self.size[1] - 45)
  39.     self.buttonPos = (self.pos[0] + self.size[0] - 25, self.pos[1] + self.size[1] - 25)
  40.  
  41. def on_touch_down(self, touch):
  42.     if not self.collide_point(*touch.pos):
  43.         return super(SubWindow, self).on_touch_down(touch)
  44.  
  45.     # print(self.size)
  46.     # print("Mouse X: " + str(touch.x))
  47.     # print("Mouse Y: " + str(touch.y))
  48.     if touch.x > self.pos[0] and touch.x < self.pos[0] + self.size[0] - 30 and touch.y > self.pos[1] + self.size[
  49.         1] - 5 and touch.y < self.pos[1] + self.size[1] + 5:
  50.         self.side = 'up'
  51.         print("up hit detect...")
  52.         self.yInit = self.pos[1]
  53.         self.hInit = self.size[1]
  54.         # self.tPosRel = touch - self.pos
  55.         touch.grab(self)
  56.         return True
  57.  
  58.     if touch.x > self.pos[0] + self.size[0] - 5 and touch.x < self.pos[0] + self.size[0] + 5 and touch.y > self.pos[
  59.         1] + 5 and touch.y < self.pos[1] + self.size[1] - 21:
  60.         self.side = 'right'
  61.         print("right hit detect...")
  62.         self.xInit = self.pos[0]
  63.         self.wInit = self.size[0]
  64.         touch.grab(self)
  65.         return True
  66.  
  67.     if touch.x > self.pos[0] + 5 and touch.x < self.pos[0] + self.size[0] - 5 and touch.y > self.pos[
  68.         1] - 5 and touch.y < self.pos[1] + 5:
  69.         self.side = 'down'
  70.         print("down hit detect...")
  71.         self.yInit = self.pos[1]
  72.         self.hInit = self.size[1]
  73.         touch.grab(self)
  74.         return True
  75.  
  76.     if touch.x > self.pos[0] - 5 and touch.x < self.pos[0] + 5 and touch.y > self.pos[1] + 5 and touch.y < self.pos[
  77.         1] + self.size[1]:
  78.         self.side = 'left'
  79.         print("left hit detect...")
  80.         #print(self.size)
  81.         self.xInit = self.pos[0]
  82.         self.wInit = self.size[0]
  83.         touch.grab(self)
  84.         return True
  85.  
  86.     if touch.x > self.pos[0] and touch.x < self.pos[0] + self.size[0] - 30 and touch.y > self.pos[1] + self.size[
  87.         1] - 22 and touch.y < self.pos[1] + self.size[1] - 5:
  88.         print("top hit detect...")
  89.         self.side = 'window'
  90.         self.tPosRel = (touch.x - self.pos[0], touch.y - self.pos[1])
  91.         touch.grab(self)
  92.         return True
  93.  
  94.     if touch.x > self.pos[0] - 5 and touch.x < self.pos[0] + 5 and touch.y > self.pos[1] - 5 and touch.y < self.pos[
  95.         1] + 5:
  96.         self.side = 'leftcorner'
  97.         print("left hit detect...")
  98.         #print(self.size)
  99.         self.xInit = self.pos[0]
  100.         self.wInit = self.size[0]
  101.         self.yInit = self.pos[1]
  102.         self.hInit = self.size[1]
  103.         touch.grab(self)
  104.         return True
  105.  
  106.     if touch.x > self.pos[0] + self.size[0] - 5 and touch.x < self.pos[0] + self.size[0] + 5 and touch.y > self.pos[
  107.         1] - 5 and touch.y < self.pos[1] + 5:
  108.         self.side = 'rightcorner'
  109.         print("right hit detect...")
  110.         #print(self.size)
  111.         self.xInit = self.pos[0]
  112.         self.wInit = self.size[0]
  113.         self.yInit = self.pos[1]
  114.         self.hInit = self.size[1]
  115.         touch.grab(self)
  116.         return True
  117.     return super(SubWindow, self).on_touch_down(touch)
  118.      
  119. <SubWindow>:
  120. size_hint: (None, None)
  121. FloatLayout:
  122.     size: root.size
  123.     pos: root.pos
  124.     size_hint: (None, None)
  125.     canvas:
  126.         Color:
  127.             rgba: root.bColor
  128.         Rectangle:
  129.             size: root.size
  130.             pos: root.pos
  131.     Button:
  132.         size: 20, 20
  133.         pos: root.buttonPos
  134.         size_hint: (None, None)
  135.         text: "X"
  136.         on_release: root.close(root)
  137.     FloatLayout:
  138.         pos: root.innerPos
  139.         size: root.innerSize
  140.         size_hint:(None, None)
  141.         id: content
  142.         canvas:
  143.             Color:
  144.                 rgba: root.innerColor
  145.             Rectangle:
  146.                 pos: content.pos
  147.                 size: root.innerSize
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top