"Fossies" - the Fresh Open Source Software Archive

Member "sk1-2.0rc4/src/sk1/context/transform.py" (25 May 2019, 1881 Bytes) of package /linux/misc/sk1-2.0rc4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "transform.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0rc3_vs_2.0rc4.

    1 # -*- coding: utf-8 -*-
    2 #
    3 #  Copyright (C) 2013 by Igor E. Novikov
    4 #
    5 #  This program is free software: you can redistribute it and/or modify
    6 #  it under the terms of the GNU General Public License as published by
    7 #  the Free Software Foundation, either version 3 of the License, or
    8 #  (at your option) any later version.
    9 #
   10 #  This program is distributed in the hope that it will be useful,
   11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 #  GNU General Public License for more details.
   14 #
   15 #  You should have received a copy of the GNU General Public License
   16 #  along with this program.  If not, see <https://www.gnu.org/licenses/>.
   17 
   18 from wal import LEFT, CENTER
   19 
   20 from sk1 import _
   21 from sk1.resources import icons, get_bmp, pdids
   22 from sk1.pwidgets import AngleSpin, ActionButton
   23 from generic import CtxPlugin, ActionCtxPlugin
   24 
   25 
   26 class RotatePlugin(CtxPlugin):
   27     name = 'RotatePlugin'
   28     angle_spin = None
   29 
   30     def __init__(self, app, parent):
   31         CtxPlugin.__init__(self, app, parent)
   32 
   33     def build(self):
   34         bmp = get_bmp(self, icons.CTX_ROTATE, _('Rotate selection'))
   35         self.add(bmp, 0, LEFT | CENTER, 2)
   36 
   37         self.angle_spin = AngleSpin(self, onenter=self.apply_changes)
   38         self.add(self.angle_spin, 0, LEFT | CENTER, 2)
   39 
   40         self.add((2, 2))
   41 
   42         rot_left = ActionButton(self, self.actions[pdids.ID_ROTATE_LEFT])
   43         self.add(rot_left, 0, LEFT | CENTER)
   44 
   45         rot_right = ActionButton(self, self.actions[pdids.ID_ROTATE_RIGHT])
   46         self.add(rot_right, 0, LEFT | CENTER)
   47 
   48     def apply_changes(self, *args):
   49         val = self.angle_spin.get_angle_value()
   50         if val != 0.0:
   51             self.app.current_doc.api.rotate_selected(val)
   52 
   53 
   54 class MirrorPlugin(ActionCtxPlugin):
   55     name = 'MirrorPlugin'
   56     ids = [pdids.ID_MIRROR_H, pdids.ID_MIRROR_V]