Skip to content

Commit

Permalink
Gradient improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-manias authored Dec 8, 2024
2 parents 2c46940 + 8625c93 commit 042f5fc
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 175 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ debug-mod/
local-mod/
local-gdb/
out/
3rdparty/blend2d/
3rdparty/blend2d-apps/
96 changes: 48 additions & 48 deletions examples/vue.fluid
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
--[[
A file viewer for recognised documents like SVG and RIPL

Example: parasol vue.fluid file=[Path]

Optional parameters are:

width: Width of the application window
height: Height of the application window
path: Path to use in the file selector.
file: A source file to load and display in the application.
--]]

require 'gui'
Expand Down Expand Up @@ -44,6 +35,7 @@ Optional parameters are:
<row><cell><p>height</p></cell><cell>Height of the application window.</cell></row>
<row><cell><p>path</p></cell><cell>Path to use in the file selector.</cell></row>
<row><cell><p>file</p></cell><cell>A source file to load and display in the application.</cell></row>
<row><cell><p>no-browser</p></cell><cell>Hide the file browser.</cell></row>
</table></p>

</page>
Expand Down Expand Up @@ -191,50 +183,58 @@ end

glViewport = glWindow:clientViewport({ aspectRatio = ARF_MEET })

-- File view on the left

glView = gui.listView({
target = glViewport,
x = glWindow.margins.left,
y = glWindow.margins.top,
width = 200,
yOffset = glWindow.margins.top,
dragDrop = true,
sensitive = true,
multiSelect = false,
borderless = true
})
if arg('no-browser') then
glViewArea = glViewport.new('VectorViewport', {
x=glWindow.margins.left, y=glWindow.margins.top,
xOffset=glWindow.margins.right, yOffset=glWindow.margins.top
})
else
-- File view on the left

glView = gui.listView({
target = glViewport,
x = glWindow.margins.left,
y = glWindow.margins.top,
width = 200,
yOffset = glWindow.margins.top,
dragDrop = true,
sensitive = true,
multiSelect = false,
borderless = true
})

glFileview = gui.fileview(glView, {
navigationBar = true,
path = arg('path', ':'),
filterList = {
{ name='SVG Images', pattern='.svg' },
{ name='RIPL Documents', pattern={ '.ripl', '.rpl' } },
{ name='JPEG Images', pattern={ '.jpeg', '.jpg' } },
{ name='PNG Images', pattern='.png' }
},
fileSelected = function(FileView)
displayFile(FileView.selectionPath())
title = FileView.selectionFile()
if glStats.width and glStats.height then
title = title .. ' [ ' .. glStats.width .. ' x ' .. glStats.height .. ' ]'
glFileview = gui.fileview(glView, {
navigationBar = true,
displayPath = true,
path = arg('path', ':'),
filterList = {
{ name='SVG Images', pattern='.svg' },
{ name='RIPL Documents', pattern={ '.ripl', '.rpl' } },
{ name='JPEG Images', pattern={ '.jpeg', '.jpg' } },
{ name='PNG Images', pattern='.png' }
},
fileSelected = function(FileView)
displayFile(FileView.selectionPath())
title = FileView.selectionFile()
if glStats.width and glStats.height then
title = title .. ' [ ' .. glStats.width .. ' x ' .. glStats.height .. ' ]'
end
glWindow:setTitle(title)
end
glWindow:setTitle(title)
end
})
})

-- Document viewer on the right
-- Document viewer on the right

glViewArea = glViewport.new('VectorViewport', {
x=glView.viewport.x + glView.viewport.width + 6, y=glWindow.margins.top,
xOffset=glWindow.margins.right, yOffset=glWindow.margins.top
})
glViewArea = glViewport.new('VectorViewport', {
x=glView.viewport.x + glView.viewport.width + 6, y=glWindow.margins.top,
xOffset=glWindow.margins.right, yOffset=glWindow.margins.top
})

gui.divider({
left = glView.viewport, right = glViewArea,
minA = 100, maxA = glWindow.surface.insideWidth * 0.4, minB = 100
})
gui.divider({
left = glView.viewport, right = glViewArea,
minA = 100, maxA = glWindow.surface.insideWidth * 0.4, minB = 100
})
end

-- Display a file from the commandline, or show the application documentation.

Expand Down
19 changes: 0 additions & 19 deletions scripts/gui.fluid
Original file line number Diff line number Diff line change
Expand Up @@ -371,25 +371,6 @@ gui.createIcon = function(Scene, Path, Size, Theme, Name)
end
end)

-- Adjust gradient size to match the viewport height.

local viewport = icon.pattern.viewport.child
if viewport != nil then
while child != nil do
if child.class.id == ID_VECTORVIEWPORT then
viewport = child
break
end
end

if viewport.viewHeight < viewport.viewWidth then
icon.gradient.y1 = viewport.viewY - ((viewport.viewWidth - viewport.viewHeight) * 0.5)
icon.gradient.y2 = icon.gradient.y1 + viewport.viewWidth
else
icon.gradient.y1 = viewport.viewY
icon.gradient.y2 = viewport.viewY + viewport.viewHeight
end
end

check(Scene.mtAddDef(Name, icon.pattern))

Expand Down
1 change: 1 addition & 0 deletions src/svg/class_svg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static ERR SVG_Free(extSVG *Self)
{
if (Self->AnimationTimer) {
UpdateTimer(Self->AnimationTimer, 0);
if (Self->Scene) UnsubscribeAction(Self->Scene, AC::Free);
Self->AnimationTimer = 0;
}

Expand Down
32 changes: 32 additions & 0 deletions src/svg/tests/gradients/w3-pservers-grad-04-b.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions src/svg/tests/gradients/w3-pservers-grad-05-b.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions src/svg/tests/gradients/w3-pservers-grad-10-b.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions src/svg/tests/gradients/w3-pservers-grad-14-b.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/svg/tests/test-svg.fluid
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ function testVStripes() hashTestSVG('patterns/vstripes.svg', 0x2f85dc2

function testW3Gradients01() hashTestSVG('gradients/w3-pservers-grad-01-b.svg', 0xe637a6fa) end
function testW3Gradients02() hashTestSVG('gradients/w3-pservers-grad-02-b.svg', 0x69157174) end
function testW3Gradients04() hashTestSVG('gradients/w3-pservers-grad-04-b.svg', 0x30e19fc3) end
function testW3Gradients05() hashTestSVG('gradients/w3-pservers-grad-05-b.svg', 0x80b6a37d) end
function testW3Gradients07() hashTestSVG('gradients/w3-pservers-grad-07-b.svg', 0xfb7be5fe) end
function testW3Gradients08() hashTestSVG('gradients/w3-pservers-grad-08-b.svg', 0x97f7b810) end
function testW3Gradients09() hashTestSVG('gradients/w3-pservers-grad-09-b.svg', 0xfd34d4f1) end
function testW3Gradients10() hashTestSVG('gradients/w3-pservers-grad-10-b.svg', 0x8a32cb66) end
function testW3Gradients11() hashTestSVG('gradients/w3-pservers-grad-11-b.svg', 0x4f4a58f3) end
function testW3Gradients12() hashTestSVG('gradients/w3-pservers-grad-12-b.svg', 0xd59b60ce) end
function testW3Gradients14() hashTestSVG('gradients/w3-pservers-grad-14-b.svg', 0xb26061f7) end
function testW3Gradients15() hashTestSVG('gradients/w3-pservers-grad-15-b.svg', 0x531aca96) end
function testW3Gradients22() hashTestSVG('gradients/w3-pservers-grad-22-b.svg', 0x5477019b) end

Expand Down Expand Up @@ -252,11 +256,15 @@ function testW3TextB25() hashTestSVG('text/w3-text-ws-03-t.svg', -1) end
'testInheritClip',
'testW3Gradients01',
'testW3Gradients02',
'testW3Gradients04',
'testW3Gradients05',
'testW3Gradients07',
'testW3Gradients08',
'testW3Gradients09',
'testW3Gradients10',
'testW3Gradients11',
'testW3Gradients12',
'testW3Gradients14',
'testW3Gradients15',
'testW3Gradients22',
-- Patterns
Expand Down
Loading

0 comments on commit 042f5fc

Please sign in to comment.