Commit c7be9784 authored by Jaden Goter's avatar Jaden Goter

Removed guidelines_to_draw property and changed it to new active_guidelines field.

parent 68250f85
Pipeline #174498 failed with stage
in 3 minutes and 2 seconds
......@@ -29,20 +29,16 @@ class CompositionGuidelinesOverlay(Gtk.DrawingArea, Loggable):
Loggable.__init__(self)
self.stack = stack
self.__guidelines_to_draw = set()
@property
def guidelines_to_draw(self):
return self.__guidelines_to_draw
self.active_guidelines = set()
def add_guideline(self, guideline):
if guideline not in self.guidelines_to_draw:
self.__guidelines_to_draw.add(guideline)
if guideline not in self.active_guidelines:
self.active_guidelines.add(guideline)
self.queue_draw()
def remove_guideline(self, guideline):
if guideline in self.guidelines_to_draw:
self.__guidelines_to_draw.remove(guideline)
if guideline in self.active_guidelines:
self.active_guidelines.remove(guideline)
self.queue_draw()
def do_draw(self, cr):
......@@ -53,14 +49,14 @@ class CompositionGuidelinesOverlay(Gtk.DrawingArea, Loggable):
# Draw black border
cr.set_source_rgb(0, 0, 0)
cr.set_line_width(3)
for guideline_func in self.__guidelines_to_draw:
for guideline_func in self.active_guidelines:
guideline_func(self, cr)
cr.stroke()
# Draw blue line in middle
cr.set_source_rgb(0.75, 1.0, 1.0)
cr.set_line_width(1)
for guideline_func in self.__guidelines_to_draw:
for guideline_func in self.active_guidelines:
guideline_func(self, cr)
cr.stroke()
......
......@@ -39,7 +39,7 @@ class ViewerContainerTest(common.TestCase):
viewer_container = self.setup_viewer_widget()
viewer_container.three_by_three_switch.set_active(True)
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.guidelines_to_draw,
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.active_guidelines,
{CompositionGuidelinesDrawingFunctions.three_by_three})
def test_enable_all_guidelines(self):
......@@ -49,7 +49,7 @@ class ViewerContainerTest(common.TestCase):
viewer_container.diagonals_switch.set_active(True)
viewer_container.vert_horiz_center_switch.set_active(True)
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.guidelines_to_draw,
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.active_guidelines,
{CompositionGuidelinesDrawingFunctions.three_by_three, CompositionGuidelinesDrawingFunctions.diagonals, CompositionGuidelinesDrawingFunctions.vertical_horizontal_center})
def test_disable_three_by_three_guidelines(self):
......@@ -58,7 +58,7 @@ class ViewerContainerTest(common.TestCase):
viewer_container.three_by_three_switch.set_active(True)
viewer_container.three_by_three_switch.set_active(False)
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.guidelines_to_draw, set())
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.active_guidelines, set())
def test_show_guidelines(self):
"""Checks that the show guidelines shortcut properly hides the guidelines overlay."""
......@@ -68,7 +68,7 @@ class ViewerContainerTest(common.TestCase):
viewer_container.vert_horiz_center_switch.set_active(True)
viewer_container.toggle_guidelines_action.activate()
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.guidelines_to_draw, set())
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.active_guidelines, set())
def test_toggle_guidelines_shortcut(self):
"""Checks that the toggle guidelines shortcut properly toggles the composition guidelines."""
......@@ -79,10 +79,10 @@ class ViewerContainerTest(common.TestCase):
viewer_container.toggle_guidelines_action.activate()
self.assertEqual(viewer_container.three_by_three_switch.get_active(), False)
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.guidelines_to_draw, set())
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.active_guidelines, set())
viewer_container.toggle_guidelines_action.activate()
self.assertEqual(viewer_container.three_by_three_switch.get_active(), True)
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.guidelines_to_draw,
self.assertEqual(viewer_container.overlay_stack.composition_guidelines_overlay.active_guidelines,
{CompositionGuidelinesDrawingFunctions.three_by_three})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment