Skip to content

Commit be0c323

Browse files
author
Timothy Place
committed
min.progress: new example to demonstrate object box progress display ala stretch~.
1 parent 566e6e4 commit be0c323

File tree

5 files changed

+234
-1
lines changed

5 files changed

+234
-1
lines changed

docs/min.progress.maxref.xml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='yes'?>
2+
3+
4+
<!-- DO NOT EDIT THIS FILE ... YOU WILL LOSE YOUR WORK -->
5+
6+
7+
<c74object name='min.progress' category='interface'>
8+
9+
<digest>Demonstrate display of a progress bar</digest>
10+
<description>Demonstrate display of a progress bar. </description>
11+
12+
13+
<!--METADATA-->
14+
15+
<metadatalist>
16+
<metadata name='author'>Cycling '74 </metadata>
17+
<metadata name='tag'>interface</metadata>
18+
</metadatalist>
19+
20+
21+
<!--ARGUMENTS-->
22+
23+
<objarglist>
24+
25+
</objarglist>
26+
27+
28+
<!--MESSAGES-->
29+
30+
<methodlist>
31+
32+
<method name='bang'>
33+
<digest>Start process</digest>
34+
<description>Start process. </description>
35+
</method>
36+
37+
</methodlist>
38+
39+
40+
<!--ATTRIBUTES-->
41+
42+
<attributelist>
43+
44+
<attribute name='duration' get='1' set='1' type='float64' size='1' >
45+
<digest>Duration of the process</digest>
46+
<description>Duration of the process. </description>
47+
</attribute>
48+
49+
</attributelist>
50+
51+
52+
<!--RELATED-->
53+
54+
<seealsolist>
55+
<seealso name='stretch~' />
56+
</seealsolist>
57+
58+
59+
</c74object>

help/min.progress.maxhelp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"patcher" : {
3+
"fileversion" : 1,
4+
"appversion" : {
5+
"major" : 8,
6+
"minor" : 1,
7+
"revision" : 5,
8+
"architecture" : "x64",
9+
"modernui" : 1
10+
}
11+
,
12+
"classnamespace" : "box",
13+
"rect" : [ 59.0, 104.0, 640.0, 480.0 ],
14+
"bglocked" : 0,
15+
"openinpresentation" : 0,
16+
"default_fontsize" : 12.0,
17+
"default_fontface" : 0,
18+
"default_fontname" : "Arial",
19+
"gridonopen" : 1,
20+
"gridsize" : [ 15.0, 15.0 ],
21+
"gridsnaponopen" : 1,
22+
"objectsnaponopen" : 1,
23+
"statusbarvisible" : 2,
24+
"toolbarvisible" : 1,
25+
"lefttoolbarpinned" : 0,
26+
"toptoolbarpinned" : 0,
27+
"righttoolbarpinned" : 0,
28+
"bottomtoolbarpinned" : 0,
29+
"toolbars_unpinned_last_save" : 0,
30+
"tallnewobj" : 0,
31+
"boxanimatetime" : 200,
32+
"enablehscroll" : 1,
33+
"enablevscroll" : 1,
34+
"devicewidth" : 0.0,
35+
"description" : "",
36+
"digest" : "",
37+
"tags" : "",
38+
"style" : "",
39+
"subpatcher_template" : "",
40+
"assistshowspatchername" : 0,
41+
"boxes" : [ {
42+
"box" : {
43+
"id" : "obj-3",
44+
"maxclass" : "button",
45+
"numinlets" : 1,
46+
"numoutlets" : 1,
47+
"outlettype" : [ "bang" ],
48+
"parameter_enable" : 0,
49+
"patching_rect" : [ 245.0, 138.0, 24.0, 24.0 ]
50+
}
51+
52+
}
53+
, {
54+
"box" : {
55+
"id" : "obj-1",
56+
"maxclass" : "newobj",
57+
"numinlets" : 1,
58+
"numoutlets" : 0,
59+
"patching_rect" : [ 274.0, 193.0, 78.0, 22.0 ],
60+
"text" : "min.progress"
61+
}
62+
63+
}
64+
],
65+
"lines" : [ {
66+
"patchline" : {
67+
"destination" : [ "obj-1", 0 ],
68+
"source" : [ "obj-3", 0 ]
69+
}
70+
71+
}
72+
],
73+
"dependency_cache" : [ {
74+
"name" : "min.progress.mxo",
75+
"type" : "iLaX"
76+
}
77+
],
78+
"autosave" : 0
79+
}
80+
81+
}

source/min-api

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2018 The Min-DevKit Authors. All rights reserved.
2+
# Use of this source code is governed by the MIT License found in the License.md file.
3+
4+
cmake_minimum_required(VERSION 3.0)
5+
6+
set(C74_MIN_API_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../min-api)
7+
include(${C74_MIN_API_DIR}/script/min-pretarget.cmake)
8+
9+
10+
#############################################################
11+
# MAX EXTERNAL
12+
#############################################################
13+
14+
15+
include_directories(
16+
"${C74_INCLUDES}"
17+
)
18+
19+
20+
set( SOURCE_FILES
21+
${PROJECT_NAME}.cpp
22+
)
23+
24+
25+
add_library(
26+
${PROJECT_NAME}
27+
MODULE
28+
${SOURCE_FILES}
29+
)
30+
31+
32+
include(${C74_MIN_API_DIR}/script/min-posttarget.cmake)
33+
34+
35+
#############################################################
36+
# UNIT TEST
37+
#############################################################
38+
39+
include(${C74_MIN_API_DIR}/test/min-object-unittest.cmake)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/// @file
2+
/// @ingroup minexamples
3+
/// @copyright Copyright 2020 The Min-DevKit Authors. All rights reserved.
4+
/// @license Use of this source code is governed by the MIT License found in the License.md file.
5+
6+
#include "c74_min.h"
7+
8+
using namespace c74::min;
9+
10+
class progress : public object<progress> {
11+
private:
12+
number m_current_progress {};
13+
number m_stepsize {};
14+
15+
public:
16+
MIN_DESCRIPTION { "Demonstrate display of a progress bar." };
17+
MIN_TAGS { "interface" };
18+
MIN_AUTHOR { "Cycling '74" };
19+
MIN_RELATED { "stretch~" };
20+
21+
inlet<> m_inlet { this, "(list) values to convolve" };
22+
23+
24+
attribute<number> m_duration { this, "duration", 3000.0, description {"Duration of the process."} };
25+
26+
27+
message<> m_bang { this, "bang", "Start process.",
28+
MIN_FUNCTION {
29+
m_current_progress = 0.0;
30+
m_stepsize = 1.0 / m_duration;
31+
32+
auto b = box();
33+
b("startprogress", &m_current_progress);
34+
35+
m_timer.delay(1.0);
36+
return {};
37+
}
38+
};
39+
40+
41+
timer<timer_options::defer_delivery> m_timer { this, MIN_FUNCTION {
42+
if (m_current_progress >= 1.0) {
43+
auto b = box();
44+
b("stopprogress");
45+
}
46+
else {
47+
m_current_progress += m_stepsize;
48+
m_timer.delay(1.0);
49+
}
50+
return {};
51+
}};
52+
};
53+
54+
MIN_EXTERNAL(progress);

0 commit comments

Comments
 (0)