Debian Codegraph @

src/optionsbars/transform/optionsbar_rotate.py

raw symbols SCIP
1 # optionsbar_rotate.py
2 #
3 # Copyright 2018-2023 Romain F. T.
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 <http://www.gnu.org/licenses/>.
17
18 from gi.repository import Gtk
19 from .abstract_optionsbar import AbstractOptionsBar
20 from .utilities_units import utilities_add_unit_to_spinbtn
21
22 class OptionsBarRotate(AbstractOptionsBar):
23 __gtype_name__ = 'OptionsBarRotate'
24
25 def __init__(self, rotate_tool):
26 super().__init__()
27 # knowing the tool is needed because the pane doesn't compact the same
28 # way if it's applied to the selection
29 self.rotate_tool = rotate_tool
30
31 self._build_ui('transform/abstract-optionsbar-transform.ui')
32 builder = self._hydrate_transform_tool('transform/optionsbar-rotate.ui')
33
34 self.angle_btn = builder.get_object('angle_btn')
35 utilities_add_unit_to_spinbtn(self.angle_btn, 3, '°')
36
37 self.angle_box = builder.get_object('angle_box')
38 self.rotate_box = builder.get_object('rotate_box')
39 self.flip_box = builder.get_object('flip_box')
40
41 def init_adaptability(self):
42 super().init_adaptability()
43 temp_limit_size = self.centered_box.get_preferred_width()[0] + \
44 self.cancel_btn.get_preferred_width()[0] + \
45 self.help_btn.get_preferred_width()[0] + \
46 self.apply_btn.get_preferred_width()[0]
47 self._set_limit_size(temp_limit_size)
48
49 def update_for_new_tool(self, tool):
50 self.set_compact(self._is_narrow)
51
52 def set_compact(self, state):
53 super().set_compact(state)
54 if self.rotate_tool.apply_to_selection:
55 self.options_btn.set_visible(state)
56 self.angle_box.set_visible(True)
57 self.rotate_box.set_visible(not state)
58 self.flip_box.set_visible(not state)
59 else:
60 self.options_btn.set_visible(False)
61 self.angle_box.set_visible(False)
62 self.rotate_box.set_visible(True)
63 self.flip_box.set_visible(True)
64
65 ############################################################################
66 ################################################################################
67