From 4328d301756a616f02ccaeb992533b819bf51984 Mon Sep 17 00:00:00 2001 From: iovar Date: Sat, 17 Mar 2007 03:11:39 +0000 Subject: 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 --- gtk-recordmydesktop/src/Makefile.am | 1 + gtk-recordmydesktop/src/rmdConfig.py.in | 1 + gtk-recordmydesktop/src/rmdFrame.py | 102 ++++++++++++++++++++++++++++++ gtk-recordmydesktop/src/rmdPrefsWidget.py | 19 ++++-- gtk-recordmydesktop/src/rmdSelectThumb.py | 57 ++++++++++++----- gtk-recordmydesktop/src/rmdSimple.py | 9 ++- 6 files changed, 168 insertions(+), 21 deletions(-) create mode 100644 gtk-recordmydesktop/src/rmdFrame.py (limited to 'gtk-recordmydesktop/src') diff --git a/gtk-recordmydesktop/src/Makefile.am b/gtk-recordmydesktop/src/Makefile.am index 08f4f2e..0cb4980 100644 --- a/gtk-recordmydesktop/src/Makefile.am +++ b/gtk-recordmydesktop/src/Makefile.am @@ -13,6 +13,7 @@ gtk_recordMyDesktop_PYTHON = \ rmdSimple.py\ rmdConfig.py\ rmdMonitor.py\ + rmdFrame.py\ __init__.py desktopdir = $(datadir)/applications diff --git a/gtk-recordmydesktop/src/rmdConfig.py.in b/gtk-recordmydesktop/src/rmdConfig.py.in index 6b71efa..f3194c5 100644 --- a/gtk-recordmydesktop/src/rmdConfig.py.in +++ b/gtk-recordmydesktop/src/rmdConfig.py.in @@ -32,4 +32,5 @@ default_values=[15, #framerate False, #Use jack [], #jack ports 0, #tooltips,0 on 1 off + 0, #draw an on-screen frame, surrounding the capture area,0 on 1 off ] diff --git a/gtk-recordmydesktop/src/rmdFrame.py b/gtk-recordmydesktop/src/rmdFrame.py new file mode 100644 index 0000000..f5187e4 --- /dev/null +++ b/gtk-recordmydesktop/src/rmdFrame.py @@ -0,0 +1,102 @@ +#/********************************************************************************* +#* gtk-recordMyDesktop * +#********************************************************************************** +#* * +#* Copyright (C) 2006 John Varouhakis * +#* * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU General Public License as published by * +#* the Free Software Foundation; either version 2 of the License, or * +#* (at your option) any later version. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU General Public License for more details. * +#* * +#* You should have received a copy of the GNU General Public License * +#* along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +#* * +#* * +#* * +#* For further information contact me at johnvarouhakis@gmail.com * +#**********************************************************************************/ +import pygtk +pygtk.require('2.0') +import gtk + +class rmdFrame: + borderwidth=6 + outlinewidth=1 + + def __init__(self,x,y,w,h): + self.window=gtk.Window(gtk.WINDOW_TOPLEVEL) + self.area=gtk.DrawingArea() + self.x=x + self.y=y + self.w=w + self.h=h + + mask = gtk.gdk.Pixmap(None, + self.w+self.borderwidth*2, + self.h+self.borderwidth*2, + 1) + gc = mask.new_gc() + gc.foreground = gtk.gdk.Color(0,0,0,1) + mask.draw_rectangle(gc,True,0,0, + self.w+self.borderwidth*2, + self.h+self.borderwidth*2) + gc.foreground = gtk.gdk.Color(0, 0, 0, 0) + mask.draw_rectangle(gc,True, + self.borderwidth, + self.borderwidth, + self.w,self.h) + + self.area.show() + self.window.stick() + self.window.set_keep_above(True) + self.area.connect("expose-event", self.__expose_cb) + self.window.shape_combine_mask(mask,0,0) + self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK) + self.window.set_title("gtk-recordMyDesktop frame") + self.window.stick() + self.window.set_keep_above(True) + self.window.add(self.area) + self.window.show() + + self.window.set_size_request(self.w+self.borderwidth*2, + self.h+self.borderwidth*2) + self.window.move(self.x-self.borderwidth, + self.y-self.borderwidth) + self.window.set_resizable(False) + + + def __expose_cb(self, widget, event): + if widget==self.area: + self.area.window.draw_rectangle(self.window.style.white_gc, + True,0,0,self.w+self.borderwidth*2, + self.h+self.borderwidth*2) + self.area.window.draw_rectangle(self.window.style.black_gc, + True,self.outlinewidth, + self.outlinewidth, + self.w+(self.borderwidth- + self.outlinewidth)*2, + self.h+(self.borderwidth- + self.outlinewidth)*2) + self.area.window.draw_rectangle(self.window.style.white_gc, + True, + self.borderwidth-self.outlinewidth, + self.borderwidth-self.outlinewidth, + self.w+self.outlinewidth*2, + self.h+self.outlinewidth*2) + else: + pass + + def destroy(self): + self.area.destroy() + try: + self.window.destroy() + except: + pass diff --git a/gtk-recordmydesktop/src/rmdPrefsWidget.py b/gtk-recordmydesktop/src/rmdPrefsWidget.py index 2866bbc..a5e6b0c 100644 --- a/gtk-recordmydesktop/src/rmdPrefsWidget.py +++ b/gtk-recordmydesktop/src/rmdPrefsWidget.py @@ -44,6 +44,7 @@ class prefsWidget(object): _('Quick Subsampling'),_('Full shots at every frame'), _('Channels'),_('Frequency'),_('Device'),_('Display'),_('Mouse Cursor'), _('MIT-Shm extension'),_('Include Window Decorations'),_('Tooltips'), + _('Outline Capture Area On Screen'), _('Video Quality'),_('Sound Quality'), _('Drop Frames(encoder)'),_('Startup Delay(secs)'),] mouseStrings=[_('Normal'),_('White'),_('Black'),_('None')] @@ -63,11 +64,12 @@ class prefsWidget(object): _('The mouse cursor that will be drawn.\nNormal is for the real cursor that you see while recording,\nwhile black and white are fake cursors, drawn by the program.\nYou can also disable cursor drawing.'), _('Use the MIT-Shared memory extension, whenever appropriate,\n depending on the rest of the program settings.\nDisabling this option is not recommended,\nas it may severely slow down the program.'), _('When selecting a window via the "Select Window" button,\ninclude that window\'s decorations in the recording area.'), - _('Enable or disable tooltips, like this one.\n(Requires restart)')] + _('Enable or disable tooltips, like this one.\n(Requires restart)'), + _('Draw a frame on the screen, around the area\nthat will get captured.\n(This frame will remain throughout the recording.)')] jacktip=_("Enable this option to record audio through\nJACK. The Jack server must be running in order to\nobtain the ports that will be recorded.\nThe audio recorded from each one\nwill be written on a channel of its own.\nrecordMyDesktop must be compiled with JACK\nsupport for this option to work.") def __tooltips__(self): self.tooltips=gtk.Tooltips() - for i in range(15): + for i in range(16): self.tooltips.set_tip(self.eboxes[i],self.tooltipLabels[i]) self.tooltips.set_tip(self.jack_ebox,self.jacktip) @@ -90,6 +92,7 @@ class prefsWidget(object): self.values[22]=self.jack_button.get_active() self.__getSelectedPorts__() self.values[24]=self.tooltipsComboBox.get_active() + self.values[25]=self.rFrameComboBox.get_active() self.window.destroy() self.optionsOpen[0]=0 @@ -259,7 +262,7 @@ class prefsWidget(object): self.boxes[9].pack_end(self.deviceEntry,expand=False,fill=False) #misc page - for i in xrange(10,15): + for i in xrange(10,16): self.labels[i]=gtk.Label(self.labelStrings[i]) self.labels[i].set_justify(gtk.JUSTIFY_LEFT) self.boxes[i]=gtk.HBox(homogeneous=False, spacing=0) @@ -304,7 +307,15 @@ class prefsWidget(object): self.tooltipsComboBox.show() self.boxes[14].pack_end(self.tooltipsComboBox,expand=False,fill=False) - for i in range(15): + + self.rFrameComboBox = gtk.combo_box_new_text() + for i in range(2): + self.rFrameComboBox.append_text(self.stateStrings[i]) + self.rFrameComboBox.set_active(self.values[25]) + self.rFrameComboBox.show() + self.boxes[15].pack_end(self.rFrameComboBox,expand=False,fill=False) + + for i in range(16): self.boxes[i].show() self.eboxes[i].show() 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] 320 or self.factor<4: twidth/=2 self.factor*=2 - self.image=sT.GtkThumbSelector(self.values[5],self.hidden,2000) + self.image=sT.GtkThumbSelector(self,self.values[5],self.hidden,2000) self.image.show() self.NWBox.pack_start(self.image,False,False) @@ -336,6 +336,11 @@ class simpleWidget(object): self.values.append(rmdConfig.default_values[24]) else: self.values.append(int(savefile.readline())) + p=savefile.readline() + if p=='': + self.values.append(rmdConfig.default_values[25]) + else: + self.values.append(int(savefile.readline())) return True except: return False @@ -396,6 +401,8 @@ class simpleWidget(object): savefile.write("\n") savefile.write("#Tooltips,1 disabled 0 enabled\n") savefile.write("%d\n"%self.values[24]) + savefile.write("#draw an on-screen frame, surrounding the capture area\n") + savefile.write("%d\n"%self.values[25]) savefile.flush() savefile.close() return True -- cgit v1.2.3