Skip to content

Commit

Permalink
Merge pull request #302 from parasol-framework/test/gradients
Browse files Browse the repository at this point in the history
Test/gradients
  • Loading branch information
paul-manias authored Jan 16, 2025
2 parents c55a5d0 + f334929 commit 059bdac
Show file tree
Hide file tree
Showing 25 changed files with 271 additions and 285 deletions.
17 changes: 8 additions & 9 deletions docs/xml/modules/classes/task.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
<access read="G" write="S">Get/Set</access>
<type>FUNCTION</type>
<description>
<p>The InputCallback field is available for use only when the task object represents the current process. The referenced function will be called when process receives data from STDIN. The callback must follow the prototype <code>Function(*Task, APTR Data, LONG Size, ERR Status)</code></p>
<p>The InputCallback field is available to the active task object only (i.e. the current process). The referenced function will be called when process receives data from STDIN. The callback must follow the prototype <code>Function(*Task, APTR Data, LONG Size, ERR Status)</code></p>
<p>The information read from STDOUT will be returned in the <code>Data</code> pointer and the byte-length of the data will be indicated by the <code>Size</code>. The data buffer is temporary and will be invalid once the callback function has returned.</p>
<p>A status of <code>ERR::Finished</code> is sent if the stdinput handle has been closed.</p>
</description>
Expand Down Expand Up @@ -377,16 +377,15 @@
</fields>
<types>
<constants lookup="TSF" comment="Task flags">
<const name="ATTACHED">Forces new task to be attached to the parent (child will close when parent closes).</const>
<const name="DETACHED">Forces new task to be detached from the parent.</const>
<const name="FOREIGN">Set this flag when using the task object to execute a foreign process - that is an executable that does not use the Parasol API.</const>
<const name="LOG_ALL">Additional debug messages will be printed during normal usage of the task class when this flag is set.</const>
<const name="ATTACHED">Forces the new process to be attached to the parent (child will close when parent closes).</const>
<const name="DETACHED">Forces the new process to be detached from the parent.</const>
<const name="PIPE">Enable the output pipe to the launched process so that it can read data.</const>
<const name="PRIVILEGED">During a normal execution process, any privileges of the parent process will be dropped so that the child process runs unprivileged. This behaviour can be reversed if he PRIVILEGED flag is set, in which case the child process has the same privileges as the parent.</const>
<const name="QUIET">Setting this flag will divert all process output to <code>/dev/null</code> or the nearest equivalent for non-Unix systems.</const>
<const name="RESET_PATH">If set, the executed process will start in its own folder rather than the folder of the parent process.</const>
<const name="PRIVILEGED">The child process will inherit the system privileges of its parent.</const>
<const name="QUIET">Divert all process output to <code>/dev/null</code> or the nearest equivalent for non-Unix systems.</const>
<const name="RESET_PATH">The new process will start in its own folder and not the folder of the parent process.</const>
<const name="SHELL">Enables shell mode. On Unix systems, this means that a shell (usually BASH) will be used to launch the process.</const>
<const name="WAIT">This flag will cause the parent process to halt when the task is activated. Control is returned to the parent process once the child process terminates.</const>
<const name="VERBOSE">Enable verbose logging.</const>
<const name="WAIT">The parent process will halt when the task is running. Control is returned to the parent process once the child process terminates.</const>
</constants>

</types>
Expand Down
2 changes: 1 addition & 1 deletion docs/xml/modules/classes/vectorgradient.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<field>
<name>TotalStops</name>
<comment>Total number of stops defined in the Stops array.</comment>
<access read="R">Read</access>
<access read="G">Get</access>
<type>INT</type>
<description>
<p>This read-only field indicates the total number of stops that have been defined in the <fl>Stops</fl> array.</p>
Expand Down
17 changes: 8 additions & 9 deletions docs/xml/modules/core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2910,16 +2910,15 @@ SetField(Object, FID_Statement|TSTR, "string");
</constants>

<constants lookup="TSF" comment="Task flags">
<const name="ATTACHED">Forces new task to be attached to the parent (child will close when parent closes).</const>
<const name="DETACHED">Forces new task to be detached from the parent.</const>
<const name="FOREIGN">Set this flag when using the task object to execute a foreign process - that is an executable that does not use the Parasol API.</const>
<const name="LOG_ALL">Additional debug messages will be printed during normal usage of the task class when this flag is set.</const>
<const name="ATTACHED">Forces the new process to be attached to the parent (child will close when parent closes).</const>
<const name="DETACHED">Forces the new process to be detached from the parent.</const>
<const name="PIPE">Enable the output pipe to the launched process so that it can read data.</const>
<const name="PRIVILEGED">During a normal execution process, any privileges of the parent process will be dropped so that the child process runs unprivileged. This behaviour can be reversed if he PRIVILEGED flag is set, in which case the child process has the same privileges as the parent.</const>
<const name="QUIET">Setting this flag will divert all process output to <code>/dev/null</code> or the nearest equivalent for non-Unix systems.</const>
<const name="RESET_PATH">If set, the executed process will start in its own folder rather than the folder of the parent process.</const>
<const name="PRIVILEGED">The child process will inherit the system privileges of its parent.</const>
<const name="QUIET">Divert all process output to <code>/dev/null</code> or the nearest equivalent for non-Unix systems.</const>
<const name="RESET_PATH">The new process will start in its own folder and not the folder of the parent process.</const>
<const name="SHELL">Enables shell mode. On Unix systems, this means that a shell (usually BASH) will be used to launch the process.</const>
<const name="WAIT">This flag will cause the parent process to halt when the task is activated. Control is returned to the parent process once the child process terminates.</const>
<const name="VERBOSE">Enable verbose logging.</const>
<const name="WAIT">The parent process will halt when the task is running. Control is returned to the parent process once the child process terminates.</const>
</constants>

<constants lookup="TSTATE" comment="Indicates the state of a process.">
Expand Down Expand Up @@ -3062,7 +3061,7 @@ SetField(Object, FID_Statement|TSTR, "string");
<field name="Bottom" type="LONG">Bottom coordinate</field>
</struct>

<struct name="FRGB" comment="64-bit floating point RGB colour value.">
<struct name="FRGB" comment="32-bit floating point RGB colour components.">
<field name="Red" type="FLOAT">Red component value</field>
<field name="Green" type="FLOAT">Green component value</field>
<field name="Blue" type="FLOAT">Blue component value</field>
Expand Down
4 changes: 2 additions & 2 deletions docs/xml/modules/display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ Alpha = CFUnpackAlpha(Format,Colour)
<param type="DOUBLE" name="Value">The number to be scaled.</param>
</input>
<description>
<p>ScaleToDPI() is a convenience function for scaling any value to the active display's current DPI setting. The value that you provide must be fixed in relation to the system wide default of 96 DPI. If the display's DPI varies differs to that, your value will be scaled to match. For instance, an 8 point font at 96 DPI would be scaled to 20 points if the display was 240 DPI.</p>
<p>If the DPI of the display is unknown, your value will be returned unscaled.</p>
<p>ScaleToDPI() is a convenience function for scaling a value to the display's current DPI setting. The provided value must be relative to the system wide default of 96 DPI. If the display's DPI is not equal to 96, the value will be scaled to match. For instance, an 8 point font at 96 DPI would be scaled to 20 points if the display was 240 DPI.</p>
<p>If the DPI of the display is unknown, the value will be returned unscaled.</p>
</description>
<result type="DOUBLE">The scaled value is returned.</result>
</function>
Expand Down
12 changes: 2 additions & 10 deletions examples/gradients.fluid
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ function selectGradient(Text)
end
gradient.cX = '50%'
gradient.cY = '50%'
elseif Text == 'Conic' then
gradient.type = 'conic'
uiEvent = function(ev)
gradient.cX = (ev.x / gradientVP.width * 100) .. '%'
gradient.cY = (ev.y / gradientVP.height * 100) .. '%'
gradient.x2 = (ev.x / gradientVP.width * 100) .. '%'
gradient.y2 = (ev.y / gradientVP.height * 100) .. '%'
end
elseif Text == 'Diamond' then
gradient.type = 'diamond'
elseif (Text == 'Conic') or (Text == 'Diamond') then
gradient.type = Text
uiEvent = function(ev)
gradient.cX = (ev.x / gradientVP.width * 100) .. '%'
gradient.cY = (ev.y / gradientVP.height * 100) .. '%'
Expand Down
19 changes: 9 additions & 10 deletions include/parasol/modules/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,16 +675,15 @@ DEFINE_ENUM_FLAG_OPERATORS(RFD)

enum class TSF : ULONG {
NIL = 0,
FOREIGN = 0x00000001,
WAIT = 0x00000002,
RESET_PATH = 0x00000004,
PRIVILEGED = 0x00000008,
SHELL = 0x00000010,
LOG_ALL = 0x00000020,
QUIET = 0x00000040,
DETACHED = 0x00000080,
ATTACHED = 0x00000100,
PIPE = 0x00000200,
WAIT = 0x00000001,
RESET_PATH = 0x00000002,
PRIVILEGED = 0x00000004,
SHELL = 0x00000008,
VERBOSE = 0x00000010,
QUIET = 0x00000020,
DETACHED = 0x00000040,
ATTACHED = 0x00000080,
PIPE = 0x00000100,
};

DEFINE_ENUM_FLAG_OPERATORS(TSF)
Expand Down
2 changes: 1 addition & 1 deletion include/parasol/modules/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,6 @@ class objVectorGradient : public Object {
VGT Type; // Specifies the type of gradient (e.g. RADIAL, LINEAR)
VGF Flags; // Dimension flags are stored here.
VCS ColourSpace; // Defines the colour space to use when interpolating gradient colours.
LONG TotalStops; // Total number of stops defined in the Stops array.

// Action stubs

Expand Down Expand Up @@ -3966,6 +3965,7 @@ inline void SET_VECTOR_COLOUR(objVectorColour *Colour, DOUBLE Red, DOUBLE Green,
#define SVF_FEFUNCG 0xa284a6a3
#define SVF_FEFUNCB 0xa284a69e
#define SVF_FEFUNCA 0xa284a69d
#define SVF_FOCALPOINT 0xe03591b4
#define SVF_LIGHTING_COLOR 0x020fc127
#define SVF_LIGHTING_COLOUR 0x4407e6dc
#define SVF_LIMITINGCONEANGLE 0xbb90036e
Expand Down
2 changes: 2 additions & 0 deletions include/parasol/strings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ inline void camelcase(std::string &s) noexcept {
else if ((Wildcard[w] IS '|') and (w + 1 < Wildcard.size())) {
w++;
String = Original; // Restart the comparison
s = 0;
}
else {
if (Case) {
Expand All @@ -146,6 +147,7 @@ inline void camelcase(std::string &s) noexcept {

w = or_index + 1;
String = Original;
s = 0;
}
}

Expand Down
1 change: 1 addition & 0 deletions include/parasol/system/fields.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,4 +976,5 @@
#define FID_ResizeEvent 0xc404ebf9LL
#define FID_TabOrder 0xa10b2cb8LL
#define FID_TextFlags 0x1bce45f7LL
#define FID_TotalStops 0xc961c5a2LL

10 changes: 3 additions & 7 deletions src/core/classes/class_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ static ERR TASK_Expunge(extTask *);
static ERR TASK_Quit(extTask *);

static const FieldDef clFlags[] = {
{ "Foreign", TSF::FOREIGN },
{ "Wait", TSF::WAIT },
{ "Shell", TSF::SHELL },
{ "ResetPath", TSF::RESET_PATH },
{ "Privileged", TSF::PRIVILEGED },
{ "LogAll", TSF::LOG_ALL },
{ "LogAll", TSF::VERBOSE },
{ "Quiet", TSF::QUIET },
{ "Attached", TSF::ATTACHED },
{ "Detached", TSF::DETACHED },
Expand Down Expand Up @@ -625,8 +624,6 @@ static ERR TASK_Activate(extTask *Self)

Self->ReturnCodeSet = false;

if ((Self->Flags & TSF::FOREIGN) != TSF::NIL) Self->Flags |= TSF::SHELL;

if (!Self->Location) return log.warning(ERR::MissingPath);

if (!glJanitorActive) {
Expand Down Expand Up @@ -855,7 +852,7 @@ static ERR TASK_Activate(extTask *Self)
}
argslist[i+1] = NULL;

if ((Self->Flags & TSF::LOG_ALL) != TSF::NIL) {
if ((Self->Flags & TSF::VERBOSE) != TSF::NIL) {
for (i=1; argslist[i]; i++) {
log.msg("Arg %d: %s", i, argslist[i]);
}
Expand Down Expand Up @@ -1407,7 +1404,6 @@ static ERR TASK_Init(extTask *Self)
log.msg("Process Path: %s", Self->ProcessPath);
log.msg("Working Path: %s", Self->Path);
}
else if (Self->ProcessID) Self->Flags |= TSF::FOREIGN;

return ERR::Okay;
}
Expand Down Expand Up @@ -1762,7 +1758,7 @@ static ERR SET_ExitCallback(extTask *Self, FUNCTION *Value)
-FIELD-
InputCallback: This callback returns incoming data from STDIN.

The InputCallback field is available for use only when the task object represents the current process.
The InputCallback field is available to the active task object only (i.e. the current process).
The referenced function will be called when process receives data from STDIN. The callback must follow the
prototype `Function(*Task, APTR Data, LONG Size, ERR Status)`

Expand Down
19 changes: 9 additions & 10 deletions src/core/classes/class_task_def.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Auto-generated by idl-c.fluid

static const struct FieldDef clTaskFlags[] = {
{ "Foreign", 0x00000001 },
{ "Wait", 0x00000002 },
{ "ResetPath", 0x00000004 },
{ "Privileged", 0x00000008 },
{ "Shell", 0x00000010 },
{ "LogAll", 0x00000020 },
{ "Quiet", 0x00000040 },
{ "Detached", 0x00000080 },
{ "Attached", 0x00000100 },
{ "Pipe", 0x00000200 },
{ "Wait", 0x00000001 },
{ "ResetPath", 0x00000002 },
{ "Privileged", 0x00000004 },
{ "Shell", 0x00000008 },
{ "Verbose", 0x00000010 },
{ "Quiet", 0x00000020 },
{ "Detached", 0x00000040 },
{ "Attached", 0x00000080 },
{ "Pipe", 0x00000100 },
{ NULL, 0 }
};

Expand Down
15 changes: 7 additions & 8 deletions src/core/defs/core.fdl
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,14 @@ inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_
"ALWAYS_CALL: Always call this FD's handler prior to the process going to sleep.")

flags("TSF", { comment="Task flags" },
"FOREIGN: Set this flag when using the task object to execute a foreign process - that is an executable that does not use the Parasol API.",
"WAIT: This flag will cause the parent process to halt when the task is activated. Control is returned to the parent process once the child process terminates.",
"RESET_PATH: If set, the executed process will start in its own folder rather than the folder of the parent process.",
"PRIVILEGED: During a normal execution process, any privileges of the parent process will be dropped so that the child process runs unprivileged. This behaviour can be reversed if he PRIVILEGED flag is set, in which case the child process has the same privileges as the parent.",
"WAIT: The parent process will halt when the task is running. Control is returned to the parent process once the child process terminates.",
"RESET_PATH: The new process will start in its own folder and not the folder of the parent process.",
"PRIVILEGED: The child process will inherit the system privileges of its parent.",
"SHELL: Enables shell mode. On Unix systems, this means that a shell (usually BASH) will be used to launch the process.",
"LOG_ALL: Additional debug messages will be printed during normal usage of the task class when this flag is set.",
"QUIET: Setting this flag will divert all process output to `/dev/null` or the nearest equivalent for non-Unix systems.",
"DETACHED: Forces new task to be detached from the parent.",
"ATTACHED: Forces new task to be attached to the parent (child will close when parent closes).",
"VERBOSE: Enable verbose logging.",
"QUIET: Divert all process output to `/dev/null` or the nearest equivalent for non-Unix systems.",
"DETACHED: Forces the new process to be detached from the parent.",
"ATTACHED: Forces the new process to be attached to the parent (child will close when parent closes).",
"PIPE: Enable the output pipe to the launched process so that it can read data.")

hash("AHASH", "0x%s",
Expand Down
3 changes: 2 additions & 1 deletion src/core/defs/fields.fdl
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ header({ path="system/fields", copyright="Paul Manias © 1996-2024" }, function(
"Numeric",
"ResizeEvent",
"TabOrder",
"TextFlags"
"TextFlags",
"TotalStops"
)
end)
2 changes: 1 addition & 1 deletion src/core/idl.h

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/display/lib_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,11 @@ ERR SetHostOption(HOST Option, LARGE Value)
-FUNCTION-
ScaleToDPI: Scales a value to the active display's DPI.

ScaleToDPI() is a convenience function for scaling any value to the active display's current DPI setting. The value
that you provide must be fixed in relation to the system wide default of 96 DPI. If the display's DPI varies differs
to that, your value will be scaled to match. For instance, an 8 point font at 96 DPI would be scaled to 20 points if
the display was 240 DPI.
ScaleToDPI() is a convenience function for scaling a value to the display's current DPI setting. The provided value
must be relative to the system wide default of 96 DPI. If the display's DPI is not equal to 96, the value will be
scaled to match. For instance, an 8 point font at 96 DPI would be scaled to 20 points if the display was 240 DPI.

If the DPI of the display is unknown, your value will be returned unscaled.
If the DPI of the display is unknown, the value will be returned unscaled.

-INPUT-
double Value: The number to be scaled.
Expand Down
2 changes: 1 addition & 1 deletion src/fluid/fluid_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ static ERR FLUID_Init(objScript *Self)

if (Self->Path) {
if (!wildcmp("*.fluid|*.fb|*.lua", Self->Path)) {
log.trace("No support for path '%s'", Self->Path);
log.warning("No support for path '%s'", Self->Path);
return ERR::NoSupport;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/launcher/exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ ERR exec_source(CSTRING TargetFile, LONG ShowTime, const std::string Procedure)
else return ERR::Okay;
}
else {
printf("Script failed during processing. Use the --log-error option to examine the failure.\n");
return ERR::Failed;
printf("Script failed during processing: %s\nUse --log-warning or --log-api to examine the failure.\n", GetErrorMsg(error));
return error;
}
}
else {
printf("Failed to load / initialise the script.\n");
return ERR::Failed;
printf("Failed to load / initialise the script: %s\n", GetErrorMsg(error));
return error;
}
}
else {
Expand Down
Loading

0 comments on commit 059bdac

Please sign in to comment.