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

Script improvements #279

Merged
merged 17 commits into from
Nov 29, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[Scripts] Added gui.rgbToIconTheme()
paul-manias committed Nov 27, 2024
commit effcad5067707829b47d061de5c77f8df2868c79
34 changes: 24 additions & 10 deletions scripts/gui.fluid
Original file line number Diff line number Diff line change
@@ -190,6 +190,20 @@ gui.rgbValue = function(Value)
return max
end

----------------------------------------------------------------------------------------------------------------------

gui.rgbToIconTheme = function(Value)
if type(Value) == 'string' then
Value = gui.strToRGB(Value)
end

if gui.rgbValue(Value) > 127 then
return 'pearl'
else
return 'carbon'
end
end

----------------------------------------------------------------------------------------------------------------------
-- Convert RGB table to HSV

@@ -422,17 +436,17 @@ end
-- prime (primary) and second (secondary prime) are colour pairs of the same hue.
-- contrast is a suitable complement to prime and should be of a strongly contrasting hue
-- neutral is a default background colour for unpainted areas, usually a light grey tone
ocean = { type = 'light', bkgd = '#ECF0F1', base = '#2C3E50', prime = '#3498DB', second = '#2980B9',
contrast = '#E74C3C', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
ocean = { type = 'light', bkgd = '#ECF0F1', base = '#2C3E50', prime = '#3498DB', second = '#2980B9',
contrast = '#E74C3C', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
orangeApples = { type = 'light', bkgd = '#ffffff', base = '#19302d', prime = '#74a108', second = '#263248',
contrast = '#e89214', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
greenland = { type = 'light', bkgd = '#f9FFfB', base = '#163a00', prime = '#c55500', second = '#55c500',
contrast = '#567a00', neutral = '#e9e9e0', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
sunrise = { type = 'light', bkgd = '#f9FfFc', base = '#687878', prime = '#e2581b', second = '#bd3232',
contrast = '#eb9500', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
candyfloss = { type = 'light', bkgd = '#fffaf7', base = '#375a5e', prime = '#6ac9a6', second = '#FF8B94',
contrast = '#e07780', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
template = { type = '', bkgd = '', base = '', prime = '', second = '', contrast = '', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' }
greenland = { type = 'light', bkgd = '#f9FFfB', base = '#163a00', prime = '#c55500', second = '#55c500',
contrast = '#567a00', neutral = '#e9e9e0', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
sunrise = { type = 'light', bkgd = '#f9FfFc', base = '#687878', prime = '#e2581b', second = '#bd3232',
contrast = '#eb9500', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
candyfloss = { type = 'light', bkgd = '#fffaf7', base = '#375a5e', prime = '#6ac9a6', second = '#FF8B94',
contrast = '#e07780', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' },
template = { type = '', bkgd = '', base = '', prime = '', second = '', contrast = '', neutral = 'rgb(220,220,220)', text='rgb(0,0,0)', altText='rgb(255,255,255)' }
}

gui.palette = gui.palettes.ocean
@@ -457,7 +471,7 @@ end
text = gui.palette.altText,
bkgd = gui.palette.prime,
stroke = 'rgb(255,255,255,60)',
strokeFocus = gui.palette.contrast,
strokeFocus = gui.palette.contrast,
strokeWidth = 2,
width = 160, -- Default width for common widgets (px)
gap = 6, -- Recommended gap between widgets (px)
10 changes: 1 addition & 9 deletions scripts/gui/button.fluid
Original file line number Diff line number Diff line change
@@ -10,14 +10,6 @@ local HEIGHT = math.floor(FONT_MAX_HEIGHT * 1.75) + 1
local ICON_SIZE = HEIGHT * 0.56
local GAP = HEIGHT * 0.35

local function iconTheme()
if (gui.rgbValue(gui.strToRGB(gui.style.widget.text)) > 127) then
return 'pearl'
else
return 'default' -- The default theme is dark
end
end

gui.button = function(Options)
local self = { -- Public variables
events = nz(Options.events, { }),
@@ -98,7 +90,7 @@ gui.button = function(Options)

if Options.icon then
pcall(function()
local icon = gui.createIcon(self.viewport.scene, Options.icon, ICON_SIZE, iconTheme())
local icon = gui.createIcon(self.viewport.scene, Options.icon, ICON_SIZE, gui.rgbToIconTheme(gui.style.widget.text))

if icon then
self.iconRender = self.viewport.new('VectorViewport', {
4 changes: 2 additions & 2 deletions scripts/gui/columnview.fluid
Original file line number Diff line number Diff line change
@@ -229,7 +229,7 @@ local function bannerZoneClick(View, Col, X, Y, Value)
View._sort = { col=Col, ascending=false }
if not View.iconDescending then
if not View.icons['sort_desc'] then
gui.createIcon(View.scene, 'layout/sort_alpha_desc', ICON_SIZE, nil, 'sort_desc')
gui.createIcon(View.scene, 'layout/sort_alpha_desc', ICON_SIZE, gui.rgbToIconTheme(gui.style.widget.text), 'sort_desc')
View.icons['sort_desc'] = true
end

@@ -245,7 +245,7 @@ local function bannerZoneClick(View, Col, X, Y, Value)
if not View.iconAscending then
if not View.icons['sort_asc'] then
View.icons['sort_asc'] = true
gui.createIcon(View.scene, 'layout/sort_alpha_asc', ICON_SIZE, nil, 'sort_asc')
gui.createIcon(View.scene, 'layout/sort_alpha_asc', ICON_SIZE, gui.rgbToIconTheme(gui.style.widget.text), 'sort_asc')
end

View._sort.icon = Col.bannerVP.new('VectorRectangle', {