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

V0.12.0 rc.0 #348

Merged
merged 10 commits into from
Jun 25, 2024
Merged
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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: '1.11.4'
otp: '24.2'
- elixir: '1.16.0'
otp: '26.2'

Expand Down
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.12.0-rc.0

**Note: as of v0.12.0 we'll be requiring at least Elixir 1.16**

This is a major update that adds fixes and support for new operations:

* CI improvements - @axelson
* Formatting updates - @axelson
* Support for Elixir 1.16 - @axelson
* Update getting started guide for Scenic in supervision tree - @amclain
* Fix `already_started` error propogation failure - @seb3s
* Add development Nix flake - @crertel
* Reduce makefile compilation spam - @jjcartsens
* Simplify `default_pin` and `centroid` code - @seb3s
* Add new input events (`:btn_pressed`, `:btn_released`, `:dropdown_opened`, `:dropdown_closed`, `:dropdown_item_hover`, `:focus`, `:blur`) - @GPrimola
* Add warning for missing `handle_input/3` on `request_input/2` - @BinaryNoggin
* Add alpha channel to sprites - @seb3s
* Add script arc functions - @GPrimola
* Add extended rounded rectangle drawing - @GPrimola
* Assorted updates for deprecations and warnings


## 0.11.2

* Variety of minor updates, bug fixes, and doc updates
Expand Down Expand Up @@ -113,7 +135,7 @@ continue to work, but will log a warning when used.

| Asset Class | Module |
| ------------- | -----|
| Fonts | `Scenic.Cache.Static.Font` |
| Fonts | `Scenic.Cache.Static.Font` |
| Font Metrics | `Scenic.Cache.Static.FontMetrics` |
| Textures (images in a fill) | `Scenic.Cache.Static.Texture` |
| Raw Pixel Maps | `Scenic.Cache.Dynamic.Texture` |
Expand Down
2 changes: 1 addition & 1 deletion config/.credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
#
{Credo.Check.Design.TagTODO, exit_status: 2},
{Credo.Check.Design.TagTODO, exit_status: 0},
{Credo.Check.Design.TagFIXME},

#
Expand Down
48 changes: 34 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,44 @@
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (pkgs.lib) optional optionals;
pkgs = import nixpkgs { inherit system; };
let
inherit (pkgs.lib) optional optionals;
pkgs = import nixpkgs { inherit system; };

elixir = pkgs.beam.packages.erlang.elixir;
in
with pkgs;
{
devShell = pkgs.mkShell {
buildInputs = [
elixir_1_16
elixir_ls
] ++ optional stdenv.isLinux inotify-tools
elixir = pkgs.beam.packages.erlang.elixir;
in
with pkgs;
{
devShell = pkgs.mkShell {
buildInputs = [
util-linux
libselinux
libthai
libdatrie
libsepol
libxkbcommon
libepoxy
pcre
pcre2
xorg.libXtst
cairo
gtk3
freeglut
elixir_1_16
elixir_ls
glibcLocales
glew
glfw
pkg-config
xorg.libX11
xorg.libXau
xorg.libXdmcp
] ++ optional stdenv.isLinux inotify-tools
++ optional stdenv.isDarwin terminal-notifier
++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
CoreFoundation
CoreServices
]);
};
});
};
});
}
13 changes: 7 additions & 6 deletions lib/scenic/color.ex
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ defmodule Scenic.Color do

Most of the time, you will use one of the pre-defined named colors from the
Named Colors table. However, there are times when you want to work with
other color formats ranging from simple grayscale to rgb to hsl.
other color formats ranging from simple grayscale to rgb to hsl.

The following formats are all supported by the `Scenic.Color` module.
The values of r, g, b, and a are integers between 0 and 255.
Expand Down Expand Up @@ -543,11 +543,12 @@ defmodule Scenic.Color do
h = rgb_to_hue(r, g, b)
l = (max + min) / 2

s =
cond do
delta < @epsilon -> 0.0
true -> delta / (1 - abs(2 * l - 1))
end
s = if delta < @epsilon do
0.0
else
delta / (1 - abs(2 * l - 1))
end


{h, s * 100, l * 100}
end
Expand Down
36 changes: 18 additions & 18 deletions lib/scenic/driver/key_map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ defmodule Scenic.Driver.KeyMap do
"""
@spec caps_lock?(keys :: keys) :: boolean
def caps_lock?(keys) do
is_pressed?(keys[:virt_caps_lock])
pressed?(keys[:virt_caps_lock])
end

@doc """
Expand All @@ -74,7 +74,7 @@ defmodule Scenic.Driver.KeyMap do
"""
@spec num_lock?(keys :: keys) :: boolean
def num_lock?(keys) do
is_pressed?(keys[:virt_num_lock])
pressed?(keys[:virt_num_lock])
end

@doc """
Expand All @@ -84,7 +84,7 @@ defmodule Scenic.Driver.KeyMap do
"""
@spec scroll_lock?(keys :: keys) :: boolean
def scroll_lock?(keys) do
is_pressed?(keys[:virt_scroll_lock])
pressed?(keys[:virt_scroll_lock])
end

@doc """
Expand All @@ -94,39 +94,39 @@ defmodule Scenic.Driver.KeyMap do
"""
@spec shift?(keys :: keys) :: boolean
def shift?(keys) do
is_pressed?(keys[:key_shift]) ||
is_pressed?(keys[:key_leftshift]) ||
is_pressed?(keys[:key_rightshift])
pressed?(keys[:key_shift]) ||
pressed?(keys[:key_leftshift]) ||
pressed?(keys[:key_rightshift])
end

@doc """
Is any alt key pressed?
"""
@spec alt?(keys :: keys) :: boolean
def alt?(keys) do
is_pressed?(keys[:key_alt]) ||
is_pressed?(keys[:key_leftalt]) ||
is_pressed?(keys[:key_rightalt])
pressed?(keys[:key_alt]) ||
pressed?(keys[:key_leftalt]) ||
pressed?(keys[:key_rightalt])
end

@doc """
Is any ctrl key pressed?
"""
@spec ctrl?(keys :: keys) :: boolean
def ctrl?(keys) do
is_pressed?(keys[:key_ctrl]) ||
is_pressed?(keys[:key_leftctrl]) ||
is_pressed?(keys[:key_rightctrl])
pressed?(keys[:key_ctrl]) ||
pressed?(keys[:key_leftctrl]) ||
pressed?(keys[:key_rightctrl])
end

@doc """
Is any meta key pressed? This is usually the command button.
"""
@spec meta?(keys :: keys) :: boolean
def meta?(keys) do
is_pressed?(keys[:key_meta]) ||
is_pressed?(keys[:key_leftmeta]) ||
is_pressed?(keys[:key_rightmeta])
pressed?(keys[:key_meta]) ||
pressed?(keys[:key_leftmeta]) ||
pressed?(keys[:key_rightmeta])
end

@doc """
Expand All @@ -144,9 +144,9 @@ defmodule Scenic.Driver.KeyMap do
|> add_if_set(:scroll_lock, scroll_lock?(keys))
end

defp is_pressed?(nil), do: false
defp is_pressed?(0), do: false
defp is_pressed?(_), do: true
defp pressed?(nil), do: false
defp pressed?(0), do: false
defp pressed?(_), do: true

defp add_if_set(list, value, true), do: [value | list]
defp add_if_set(list, _value, false), do: list
Expand Down
26 changes: 14 additions & 12 deletions lib/scenic/graph/compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,21 @@ defmodule Scenic.Graph.Compiler do
defp compile_styles(desired, %Compiler{} = state) when is_list(desired) do
Enum.reduce(desired, {[], state}, fn k, {ops, state} ->
# if not requested, there is no style to compile...
with {:ok, req} <- fetch_req(state, k) do
case fetch_set(state, k) do
{:ok, ^req} ->
# Nothing to do. The correct style is already set
{ops, state}

_ ->
# Whatever is set (or not) is different than what is requested
{compile_style(ops, {k, req}), put_set(state, k, req)}
end
else
case fetch_req(state, k) do
{:ok, req} ->
case fetch_set(state, k) do
{:ok, ^req} ->
# Nothing to do. The correct style is already set
{ops, state}

_ ->
# Whatever is set (or not) is different than what is requested
{compile_style(ops, {k, req}), put_set(state, k, req)}
end

# not requested at all case
_ -> {ops, state}
_ ->
{ops, state}
end
end)
end
Expand Down
8 changes: 6 additions & 2 deletions lib/scenic/scene.ex
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,14 @@ defmodule Scenic.Scene do
def request_input(scene, input_class)
def request_input(scene, input) when is_atom(input), do: request_input(scene, [input])

def request_input(%Scene{viewport: vp, pid: pid, module: module}, inputs) when is_list(inputs) do
def request_input(%Scene{viewport: vp, pid: pid, module: module}, inputs)
when is_list(inputs) do
unless Kernel.function_exported?(module, :handle_input, 3) do
Logger.warning("Requesting input for #{inspect inputs} - #{module}.handle_input/3 not implemented")
Logger.warning(
"Requesting input for #{inspect(inputs)} - #{module}.handle_input/3 not implemented"
)
end

ViewPort.Input.request(vp, inputs, pid: pid)
end

Expand Down
3 changes: 2 additions & 1 deletion lib/scenic/script.ex
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ defmodule Scenic.Script do

[
{:draw_rrectv,
{width, height, upper_left_radius, upper_right_radius, lower_right_radius, lower_left_radius, flag}}
{width, height, upper_left_radius, upper_right_radius, lower_right_radius,
lower_left_radius, flag}}
| ops
]
end
Expand Down
18 changes: 9 additions & 9 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ defmodule Scenic.Mixfile do

@app_name :scenic

@version "0.11.2"
@version "0.12.0-rc.0"

@elixir_version "~> 1.11"
@elixir_version "~> 1.16"
@github "https://github.com/ScenicFramework/scenic"

def project do
Expand Down Expand Up @@ -47,18 +47,18 @@ defmodule Scenic.Mixfile do
defp deps do
[
{:font_metrics, "~> 0.5.0"},
{:nimble_options, "~> 0.3.4 or ~> 0.4.0 or ~> 0.5.0 or ~> 1.0"},
{:nimble_options, "~> 0.3.4 or ~> 0.4.0 or ~> 0.5.0 or ~> 1.1"},
{:ex_image_info, "~> 0.2.4"},
{:truetype_metrics, "~> 0.6"},

# Tools
{:elixir_make, "~> 0.8.3", runtime: false},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:credo, ">= 0.0.0", only: [:dev, :test], runtime: false},
{:excoveralls, ">= 0.0.0", only: :test, runtime: false},
{:elixir_make, "~> 0.8.4", runtime: false},
{:ex_doc, "~> 0.34.1", only: :dev, runtime: false},
{:credo, "~> 1.7.7", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.18.1", only: :test, runtime: false},
{:inch_ex, "~> 2.0", only: [:dev, :docs], runtime: false},
{:dialyxir, "~> 1.1", only: :dev, runtime: false},
{:machete, "~> 0.2.8", only: :test}
{:dialyxir, "~> 1.4.3", only: :dev, runtime: false},
{:machete, "~> 0.3.3", only: :test}
]
end

Expand Down
Loading
Loading