Skip to content

Commit

Permalink
Add pause feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelTallet committed Jan 26, 2020
1 parent 1dcbbcd commit 3e8dc70
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/visual_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Visual History plugin namespace.
module VisualHistory

VERSION = '1.0.2'.freeze
VERSION = '1.0.3'.freeze

# Load translation if it's available for current locale.
TRANSLATE = LanguageHandler.new('vhy.strings')
Expand Down
1 change: 1 addition & 0 deletions source/visual_history/Resources/fr/vhy.strings
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
//

"Show Visual History"="Afficher l'historique visuel";
"Pause/Restart State Recording"="Mettre en pause/reprendre l'enregistrement des états";
"Force Current State Recording"="Forcer l'enregistrement de l'état actuel";
"Center Selection Relatively to Origin"="Centrer la sélection par rapport à l'origine";
"Clear Visual History"="Effacer l'historique visuel";
Expand Down
6 changes: 6 additions & 0 deletions source/visual_history/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def add_menu_items

}

@menu.add_item(TRANSLATE['Pause/Restart State Recording']) {

Viewer.pause_state_recording

}

@menu.add_item(TRANSLATE['Force Current State Recording']) {

Viewer.force_state_recording
Expand Down
6 changes: 6 additions & 0 deletions source/visual_history/model_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ModelObserver < Sketchup::ModelObserver

# When a transaction is completed:
def onTransactionCommit(_model)

return if SESSION[:pause] == true

Viewer.add_state

Expand All @@ -41,6 +43,8 @@ def onTransactionCommit(_model)
# When user “redoes” a transaction:
def onTransactionRedo(_model)

return if SESSION[:pause] == true

Viewer.add_state

Viewer.reload_html_dialog
Expand All @@ -50,6 +54,8 @@ def onTransactionRedo(_model)
# When user “undoes” a transaction:
def onTransactionUndo(_model)

return if SESSION[:pause] == true

Viewer.remove_last_state

Viewer.reload_html_dialog
Expand Down
19 changes: 19 additions & 0 deletions source/visual_history/viewer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ def self.temp_dir

end

# Pause/restart state recording.
#
# @return [nil]
def self.pause_state_recording

if SESSION[:pause].nil?

SESSION[:pause] = false

end

SESSION[:pause] = !SESSION[:pause]

cleanup_and_reset

nil

end

# Forces recording of current state (thanks to a null operation).
#
# @return [nil]
Expand Down

0 comments on commit 3e8dc70

Please sign in to comment.