Skip to content

Commit f21337e

Browse files
Merge pull request livecode#2284 from runrevpanos/bugfix_player_colors
Bugfix player colors
2 parents 63bf2de + c289cce commit f21337e

8 files changed

Lines changed: 59 additions & 98 deletions

File tree

docs/notes/bugfix-12834.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [[Player]] enhancement set colour of player controller buttons using backcolor property

docs/notes/bugfix-13390.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [[Player]] foregroundColor and hiliteColor not saved with stack

docs/notes/bugfix-13391.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [[Player]] Make default foregroundColor a colour a colour other than black

docs/notes/feature-avfoundation_player.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
**What has changed?**
44

55
The player object until now used QuickTime/QTKit APIs for audio and video playback. Since both QuickTime and QTKit have been deprecated by Apple, we have updated the player to use the new AVFoundation API. AVFoundation does not provide a controller for multimedia playback until OSX 10.9 and their new control bar is also missing some of the features provided by the QTKIt controller, which required us to implement our own controller to ensure backward compatibility.
6-
We have added two new properties to the player object enabling you to customise the appearance of the controller:
6+
We have added three new properties to the player object enabling you to customise the appearance of the controller:
77

88
- The **hilitecolor** of a player is the color of the played area, the colour of the volume area, as well as the background color of a controller button when it is pressed.
99

1010
- The **forecolor** of a player is the color of the selected area. The selected area is the area between the selection handles.
1111

12+
- The **backcolor** of a player is the color of the controller icons (volume icon, play/pause icon, scrub back/scrub forward icon).
13+
1214
We have also added support for getting information about the download progress of a remote multimedia file:
1315

1416
- The **loadedtime** of a player is the time up to which the movie can be played. The download progress is also displayed on the controller well.

engine/src/lextable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,6 @@ LT factor_table[] =
14261426
{"securitycategories", TT_PROPERTY, P_SECURITY_CATEGORIES},
14271427
{"securitypermissions", TT_PROPERTY, P_SECURITY_PERMISSIONS},
14281428
{"selected", TT_PROPERTY, P_SELECTED},
1429-
//{"selectedareacolor", TT_PROPERTY, P_SELECTED_AREA_COLOR},
14301429
{"selectedbutton", TT_FUNCTION, F_SELECTED_BUTTON},
14311430
{"selectedchunk", TT_FUNCTION, F_SELECTED_CHUNK},
14321431
{"selectedcolor", TT_PROPERTY, P_SELECTED_COLOR},

engine/src/player-platform.cpp

Lines changed: 50 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,9 @@ static const char *ppmediastrings[] =
8787

8888

8989
static MCColor controllercolors[] = {
90-
{0, 0x8000, 0x8000, 0x8000, 0, 0}, /* 50% gray */
91-
92-
{0, 0xCCCC, 0xCCCC, 0xCCCC, 0, 0}, /* 20% gray -- 80% white */
93-
94-
{0, 0xa8a8, 0x0101, 0xffff, 0, 0}, /* Purple */
95-
96-
//{0, 0xcccc, 0x9999, 0xffff, 0, 0}, /* Magenda */
97-
98-
{0, 0x2b2b, 0x2b2b, 0x2b2b, 0, 0}, /* gray */
99-
100-
{0, 0x2222, 0x2222, 0x2222, 0, 0}, /* dark gray */
101-
10290

91+
{0, 0x2222, 0x2222, 0x2222, 0, 0}, /* dark gray */
92+
{0, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0}, /* white */
10393
};
10494

10595
inline MCGColor MCGColorMakeRGBA(MCGFloat p_red, MCGFloat p_green, MCGFloat p_blue, MCGFloat p_alpha)
@@ -205,7 +195,7 @@ class MCPlayerVolumePopup: public MCStack
205195
{
206196
MCRectangle t_volume_bar_rect = dirty;
207197
MCGContextAddRectangle(p_gcontext, MCRectangleToMCGRectangle(t_volume_bar_rect));
208-
MCGContextSetFillRGBAColor(p_gcontext, (m_player -> getcontrollerbackcolor() . red / 255.0) / 257.0, (m_player -> getcontrollerbackcolor() . green / 255.0) / 257.0, (m_player -> getcontrollerbackcolor() . blue / 255.0) / 257.0, 1.0f);
198+
MCGContextSetFillRGBAColor(p_gcontext, (m_player -> getcontrollerfontcolor() . red / 255.0) / 257.0, (m_player -> getcontrollerfontcolor() . green / 255.0) / 257.0, (m_player -> getcontrollerfontcolor() . blue / 255.0) / 257.0, 1.0f);
209199
MCGContextFill(p_gcontext);
210200
}
211201

@@ -835,21 +825,6 @@ MCPlayer::MCPlayer()
835825
lasttime = 0;
836826
starttime = endtime = MAXUINT4;
837827

838-
// Default controller back area color (darkgray)
839-
controllerbackcolor . red = 34 * 257;
840-
controllerbackcolor . green = 34 * 257;
841-
controllerbackcolor . blue = 34 * 257;
842-
843-
// Default controller played area color (purple)
844-
controllermaincolor . red = 168 * 257;
845-
controllermaincolor . green = 1 * 257;
846-
controllermaincolor . blue = 255 * 257;
847-
848-
// Default controller selected area color (some gray)
849-
selectedareacolor . red = 43 * 257;
850-
selectedareacolor . green = 43 * 257;
851-
selectedareacolor . blue = 43 * 257;
852-
853828
disposable = istmpfile = False;
854829
userCallbackStr = NULL;
855830
formattedwidth = formattedheight = 0;
@@ -889,9 +864,6 @@ MCPlayer::MCPlayer(const MCPlayer &sref) : MCControl(sref)
889864
rate = sref.rate;
890865
lasttime = sref.lasttime;
891866
starttime = sref.starttime;
892-
controllerbackcolor = sref.controllerbackcolor;
893-
controllermaincolor = sref.controllermaincolor;
894-
selectedareacolor = sref.selectedareacolor;
895867
endtime = sref.endtime;
896868
disposable = istmpfile = False;
897869
userCallbackStr = strclone(sref.userCallbackStr);
@@ -1288,12 +1260,6 @@ Exec_stat MCPlayer::getprop(uint4 parid, Properties which, MCExecPoint &ep, Bool
12881260
case P_PLAY_SELECTION:
12891261
ep.setboolean(getflag(F_PLAY_SELECTION));
12901262
break;
1291-
case P_HILITE_COLOR:
1292-
ep.setcolor(controllermaincolor);
1293-
break;
1294-
case P_FORE_COLOR:
1295-
ep.setcolor(selectedareacolor);
1296-
break;
12971263
case P_SHOW_SELECTION:
12981264
ep.setboolean(getflag(F_SHOW_SELECTION));
12991265
break;
@@ -1647,40 +1613,6 @@ Exec_stat MCPlayer::setprop(uint4 parid, Properties p, MCExecPoint &ep, Boolean
16471613
if (dirty)
16481614
playselection((flags & F_PLAY_SELECTION) != 0);
16491615
break;
1650-
case P_FORE_COLOR:
1651-
{
1652-
MCColor t_color;
1653-
char *t_colorname = NULL;
1654-
if (!MCscreen->parsecolor(data, &t_color, &t_colorname))
1655-
{
1656-
MCeerror->add
1657-
(EE_COLOR_BADSELECTEDCOLOR, 0, 0, data);
1658-
return ES_ERROR;
1659-
}
1660-
if (t_colorname != NULL)
1661-
delete t_colorname;
1662-
selectedareacolor = t_color;
1663-
dirty = True;
1664-
}
1665-
break;
1666-
1667-
case P_HILITE_COLOR:
1668-
{
1669-
MCColor t_color;
1670-
char *t_colorname = NULL;
1671-
if (!MCscreen->parsecolor(data, &t_color, &t_colorname))
1672-
{
1673-
MCeerror->add
1674-
(EE_COLOR_BADSELECTEDCOLOR, 0, 0, data);
1675-
return ES_ERROR;
1676-
}
1677-
if (t_colorname != NULL)
1678-
delete t_colorname;
1679-
controllermaincolor = t_color;
1680-
dirty = True;
1681-
}
1682-
break;
1683-
16841616
case P_SHOW_SELECTION: //means make movie editable
16851617
if (!MCU_matchflags(data, flags, F_SHOW_SELECTION, dirty))
16861618
{
@@ -2469,14 +2401,43 @@ uint2 MCPlayer::getloudness()
24692401
return loudness;
24702402
}
24712403

2472-
MCColor MCPlayer::getcontrollerbackcolor()
2404+
MCColor MCPlayer::getcontrollerfontcolor()
24732405
{
2474-
return controllerbackcolor;
2406+
// Default controller font color (darkgray)
2407+
return controllercolors[0];
2408+
}
2409+
2410+
// PM-2014-09-16: [[ Bug 12834 ]] Allow setting the color of controller icons (backcolor property of player)
2411+
MCColor MCPlayer::getcontrollericoncolor()
2412+
{
2413+
uint2 i;
2414+
if (getcindex(DI_BACK, i))
2415+
return colors[i];
2416+
2417+
// Default controller icons color (white)
2418+
return controllercolors[1];
24752419
}
24762420

2421+
// PM-2014-09-16: [[ Bug 13390 ]] use the MCObject colors list since we are using the standard color prop names, so no extra stuff needs to be saved
24772422
MCColor MCPlayer::getcontrollermaincolor()
24782423
{
2479-
return controllermaincolor;
2424+
uint2 i;
2425+
if (getcindex(DI_HILITE, i))
2426+
return colors[i];
2427+
2428+
// Default controller played area color (platform default - light blue)
2429+
return MChilitecolor;
2430+
}
2431+
2432+
// PM-2014-09-16: [[ Bug 13391 ]] Changed default forecolor
2433+
MCColor MCPlayer::getcontrollerselectedareacolor()
2434+
{
2435+
uint2 i;
2436+
if (getcindex(DI_FORE, i))
2437+
return colors[i];
2438+
2439+
// Default controller selected area color (platform default - light gray)
2440+
return MCselectioncolor;
24802441
}
24812442

24822443
void MCPlayer::updateloudness(int2 newloudness)
@@ -2923,7 +2884,7 @@ void MCPlayer::drawcontroller(MCDC *dc)
29232884

29242885
// SN-2014-08-25: [[ Bug 13187 ]] Fill up the controller background color after clipping
29252886
MCGContextAddRectangle(t_gcontext, MCRectangleToMCGRectangle(t_rect));
2926-
MCGContextSetFillRGBAColor(t_gcontext, (controllerbackcolor . red / 255.0) / 257.0, (controllerbackcolor . green / 255.0) / 257.0, (controllerbackcolor . blue / 255.0) / 257.0, 1.0f);
2887+
MCGContextSetFillRGBAColor(t_gcontext, (getcontrollerfontcolor() . red / 255.0) / 257.0, (getcontrollerfontcolor() . green / 255.0) / 257.0, (getcontrollerfontcolor() . blue / 255.0) / 257.0, 1.0f);
29272888
MCGContextFill(t_gcontext);
29282889

29292890
drawControllerVolumeButton(t_gcontext);
@@ -2967,11 +2928,11 @@ void MCPlayer::drawControllerVolumeButton(MCGContextRef p_gcontext)
29672928
if (m_show_volume)
29682929
{
29692930
MCGContextAddRectangle(p_gcontext, MCRectangleToMCGRectangle(t_volume_rect));
2970-
MCGContextSetFillRGBAColor(p_gcontext, (controllermaincolor . red / 255.0) / 257.0, (controllermaincolor . green / 255.0) / 257.0, (controllermaincolor . blue / 255.0) / 257.0, 1.0f);
2931+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollermaincolor() . red / 255.0) / 257.0, (getcontrollermaincolor() . green / 255.0) / 257.0, (getcontrollermaincolor() . blue / 255.0) / 257.0, 1.0f);
29712932
MCGContextFill(p_gcontext);
29722933
}
29732934

2974-
MCGContextSetFillRGBAColor(p_gcontext, 257 / 257.0, 257 / 257.0, 257 / 257.0, 1.0f); // WHITE
2935+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollericoncolor() . red / 255) / 257.0, (getcontrollericoncolor() . green / 255) / 257.0, (getcontrollericoncolor() . blue / 255) / 257.0, 1.0f);
29752936

29762937
MCGContextSetShouldAntialias(p_gcontext, true);
29772938

@@ -3003,7 +2964,8 @@ void MCPlayer::drawControllerVolumeButton(MCGContextRef p_gcontext)
30032964
MCGContextLineTo(p_gcontext, MCRectangleScalePoints(t_volume_rect, 0.8 , 0.7));
30042965
}
30052966

3006-
MCGContextSetStrokeRGBAColor(p_gcontext, 257 / 257.0, 257 / 257.0, 257 / 257.0, 1.0f); // WHITE
2967+
MCGContextSetStrokeRGBAColor(p_gcontext, (getcontrollericoncolor() . red / 255) / 257.0, (getcontrollericoncolor() . green / 255) / 257.0, (getcontrollericoncolor() . blue / 255) / 257.0, 1.0f);
2968+
30072969
MCGContextSetStrokeWidth(p_gcontext, t_volume_rect . width / 20.0 );
30082970
MCGContextStroke(p_gcontext);
30092971
}
@@ -3035,7 +2997,7 @@ void MCPlayer::drawControllerPlayPauseButton(MCGContextRef p_gcontext)
30352997

30362998
}
30372999

3038-
MCGContextSetFillRGBAColor(p_gcontext, 257 / 257.0, 257 / 257.0, 257 / 257.0, 1.0f); // WHITE
3000+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollericoncolor() . red / 255) / 257.0, (getcontrollericoncolor() . green / 255) / 257.0, (getcontrollericoncolor() . blue / 255) / 257.0, 1.0f);
30393001
MCGContextFill(p_gcontext);
30403002
}
30413003

@@ -3171,8 +3133,7 @@ void MCPlayer::drawControllerSelectionStartButton(MCGContextRef p_gcontext)
31713133
MCGContextLineTo(p_gcontext, MCRectangleScalePoints(t_drawn_selection_start_rect, 0.3, 0.88));
31723134
MCGContextCloseSubpath(p_gcontext);
31733135

3174-
3175-
MCGContextSetFillRGBAColor(p_gcontext, 257 / 257.0, 257 / 257.0, 257 / 257.0, 1.0f); // WHITE
3136+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollericoncolor() . red / 255) / 257.0, (getcontrollericoncolor() . green / 255) / 257.0, (getcontrollericoncolor() . blue / 255) / 257.0, 1.0f);
31763137
MCGContextFill(p_gcontext);
31773138
}
31783139

@@ -3201,9 +3162,8 @@ void MCPlayer::drawControllerSelectionFinishButton(MCGContextRef p_gcontext)
32013162
MCGContextLineTo(p_gcontext, MCRectangleScalePoints(t_drawn_selection_finish_rect, 0.3, 0.88));
32023163
MCGContextCloseSubpath(p_gcontext);
32033164

3204-
MCGContextSetFillRGBAColor(p_gcontext, 257 / 257.0, 257 / 257.0, 257 / 257.0, 1.0f); // WHITE
3165+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollericoncolor() . red / 255) / 257.0, (getcontrollericoncolor() . green / 255) / 257.0, (getcontrollericoncolor() . blue / 255) / 257.0, 1.0f);
32053166
MCGContextFill(p_gcontext);
3206-
32073167
}
32083168

32093169
void MCPlayer::drawControllerScrubForwardButton(MCGContextRef p_gcontext)
@@ -3215,7 +3175,7 @@ void MCPlayer::drawControllerScrubForwardButton(MCGContextRef p_gcontext)
32153175
if (m_scrub_forward_is_pressed)
32163176
{
32173177
MCGContextAddRectangle(p_gcontext, MCRectangleToMCGRectangle(t_scrub_forward_rect));
3218-
MCGContextSetFillRGBAColor(p_gcontext, (controllermaincolor . red / 255.0) / 257.0, (controllermaincolor . green / 255.0) / 257.0, (controllermaincolor . blue / 255.0) / 257.0, 1.0f);
3178+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollermaincolor() . red / 255.0) / 257.0, (getcontrollermaincolor() . green / 255.0) / 257.0, (getcontrollermaincolor() . blue / 255.0) / 257.0, 1.0f);
32193179
MCGContextFill(p_gcontext);
32203180
}
32213181

@@ -3230,8 +3190,8 @@ void MCPlayer::drawControllerScrubForwardButton(MCGContextRef p_gcontext)
32303190
MCGContextLineTo(p_gcontext, MCRectangleScalePoints(t_scrub_forward_rect, 0.55, 0.7));
32313191
MCGContextLineTo(p_gcontext, MCRectangleScalePoints(t_scrub_forward_rect, 0.75, 0.5));
32323192
MCGContextCloseSubpath(p_gcontext);
3233-
3234-
MCGContextSetFillRGBAColor(p_gcontext, 257 / 257.0, 257 / 257.0, 257 / 257.0, 1.0f); // WHITE
3193+
3194+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollericoncolor() . red / 255) / 257.0, (getcontrollericoncolor() . green / 255) / 257.0, (getcontrollericoncolor() . blue / 255) / 257.0, 1.0f);
32353195
MCGContextFill(p_gcontext);
32363196
}
32373197

@@ -3244,7 +3204,7 @@ void MCPlayer::drawControllerScrubBackButton(MCGContextRef p_gcontext)
32443204
if (m_scrub_back_is_pressed)
32453205
{
32463206
MCGContextAddRectangle(p_gcontext, MCRectangleToMCGRectangle(t_scrub_back_rect));
3247-
MCGContextSetFillRGBAColor(p_gcontext, (controllermaincolor . red / 255.0) / 257.0, (controllermaincolor . green / 255.0) / 257.0, (controllermaincolor . blue / 255.0) / 257.0, 1.0f);
3207+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollermaincolor() . red / 255.0) / 257.0, (getcontrollermaincolor() . green / 255.0) / 257.0, (getcontrollermaincolor() . blue / 255.0) / 257.0, 1.0f);
32483208
MCGContextFill(p_gcontext);
32493209
}
32503210

@@ -3260,7 +3220,7 @@ void MCPlayer::drawControllerScrubBackButton(MCGContextRef p_gcontext)
32603220
MCGContextAddRectangle(p_gcontext, t_grect);
32613221
MCGContextCloseSubpath(p_gcontext);
32623222

3263-
MCGContextSetFillRGBAColor(p_gcontext, 257 / 257.0, 257 / 257.0, 257 / 257.0, 1.0f); // WHITE
3223+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollericoncolor() . red / 255) / 257.0, (getcontrollericoncolor() . green / 255) / 257.0, (getcontrollericoncolor() . blue / 255) / 257.0, 1.0f);
32643224
MCGContextFill(p_gcontext);
32653225
}
32663226

@@ -3273,7 +3233,7 @@ void MCPlayer::drawControllerSelectedAreaButton(MCGContextRef p_gcontext)
32733233
t_drawn_selected_area . height = CONTROLLER_HEIGHT / 7;
32743234

32753235
MCGContextAddRectangle(p_gcontext, MCRectangleToMCGRectangle(t_drawn_selected_area));
3276-
MCGContextSetFillRGBAColor(p_gcontext, (selectedareacolor . red / 255.0) / 257.0, (selectedareacolor . green / 255.0) / 257.0, (selectedareacolor . blue / 255.0) / 257.0, 1.0f);
3236+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollerselectedareacolor() . red / 255.0) / 257.0, (getcontrollerselectedareacolor() . green / 255.0) / 257.0, (getcontrollerselectedareacolor() . blue / 255.0) / 257.0, 1.0f);
32773237
MCGContextFill(p_gcontext);
32783238
}
32793239

@@ -3286,8 +3246,7 @@ void MCPlayer::drawControllerPlayedAreaButton(MCGContextRef p_gcontext)
32863246
t_drawn_played_area . height = CONTROLLER_HEIGHT / 7;
32873247
t_drawn_played_area . x--;
32883248

3289-
3290-
MCGContextSetFillRGBAColor(p_gcontext, (controllermaincolor . red / 255.0) / 257.0, (controllermaincolor . green / 255.0) / 257.0, (controllermaincolor . blue / 255.0) / 257.0, 1.0f);
3249+
MCGContextSetFillRGBAColor(p_gcontext, (getcontrollermaincolor() . red / 255.0) / 257.0, (getcontrollermaincolor() . green / 255.0) / 257.0, (getcontrollermaincolor() . blue / 255.0) / 257.0, 1.0f);
32913250

32923251
MCGRectangle t_rounded_rect = MCRectangleToMCGRectangle(t_drawn_played_area);
32933252
MCGContextAddRoundedRectangle(p_gcontext, t_rounded_rect, MCGSizeMake(30, 30));

engine/src/player-platform.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ class MCPlayer : public MCControl
6767
real8 rate;
6868
uint4 starttime;
6969
uint4 endtime;
70-
MCColor controllerbackcolor;
71-
MCColor controllermaincolor;
72-
MCColor selectedareacolor;
7370
char *userCallbackStr; //string contains user movie callbacks
7471
uint2 formattedwidth;
7572
uint2 formattedheight;
@@ -164,7 +161,9 @@ class MCPlayer : public MCControl
164161
uint2 getloudness();
165162
void updateloudness(int2 newloudness);
166163
MCColor getcontrollermaincolor();
167-
MCColor getcontrollerbackcolor();
164+
MCColor getcontrollericoncolor();
165+
MCColor getcontrollerfontcolor();
166+
MCColor getcontrollerselectedareacolor();
168167
void setloudness();
169168
void gettracks(MCExecPoint &ep);
170169
void getenabledtracks(MCExecPoint &ep);

engine/src/props.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ static PropList playerprops[] =
602602
{"playRate", P_PLAY_RATE},
603603
{"playSelection", P_PLAY_SELECTION},
604604
{"rect", P_RECTANGLE},
605-
//{"selectedareacolor", P_SELECTED_AREA_COLOR},
606605
{"shadowColor", P_SHADOW_COLOR},
607606
{"shadowPattern", P_SHADOW_PATTERN},
608607
{"shadowOffset", P_SHADOW_OFFSET},

0 commit comments

Comments
 (0)