summaryrefslogtreecommitdiff
path: root/gtk-recordmydesktop/src/rmdSelectThumb.py
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-03-17 03:11:39 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-03-17 03:11:39 +0000
commit4328d301756a616f02ccaeb992533b819bf51984 (patch)
tree5a8626f88f4bd5f87e0a9286dafa59c09ca0059d /gtk-recordmydesktop/src/rmdSelectThumb.py
parent13473ebea685d81ded41d3b20f5aca633793e2c2 (diff)
added frame around capture area.
New file: src/rmdFrame.py git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@295 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'gtk-recordmydesktop/src/rmdSelectThumb.py')
-rwxr-xr-xgtk-recordmydesktop/src/rmdSelectThumb.py57
1 files changed, 41 insertions, 16 deletions
diff --git a/gtk-recordmydesktop/src/rmdSelectThumb.py b/gtk-recordmydesktop/src/rmdSelectThumb.py
index 6130b26..5e305a5 100755
--- a/gtk-recordmydesktop/src/rmdSelectThumb.py
+++ b/gtk-recordmydesktop/src/rmdSelectThumb.py
@@ -33,15 +33,17 @@
import gtk
import gtk.gdk
-#from rmdSelect import *
+from rmdFrame import *
import gobject
import gc
class GtkThumbSelector(gtk.DrawingArea):
- def __init__(self,area_return,hidden,update_interval=2000):
+ def __init__(self,caller,area_return,hidden,update_interval=2000):
self.hidden=hidden
self.area_return=area_return
self.selecting=0
+ self.realFrame=None
+ self.caller=caller
gtk.DrawingArea.__init__(self)
self.set_app_paintable(True)
#self.fullscreen()
@@ -70,11 +72,11 @@ class GtkThumbSelector(gtk.DrawingArea):
self.x2 = self.y2 = -1
self.set_size_request(self.wwidth/self.factor,self.wheight/self.factor)
self.timed_id=gobject.timeout_add(update_interval,self.update_image)
-
+
def __subsample__(self,im1,w,h,im2,stride,x=0,y=0):
for i in xrange(y,h,stride):
for k in xrange(x,w,stride):
- im2.put_pixel(k/stride,i/stride,im1.get_pixel(k,i))
+ im2.put_pixel(k/stride,i/stride,im1.get_pixel(k,i))
def button_release_cb(self, widget, event):
if event.button == 1 and self.x1 >= 0 and widget==self:
self.selecting=0
@@ -90,7 +92,7 @@ class GtkThumbSelector(gtk.DrawingArea):
if self.y1 >self.wheight/self.factor: self.y1=self.wheight/self.factor
if self.y2 >self.wheight/self.factor: self.y2=self.wheight/self.factor
-
+
self.area_return[0]=min(int(self.x1),int(self.x2))*self.factor
self.area_return[1]=min(int(self.y1),int(self.y2))*self.factor
self.area_return[2]=max(int(self.x1),int(self.x2))*self.factor
@@ -98,7 +100,7 @@ class GtkThumbSelector(gtk.DrawingArea):
self.x1=self.y1=self.x2=self.y2=-1
#print self.area_return
self.update_image()
-
+
def button_press_cb(self, widget, event):
if widget==self:
if event.button == 1:
@@ -116,18 +118,18 @@ class GtkThumbSelector(gtk.DrawingArea):
def realize_cb(self, widget):
if widget == self:
gdkwindow = self.window
- gdkwindow.set_events(gdkwindow.get_events() |
- gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK |
+ gdkwindow.set_events(gdkwindow.get_events() |
+ gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK |
gtk.gdk.POINTER_MOTION_MASK);
cursor = gtk.gdk.Cursor(gtk.gdk.CROSSHAIR)
gdkwindow.set_cursor(cursor)
gdkwindow.set_back_pixmap(None, False)
-
+
def expose_cb(self, widget, event):
if widget==self:
dashes = [ 1.0, 2.0 ]
cr = self.window.cairo_create()
- cr.rectangle(event.area.x, event.area.y, event.area.width,
+ cr.rectangle(event.area.x, event.area.y, event.area.width,
event.area.height)
cr.clip()
self.window.draw_image(self.style.black_gc, self.root, event.area.x,
@@ -137,11 +139,11 @@ class GtkThumbSelector(gtk.DrawingArea):
cr.set_source_rgba (1.0, 0.0, 0.0, 1.0)
cr.set_dash (dashes, 0.0)
cr.move_to (self.x1 - 0.5, 0.0)
- cr.line_to (self.x1 - 0.5, event.area.y + event.area.height)
+ cr.line_to (self.x1 - 0.5, event.area.y + event.area.height)
cr.move_to (0.0, self.y1 - 0.5)
cr.line_to (event.area.x + event.area.width, self.y1 - 0.5)
cr.stroke ()
-
+
if self.x1 >= 0:
x = min(self.x1, self.x2)
y = min(self.y1, self.y2)
@@ -153,13 +155,13 @@ class GtkThumbSelector(gtk.DrawingArea):
cr.set_source_rgba (0.0, 0.0, 0.5, 0.5)
cr.rectangle (x + 0.5, y + 0.5, w - 1, h - 1)
cr.stroke()
-
+
return False
def motion_notify_cb(self, widget, event):
if widget ==self:
self.queue_draw()
-
+
if self.x1 >= 0 :
rect = gtk.gdk.Rectangle()
rect.x = min(self.x1, min(self.x2, event.x + 1))
@@ -167,10 +169,10 @@ class GtkThumbSelector(gtk.DrawingArea):
rect.y = min(self.y1, min(self.y2, event.y + 1))
rect.height = max(self.y1, max(self.y2, event.y + 1)) - rect.y
self.queue_draw_area(rect.x, rect.y, rect.width, rect.height)
-
+
self.x2 = event.x + 1
self.y2 = event.y + 1
-
+
return True
def update_image(self):
@@ -192,6 +194,10 @@ class GtkThumbSelector(gtk.DrawingArea):
if vals[0] >0 or vals[1] >0 or vals[2] <self.wwidth or vals[3] <self.wheight:
if self.selecting==0:
self.__draw_lines__(self.root,vals,self.factor)
+ elif self.realFrame!=None:
+ self.realFrame.destroy()
+ self.realFrame=None
+
return True
def __draw_lines__(self,img,vals,factor):
for i in xrange(vals[0]/factor,vals[0]/factor+vals[2]/factor):
@@ -204,6 +210,25 @@ class GtkThumbSelector(gtk.DrawingArea):
img.put_pixel(vals[0]/factor+k,i,0xff0000)
img.put_pixel((vals[0]+vals[2]/2-k)/factor,i,0xff0000)
img.put_pixel((vals[0]+vals[2]-1-k)/factor,i,0xff0000)
+ if self.realFrame!=None:
+ if (self.area_return[0]!=self.realFrame.x or
+ self.area_return[1]!=self.realFrame.y or
+ self.area_return[2]-self.area_return[0]!=self.realFrame.w or
+ self.area_return[3]-self.area_return[1]!=self.realFrame.h or
+ self.caller.values[25]):
+
+ self.realFrame.destroy()
+ self.realFrame=None
+ if self.realFrame==None and self.caller.values[25]==0:
+ self.__draw_frame__()
+
+
+
+ def __draw_frame__(self):
+ self.realFrame=rmdFrame(self.area_return[0],
+ self.area_return[1],
+ self.area_return[2]-self.area_return[0],
+ self.area_return[3]-self.area_return[1])
#area_return=[-1,-1,-1,-1]
© All Rights Reserved