Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional settings in Shoes::App #556

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lacci/lib/shoes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class << self
# @param height [Integer] The new app window height
# @param resizable [Boolean] Whether the app window should be resizeable
# @param features [Symbol,Array<Symbol>] Additional Shoes extensions requested by the app
# @param settings [Object] Additional Shoes settings, specific to the Shoes implementation
# @return [void]
# @see Shoes::App#new
def app(
Expand All @@ -83,10 +84,11 @@ def app(
height: 420,
resizable: true,
features: [],
settings: {},
&app_code_body
)
f = [features].flatten # Make sure this is a list, not a single symbol
app = Shoes::App.new(title:, width:, height:, resizable:, features: f, &app_code_body)
app = Shoes::App.new(title:, width:, height:, resizable:, features: f, settings:, &app_code_body)
app.init
app.run
nil
Expand Down
8 changes: 7 additions & 1 deletion lacci/lib/shoes/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ class << self

shoes_styles :title, :width, :height, :resizable, :features

# This is defined to avoid the linkable-id check in the Shoes-style method_missing def'n
# This is entirely different for different Shoes implementations. But it allows passing
# implementation-specific settings information that Lacci can't directly use.
attr_reader :settings

# This is defined ahead of time to avoid the linkable-id check in the Shoes-style method_missing def'n
def features
@features
end
Expand All @@ -31,6 +35,7 @@ def initialize(
height: 420,
resizable: true,
features: [],
settings: {},
&app_code_body
)
log_init("Shoes::App")
Expand All @@ -49,6 +54,7 @@ def initialize(
@event_loop_type = "displaylib" # the default

@features = features
@settings = settings

unknown_ext = features - Shoes::FEATURES - Shoes::EXTENSIONS
unsupported_features = unknown_ext & Shoes::KNOWN_FEATURES
Expand Down
Loading