-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#16 Implementacija klase labela u klasu lajsna
- Loading branch information
Showing
7 changed files
with
131 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pygame | ||
from Labela import * | ||
|
||
class Lajsna: | ||
def __init__(self, x, y, width, height): | ||
self.x = x | ||
self.y = y | ||
self.width = width | ||
self.height = height | ||
self.press = 2 | ||
self.prevpress = [-1, -1] | ||
self.labela = Label(x, y) | ||
|
||
def draw(self, screen): | ||
pygame.draw.rect(screen, (0, 102, 255), pygame.Rect(self.x, self.y, self.width, self.height)) | ||
pygame.draw.line(screen, (200, 20, 0), (self.x + self.width*14/15 - self.width/30, self.y + self.height/10), | ||
(self.x + self.width*14/15 - self.width/30 + self.width/15, self.y + self.height*8/10), 3) | ||
pygame.draw.line(screen, (200, 20, 0), (self.x + self.width*14/15 - self.width/30, self.y + self.height/10 + self.height*8/10), | ||
(self.x + self.width*14/15 - self.width/30 + self.width/15, self.y + self.height/10), 3) | ||
self.labela.draw(screen) | ||
|
||
def click(self, x, y): | ||
if x > self.x + self.width*14/15 - self.width/30 and x < self.x + self.width*14/15 - self.width/30 + self.width/15: | ||
self.press = 0 | ||
else: | ||
self.press = 1 | ||
self.prevpress = [x, y] | ||
|
||
def drag(self, x, y, prevx, prevy): | ||
self.x += x | ||
self.y += y | ||
self.prevpress = [prevx, prevy] | ||
self.labela.change_pos(self.x, self.y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from ClassLajsna import * | ||
import pygame | ||
class Prozor: | ||
def __init__(self,x,y,width,height,labeltext): | ||
self.x=x | ||
self.y=y | ||
self.width=width | ||
self.height=height | ||
self.label=labeltext | ||
self.lajsna=Lajsna(self.x,self.y,self.width,30) | ||
def draw(self,screen): | ||
pygame.draw.rect(screen,(153, 153, 102),pygame.Rect(self.x,self.y,self.width,self.height)) | ||
self.lajsna.draw(screen) | ||
def click(self,x,y): | ||
if(x>=self.lajsna.x and x<=self.lajsna.x+self.lajsna.width) and (y>self.lajsna.y and y<self.lajsna.y+self.lajsna.height): | ||
self.lajsna.click(x,y) | ||
def drag(self,x,y,prevx,prevy): | ||
self.x+=x | ||
self.y+=y | ||
self.lajsna.drag(x,y,prevx,prevy) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from ClassProzor import * | ||
from ClassLajsna import * | ||
import pygame | ||
class WindowMenager: | ||
def __init__(self): | ||
self.prozori=[] | ||
def add_prozor(self): | ||
self.prozori.append(Prozor(100,50,1500,750,'a')) | ||
def remove_prozor(self,prozor): | ||
self.prozori.remove(prozor) | ||
def draw(self,screen): | ||
for prozor in self.prozori: | ||
prozor.draw(screen) | ||
def check_click(self,x,y): | ||
for i in range(len(self.prozori)-1,-1,-1): | ||
print(i) | ||
if(x>=self.prozori[i].x and x<=self.prozori[i].x+self.prozori[i].width) and (y>self.prozori[i].y and y<self.prozori[i].y+self.prozori[i].height): | ||
self.prozori[i].click(x,y) | ||
if self.prozori[i].lajsna.press==0: | ||
self.remove_prozor(self.prozori[i]) | ||
break | ||
def mouseup(self): | ||
for prozor in self.prozori: | ||
prozor.lajsna.press=2 | ||
def drag(self,x,y): | ||
for prozor in self.prozori: | ||
if prozor.lajsna.press==1: | ||
prozor.drag(x-prozor.lajsna.prevpress[0],y-prozor.lajsna.prevpress[1],x,y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.