]> git.plutz.net Git - viper/blob - plugins/f_scale.py
implemeted most basic cropping controls
[viper] / plugins / f_scale.py
1 #encoding: utf-8
2 #Copyright 2010 Thomas Kretzer, Paul Hänsch
3
4 #This file is part of Viper. 
5
6 #Viper is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
10
11 #Viper is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #GNU General Public License for more details.
15
16 #You should have received a copy of the GNU General Public License
17 #along with Viper.  If not, see <http://www.gnu.org/licenses/>
18
19 from plugin import *
20
21 class F_Scale(F_Plugin):
22     def build_dialog(self):
23         self.width = 0
24         self.height = 0
25         self.lock = BooleanVar(value = True)
26         self.subgets['desc'] = Label(self, text = 'Adjust image size by scaling\nthe image')
27         self.subgets['desc'].pack(side = TOP, anchor = N, expand = True, fill = BOTH)
28         self.subgets['f_spin'] = Frame(self)
29         self.subgets['f_spin'].pack(side = TOP, anchor = N, expand = True, fill = BOTH)
30         self.subgets['l_width'] = Label(self.subgets['f_spin'], text = 'Width:')
31         self.subgets['l_width'].pack(side = LEFT, anchor = N)
32         self.subgets['s_width'] = Spinbox(self.subgets['f_spin'], from_ = 0, to = 8192, wrap = False, width = 5)
33         self.subgets['s_width'].delete(0, END)
34         self.subgets['s_width'].insert(0, 320)
35         self.subgets['s_width'].pack(side = LEFT, anchor = N, fill = X)
36         self.subgets['s_height'] = Spinbox(self.subgets['f_spin'], from_ = -2, to = 8192, wrap = False, width = 5, state = DISABLED)
37         self.subgets['s_height'].delete(0, END)
38         self.subgets['s_height'].insert(0, -2)
39         self.subgets['s_height'].pack(side = RIGHT, anchor = N, fill = X)
40         self.subgets['l_height'] = Label(self.subgets['f_spin'], text = 'Height:')
41         self.subgets['l_height'].pack(side = RIGHT, anchor = N)
42         self.subgets['c_lockaspect'] = Checkbutton(self, variable = self.lock, text = 'Lock aspect', command = self.c_lockaspect)
43         self.subgets['c_lockaspect'].pack(side = TOP, anchor = N, expand = True, fill = X)
44
45     def c_lockaspect(self):
46         if self.lock.get():
47             self.subgets['s_height'].configure(from_ = -2)
48             self.subgets['s_height'].delete(0, END)
49             self.subgets['s_height'].insert(0, -2)
50             self.subgets['s_height'].configure(state = DISABLED)
51         else:
52             self.subgets['s_height'].configure(from_ = 0, state = NORMAL)
53             self.subgets['s_height'].delete(0, END)
54             self.subgets['s_height'].insert(0, 240)
55
56     def name(self):
57         return 'Scale'
58
59     def subcommand(self):
60         return ['-vf-add', 'scale=' + str(self.subgets['s_width'].get()) + ':' + str(self.subgets['s_height'].get())]