Skip to content

Commit

Permalink
Several large renames and a version bump (#401)
Browse files Browse the repository at this point in the history
* Scarpe should be a module, not a class.

* Rename 'widget' to 'drawable' throughout Scarpe. Bump version number.

* Rename display properties to Shoes styles

* Fix error declaration problem for scarpe-components tests and update Gemfile.lock for sub-gems

* Fix merge conflict
  • Loading branch information
noahgibbs authored Oct 10, 2023
1 parent 530db55 commit 6abd50f
Show file tree
Hide file tree
Showing 104 changed files with 533 additions and 533 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
scarpe (0.2.2)
scarpe (0.3.0)
bloops (~> 0.5)
fastimage
lacci
Expand All @@ -14,12 +14,12 @@ PATH
PATH
remote: lacci
specs:
lacci (0.2.2)
lacci (0.3.0)

PATH
remote: scarpe-components
specs:
scarpe-components (0.2.2)
scarpe-components (0.3.0)

GEM
remote: https://rubygems.org/
Expand Down
12 changes: 6 additions & 6 deletions examples/gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
require 'erb'

class ScarpeGenerator
def initialize(filename, display_properties)
def initialize(filename, shoes_styles)
@filename = filename
@display_properties = display_properties
@shoes_styles = shoes_styles
end

def generate_files(choice, class_template_choice)
Expand Down Expand Up @@ -96,7 +96,7 @@ def binding_with_argument
capitalized_argument = @filename.capitalize
binding.dup.tap do |b|
b.local_variable_set(:argument, capitalized_argument)
b.local_variable_set(:display_properties, @display_properties)
b.local_variable_set(:shoes_styles, @shoes_styles)
end
end
end
Expand All @@ -109,7 +109,7 @@ def binding_with_argument
end

stack width: 400 do
para 'Enter display properties (like :height,:text) '
para 'Enter Shoes styles (like :height,:text) '
$properties_input = edit_line
end

Expand All @@ -125,10 +125,10 @@ def binding_with_argument

button 'Generate Files!',color:"#FF7116",padding_bottom:"8",padding_top:"8",text_color:"white",font_size:"16" do
filename = $filename_input.text
display_properties = $properties_input.text
shoes_styles = $properties_input.text
choice = $choice_input.selected_item

generator = ScarpeGenerator.new(filename, display_properties)
generator = ScarpeGenerator.new(filename, shoes_styles)

if choice == 'Class'
generator.generate_files(choice, $class_template_choice_input.selected_item)
Expand Down
2 changes: 1 addition & 1 deletion lacci/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lacci (0.2.2)
lacci (0.3.0)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion lacci/lib/lacci/scarpe_cli.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Scarpe
module Scarpe
module CLI
DEFAULT_USAGE = <<~'USAGE'
Usage: scarpe_core [OPTIONS] <scarpe app file> # Same as "scarpe run"
Expand Down
2 changes: 1 addition & 1 deletion lacci/lib/lacci/scarpe_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
exit(-1)
end

class Scarpe; end
module Scarpe; end

# The base error class for Scarpe errors, but not necessarily {Shoes::Error}s
class Scarpe::Error < StandardError; end
Expand Down
2 changes: 1 addition & 1 deletion lacci/lib/lacci/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# mostly invisible. Instead, look at the {Shoes} module
# to see what's in Lacci.
module Lacci
VERSION = "0.2.2"
VERSION = "0.3.0"
end
6 changes: 3 additions & 3 deletions lacci/lib/shoes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ module Kernel
require_relative "shoes/border"
require_relative "shoes/spacing"

require_relative "shoes/widget"
require_relative "shoes/drawable"
require_relative "shoes/app"
require_relative "shoes/widgets"
require_relative "shoes/drawables"

require_relative "shoes/download"

Expand All @@ -46,7 +46,7 @@ module Shoes

class << self
# Creates a Shoes app with a new window. The block parameter is used to create
# widgets and set up handlers. Arguments are passed to Shoes::App.new internally.
# drawables and set up handlers. Arguments are passed to Shoes::App.new internally.
#
# @incompatibility In Shoes3, this method will return normally.
# In Scarpe, after the block is executed, the method will not return and Scarpe
Expand Down
36 changes: 18 additions & 18 deletions lacci/lib/shoes/app.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Shoes
class App < Shoes::Widget
class App < Shoes::Drawable
include Shoes::Log

class << self
Expand All @@ -10,7 +10,7 @@ class << self

attr_reader :document_root

display_properties :title, :width, :height, :resizable
shoes_styles :title, :width, :height, :resizable

CUSTOM_EVENT_LOOP_TYPES = ["displaylib", "return", "wait"]

Expand All @@ -36,20 +36,20 @@ def initialize(
super

# The draw context tracks current settings like fill and stroke,
# plus potentially other current state that changes from widget
# to widget and slot to slot.
# plus potentially other current state that changes from drawable
# to drawable and slot to slot.
@draw_context = {
"fill" => "",
"stroke" => "",
}

# This creates the DocumentRoot, including its corresponding display widget
# This creates the DocumentRoot, including its corresponding display drawable
@document_root = Shoes::DocumentRoot.new

@slots = []

# Now create the App display widget
create_display_widget
# Now create the App display drawable
create_display_drawable

# Set up testing events *after* Display Service basic objects exist
if ENV["SCARPE_APP_TEST"]
Expand Down Expand Up @@ -90,9 +90,9 @@ def init
::Shoes::App.instance.with_slot(@document_root, &@app_code_body)
end

# "Container" widgets like flows, stacks, masks and the document root
# "Container" drawables like flows, stacks, masks and the document root
# are considered "slots" in Shoes parlance. When a new slot is created,
# we push it here in order to track what widgets are found in that slot.
# we push it here in order to track what drawables are found in that slot.
def push_slot(slot)
@slots.push(slot)
end
Expand Down Expand Up @@ -154,7 +154,7 @@ def destroy(send_event: true)
send_shoes_event(event_name: "destroy") if send_event
end

def all_widgets
def all_drawables
out = []

to_add = @document_root.children
Expand All @@ -166,37 +166,37 @@ def all_widgets
out
end

# We can add various ways to find widgets here.
# We can add various ways to find drawables here.
# These are sort of like Shoes selectors, used for testing.
def find_widgets_by(*specs)
widgets = all_widgets
def find_drawables_by(*specs)
drawables = all_drawables
specs.each do |spec|
if spec.is_a?(Class)
widgets.select! { |w| spec === w }
drawables.select! { |w| spec === w }
elsif spec.is_a?(Symbol) || spec.is_a?(String)
s = spec.to_s
case s[0]
when "$"
begin
# I'm not finding a global_variable_get or similar...
global_value = eval s
widgets &= [global_value]
drawables &= [global_value]
rescue
raise InvalidAttributeValueError, "Error getting global variable: #{spec.inspect}"
end
when "@"
if Shoes::App.instance.instance_variables.include?(spec.to_sym)
widgets &= [self.instance_variable_get(spec)]
drawables &= [self.instance_variable_get(spec)]
else
raise InvalidAttributeValueError, "Can't find top-level instance variable: #{spec.inspect}!"
end
else
end
else
raise(InvalidAttributeValueError, "Don't know how to find widgets by #{spec.inspect}!")
raise(InvalidAttributeValueError, "Don't know how to find drawables by #{spec.inspect}!")
end
end
widgets
drawables
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lacci/lib/shoes/background.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Shoes
module Background
def self.included(includer)
includer.display_property(:background_color)
includer.shoes_style(:background_color)
end

# NOTE: this needs to be passed through in order for the styling to work
Expand Down
2 changes: 1 addition & 1 deletion lacci/lib/shoes/border.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Shoes
module Border
def self.included(includer)
includer.display_properties :border_color, :options
includer.shoes_styles :border_color, :options
end

# Considering a signature like this:
Expand Down
32 changes: 18 additions & 14 deletions lacci/lib/shoes/display_service.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Lacci Shoes apps operate in multiple layers. A Shoes widget tree exists as fairly
# plain, simple Ruby objects. And then a display-service widget tree integrates with
# Lacci Shoes apps operate in multiple layers. A Shoes drawable tree exists as fairly
# plain, simple Ruby objects. And then a display-service drawable tree integrates with
# the display technology. This lets us use Ruby as our API while
# not tying it too closely to the limitations of Webview, WASM, LibUI, etc.
#
Expand All @@ -15,16 +15,16 @@
#
# ## Events
#
# Events are a lot of what tie the Shoes widgets and the display service together.
# Events are a lot of what tie the Shoes drawables and the display service together.
#
# Shoes widgets *expect* to operate in a fairly "hands off" mode where they record
# Shoes drawables *expect* to operate in a fairly "hands off" mode where they record
# to an event queue to send to the display service, and the display service records
# events to send back.
#
# When a Shoes handler takes an action (e.g. some_para.replace(),) the relevant
# call will be dispatched as a :display event, to be sent to the display service.
# And when a display-side event occurs (e.g. user pushes a button,) it will be
# dispatched as a :shoes event, to be sent to the Shoes tree of widgets.
# dispatched as a :shoes event, to be sent to the Shoes tree of drawables.
#
module Shoes
class DisplayService
Expand Down Expand Up @@ -128,22 +128,26 @@ def display_service

# These methods are an interface to DisplayService objects.

def create_display_widget_for(widget_class_name, widget_id, properties)
def create_display_drawable_for(drawable_class_name, drawable_id, properties)
raise "Override in DisplayService implementation!"
end

def set_widget_pairing(id, display_widget)
@display_widget_for ||= {}
@display_widget_for[id] = display_widget
def set_drawable_pairing(id, display_drawable)
@display_drawable_for ||= {}
if @display_drawable_for[id]
@log.warn("There is already a drawable for #{id.inspect}! Not setting a new one.")
return
end
@display_drawable_for[id] = display_drawable
end

def query_display_widget_for(id, nil_ok: false)
display_widget = @display_widget_for[id]
unless display_widget || nil_ok
raise "Could not find display widget for linkable ID #{id.inspect}!"
def query_display_drawable_for(id, nil_ok: false)
display_drawable = @display_drawable_for[id]
unless display_drawable || nil_ok
raise "Could not find display drawable for linkable ID #{id.inspect}!"
end

display_widget
display_drawable
end

def destroy
Expand Down
2 changes: 1 addition & 1 deletion lacci/lib/shoes/download.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Shoes
class Widget
class Drawable
class ResponseWrapper
attr_reader :response

Expand Down
Loading

0 comments on commit 6abd50f

Please sign in to comment.