mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-15 21:32:35 +00:00
40 lines
970 B
Ruby
40 lines
970 B
Ruby
module TAC
|
|
class Dialog
|
|
class ConfirmDialog < Dialog
|
|
def build
|
|
@dangerous = @options[:dangerous]
|
|
@dangerous ||= false
|
|
|
|
color = @dangerous ? Palette::DANGEROUS : Palette::ALERT
|
|
|
|
@dialog_root.style.default[:border_color] = [ color, darken(color, 50) ]
|
|
@titlebar.style.default[:background] = [ color, darken(color, 50) ]
|
|
|
|
background Gosu::Color::GRAY
|
|
label @options[:message]
|
|
|
|
flow width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
|
button "Cancel", width: 0.5 do
|
|
close
|
|
end
|
|
|
|
button "Proceed", width: 0.5, **TAC::THEME_DANGER_BUTTON do
|
|
try_commit(true)
|
|
end
|
|
end
|
|
end
|
|
|
|
def try_commit(force = false)
|
|
if !@dangerous
|
|
close
|
|
|
|
@options[:callback_method].call
|
|
elsif @dangerous && force
|
|
close
|
|
|
|
@options[:callback_method].call
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end |