Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f18e3cb

Browse files
author
Fraser J. Gordon
committed
Merge branch 'feature-better-themes' of https://github.com/runrevfraser/livecode into HEAD
Conflicts: engine/Makefile.kernel engine/engine.xcodeproj/project.pbxproj engine/src/MCBlock.h engine/src/aclip.cpp engine/src/aclip.h engine/src/block.cpp engine/src/button.cpp engine/src/button.h engine/src/card.cpp engine/src/card.h engine/src/control.cpp engine/src/control.h engine/src/cpalette.cpp engine/src/cpalette.h engine/src/dispatch.cpp engine/src/dispatch.h engine/src/eps.cpp engine/src/eps.h engine/src/field.cpp engine/src/field.h engine/src/font.cpp engine/src/globals.cpp engine/src/graphic.cpp engine/src/graphic.h engine/src/group.cpp engine/src/group.h engine/src/image.cpp engine/src/image.h engine/src/linux.stubs engine/src/object.cpp engine/src/object.h engine/src/objectprops.cpp engine/src/osxflst.cpp engine/src/osxflst.h engine/src/player-legacy.cpp engine/src/player-legacy.h engine/src/player-platform.cpp engine/src/player-platform.h engine/src/scrolbar.cpp engine/src/scrolbar.h engine/src/stack.cpp engine/src/stack.h engine/src/vclip.cpp engine/src/vclip.h
2 parents 041406c + bb71d90 commit f18e3cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1818
-134
lines changed

engine/Makefile.kernel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ SOURCES=\
7777
exec-interface-vclip.cpp exec-keywords.cpp exec-legacy.cpp exec-dialog.cpp exec-strings-chunk.cpp \
7878
syntax.cpp \
7979
foundation-legacy.cpp legacy_spec.cpp \
80-
sysunxthreads.cpp, stacktile.cpp
80+
sysunxthreads.cpp, stacktile.cpp \
81+
linux-theme.cpp
8182

8283
linuxstubs.cpp: src/linux.stubs ../util/weak_stub_maker.pl
8384
# ../prebuilt/bin/Revolution.lnx "../tools/weak_stub_maker.lc" <./src/linux.stubs >./src/linuxstubs.cpp

engine/engine.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@
541541
766E3299180EE4ED00CF7FCF /* imagelist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 766E3295180EE4E000CF7FCF /* imagelist.cpp */; };
542542
766E329A180EE4EE00CF7FCF /* graphicscontext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 766E3293180EE4E000CF7FCF /* graphicscontext.cpp */; };
543543
766E329B180EE4EE00CF7FCF /* imagelist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 766E3295180EE4E000CF7FCF /* imagelist.cpp */; };
544+
72B67C511A0BBDF600BB2594 /* mac-theme.mm in Sources */ = {isa = PBXBuildFile; fileRef = 72B67C501A0BBDF600BB2594 /* mac-theme.mm */; };
544545
76CCAA7C19800BCD00C79271 /* mac-qt-recorder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 76CCAA7B198003B000C79271 /* mac-qt-recorder.mm */; };
545546
76CCAA7E1980152A00C79271 /* platform-recorder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76CCAA7D19800EFE00C79271 /* platform-recorder.cpp */; };
546547
76D47DE918030E50006F9102 /* exec-interface-field-chunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76D47DE81802FD03006F9102 /* exec-interface-field-chunk.cpp */; };
@@ -1719,6 +1720,9 @@
17191720
768D66A21762087500F203A3 /* mbliphonesensor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = mbliphonesensor.mm; path = src/mbliphonesensor.mm; sourceTree = "<group>"; };
17201721
768D66A31762087500F203A3 /* mbliphonestore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = mbliphonestore.mm; path = src/mbliphonestore.mm; sourceTree = "<group>"; };
17211722
768D66A41762087500F203A3 /* mbliphonetextmessaging.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = mbliphonetextmessaging.mm; path = src/mbliphonetextmessaging.mm; sourceTree = "<group>"; };
1723+
7269EC371A13D1DE000723DB /* linux-theme.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "linux-theme.cpp"; path = "src/linux-theme.cpp"; sourceTree = "<group>"; };
1724+
7269EC421A162199000723DB /* windows-theme.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "windows-theme.cpp"; path = "src/windows-theme.cpp"; sourceTree = "<group>"; };
1725+
72B67C501A0BBDF600BB2594 /* mac-theme.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "mac-theme.mm"; path = "src/mac-theme.mm"; sourceTree = "<group>"; };
17221726
76CCAA7B198003B000C79271 /* mac-qt-recorder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "mac-qt-recorder.mm"; path = "src/mac-qt-recorder.mm"; sourceTree = "<group>"; };
17231727
76CCAA7D19800EFE00C79271 /* platform-recorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "platform-recorder.cpp"; path = "src/platform-recorder.cpp"; sourceTree = "<group>"; };
17241728
76D47DE81802FD03006F9102 /* exec-interface-field-chunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "exec-interface-field-chunk.cpp"; path = "src/exec-interface-field-chunk.cpp"; sourceTree = "<group>"; };
@@ -2309,6 +2313,7 @@
23092313
76EF31A3181E7CCE00FAC195 /* osxcisupport.mm */,
23102314
76CCAA7B198003B000C79271 /* mac-qt-recorder.mm */,
23112315
4CF4B87F199E0C1C00E33AEE /* coretextlayout.mm */,
2316+
72B67C501A0BBDF600BB2594 /* mac-theme.mm */,
23122317
4D5880140B80A4F800200116 /* osxcoreimage.cpp */,
23132318
4D4F9E6613CDFB8100B9B15D /* osxfield.cpp */,
23142319
4D03C2160BC5803900026EA7 /* osxfiles.cpp */,
@@ -2366,6 +2371,7 @@
23662371
A04643F40BAAA63A0030A830 /* w32text.cpp */,
23672372
A04643F60BAAA63A0030A830 /* w32theme.cpp */,
23682373
4DAC56770D869D1600CE5BAF /* w32transfer.cpp */,
2374+
7269EC421A162199000723DB /* windows-theme.cpp */,
23692375
);
23702376
name = "Desktop - Windows";
23712377
sourceTree = "<group>";
@@ -2413,6 +2419,7 @@
24132419
4D77411A1226B930001C9150 /* lnxtransfer.h */,
24142420
4DFECFE413CEF2DB00288995 /* lnxprefix.h */,
24152421
4DFED11E13CEFC5400288995 /* lnxtheme.h */,
2422+
7269EC371A13D1DE000723DB /* linux-theme.cpp */,
24162423
);
24172424
name = "Desktop - Linux";
24182425
sourceTree = "<group>";
@@ -4296,6 +4303,7 @@
42964303
4DEE2AD50FDE42710009423C /* objectstream.cpp in Sources */,
42974304
4DEE2AD60FDE42710009423C /* objptr.cpp in Sources */,
42984305
4DEE2AD70FDE42710009423C /* opensslsocket.cpp in Sources */,
4306+
72B67C511A0BBDF600BB2594 /* mac-theme.mm in Sources */,
42994307
4DEE2AD80FDE42710009423C /* operator.cpp in Sources */,
43004308
4DEE2ADA0FDE42710009423C /* osxcoreimage.cpp in Sources */,
43014309
4DEE2AE40FDE42710009423C /* osxfiles.cpp in Sources */,

engine/kernel.vcproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,6 +3519,10 @@
35193519
RelativePath="src\w32transfer.h"
35203520
>
35213521
</File>
3522+
<File
3523+
RelativePath=".\src\windows-theme.cpp"
3524+
>
3525+
</File>
35223526
</Filter>
35233527
</Filter>
35243528
<Filter

engine/src/MCBlock.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,5 +412,11 @@ class MCBlock : public MCDLlist
412412
void SetTextStyleElement(MCExecContext& ctxt, MCNameRef p_index, bool p_value);
413413

414414
//////////
415+
416+
// FG-2014-11-11: [[ Better theming ]]
417+
// Sets up the colours on the DC for the given type of drawing
418+
void setcolorfornormaltext(MCDC*, MCColor*);
419+
void setcolorforhilite(MCDC*);
420+
void setcolorforselectedtext(MCDC*, MCColor*);
415421
};
416422
#endif

engine/src/aclip.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ void MCAudioClip::timer(MCNameRef mptr, MCParameter *params)
202202
delete this;
203203
}
204204
}
205-
#ifdef LEGACY_EXEC
206-
Exec_stat MCAudioClip::getprop_legacy(uint4 parid, Properties which, MCExecPoint &ep, Boolean effective)
205+
206+
#ifdef LEGACY_EXEC
207+
Exec_stat MCAudioClip::getprop_legacy(uint4 parid, Properties which, MCExecPoint &ep, Boolean effective, bool recursive)
207208
{
208209
switch (which)
209210
{
@@ -223,7 +224,7 @@ Exec_stat MCAudioClip::getprop_legacy(uint4 parid, Properties which, MCExecPoint
223224
break;
224225
#endif /* MCAudioClip::getprop */
225226
default:
226-
return MCObject::getprop_legacy(parid, which, ep, effective);
227+
return MCObject::getprop_legacy(parid, which, ep, effective, recursive);
227228
}
228229
return ES_NORMAL;
229230
}

engine/src/aclip.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ class MCAudioClip : public MCObject
8080
virtual void timer(MCNameRef mptr, MCParameter *params);
8181

8282
#ifdef LEGACY_EXEC
83-
virtual Exec_stat getprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
83+
virtual Exec_stat getprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective, bool recursive = false);
8484
virtual Exec_stat setprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
8585
#endif
8686

87-
8887
virtual Boolean del();
8988
virtual void paste(void);
9089

engine/src/block.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,7 @@ void MCBlock::draw(MCDC *dc, coord_t x, coord_t lx, coord_t cx, int2 y, findex_t
11771177
if (flags & F_HAS_BACK_COLOR)
11781178
dc->setbackground(*atts->backcolor);
11791179

1180-
if (t_foreground_color != NULL)
1181-
dc -> setforeground(*t_foreground_color);
1180+
setcolorfornormaltext(dc, t_foreground_color);
11821181

11831182
uint32_t t_style;
11841183
t_style = 0;
@@ -1292,11 +1291,13 @@ void MCBlock::draw(MCDC *dc, coord_t x, coord_t lx, coord_t cx, int2 y, findex_t
12921291
f->getforecolor(DI_HILITE, False, True, hc, t_pattern, x, y, dc, f);
12931292
if (hc.pixel == fc.pixel)
12941293
f->setforeground(dc, DI_BACK, False, True);
1294+
else
1295+
setcolorforselectedtext(dc, nil);
12951296
}
12961297
else
1297-
f->setforeground(dc, DI_BACK, False, True);
1298+
setcolorforselectedtext(dc, t_foreground_color);
12981299
}
1299-
1300+
13001301
// Draw the selected text.
13011302
// SN-2014-08-13: [[ Bug 13016 ]] Added a parameter for the left of the cell
13021303
drawstring(dc, x, lx, cx, y, m_index, m_size, (flags & F_HAS_BACK_COLOR) != 0, t_style);
@@ -2400,3 +2401,36 @@ MCBlock *MCBlock::GetPrevBlockVisualOrder()
24002401

24012402
return nil;
24022403
}
2404+
2405+
void MCBlock::setcolorfornormaltext(MCDC* dc, MCColor* p_color)
2406+
{
2407+
MCField* f = parent->getparent();
2408+
2409+
if (p_color != nil)
2410+
dc->setforeground(*p_color);
2411+
else if (flags & F_HAS_COLOR)
2412+
dc->setforeground(*atts -> color);
2413+
else
2414+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR, False, True);
2415+
}
2416+
2417+
void MCBlock::setcolorforhilite(MCDC* dc)
2418+
{
2419+
MCField* f = parent->getparent();
2420+
2421+
f->setforeground(dc, DI_PSEUDO_TEXT_BACKGROUND_SEL, False, True);
2422+
}
2423+
2424+
void MCBlock::setcolorforselectedtext(MCDC* dc, MCColor* p_color)
2425+
{
2426+
MCField* f = parent->getparent();
2427+
2428+
if (p_color != nil)
2429+
dc->setforeground(*p_color);
2430+
else if (flags & F_HAS_COLOR)
2431+
dc->setforeground(*atts -> color);
2432+
else if (!IsMacLF()) // TODO: if platform reverses selected text
2433+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR_SEL_BACK, False, True, true);
2434+
else
2435+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR_SEL_FORE, False, True, true);
2436+
}

engine/src/button.cpp

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ void MCButton::setrect(const MCRectangle &nrect)
16841684
}
16851685

16861686
#ifdef LEGACY_EXEC
1687-
Exec_stat MCButton::getprop_legacy(uint4 parid, Properties which, MCExecPoint& ep, Boolean effective)
1687+
Exec_stat MCButton::getprop_legacy(uint4 parid, Properties which, MCExecPoint& ep, Boolean effective, bool recursive)
16881688
{
16891689
uint2 fheight;
16901690
uint2 j = 0;
@@ -1962,7 +1962,7 @@ Exec_stat MCButton::getprop_legacy(uint4 parid, Properties which, MCExecPoint& e
19621962
break;
19631963
#endif /* MCButton::getprop */
19641964
default:
1965-
return MCControl::getprop_legacy(parid, which, ep, effective);
1965+
return MCControl::getprop_legacy(parid, which, ep, effective, recursive);
19661966
}
19671967
return ES_NORMAL;
19681968
}
@@ -4751,3 +4751,62 @@ IO_stat MCButton::load(IO_handle stream, uint32_t version)
47514751
}
47524752
return IO_NORMAL;
47534753
}
4754+
4755+
////////////////////////////////////////////////////////////////////////////////
4756+
4757+
MCPlatformControlType MCButton::getcontroltype()
4758+
{
4759+
MCPlatformControlType t_type;
4760+
t_type = kMCPlatformControlTypeButton;
4761+
if (getstyleint(flags) == F_MENU)
4762+
{
4763+
t_type = kMCPlatformControlTypeMenu;
4764+
switch (menumode)
4765+
{
4766+
case WM_POPUP:
4767+
t_type = kMCPlatformControlTypePopupMenu;
4768+
break;
4769+
4770+
case WM_OPTION:
4771+
t_type = kMCPlatformControlTypeOptionMenu;
4772+
break;
4773+
4774+
case WM_COMBO:
4775+
t_type = kMCPlatformControlTypeComboBox;
4776+
break;
4777+
4778+
case WM_PULLDOWN:
4779+
t_type = kMCPlatformControlTypePulldownMenu;
4780+
break;
4781+
4782+
default:
4783+
break;
4784+
}
4785+
}
4786+
else if (menucontrol != MENUCONTROL_NONE)
4787+
{
4788+
t_type = kMCPlatformControlTypeMenuItem;
4789+
}
4790+
4791+
return t_type;
4792+
}
4793+
4794+
MCPlatformControlPart MCButton::getcontrolsubpart()
4795+
{
4796+
return kMCPlatformControlPartNone;
4797+
}
4798+
4799+
MCPlatformControlState MCButton::getcontrolstate()
4800+
{
4801+
int t_state;
4802+
t_state = MCControl::getcontrolstate();
4803+
4804+
if (flags & F_DEFAULT)
4805+
t_state |= kMCPlatformControlStateDefault;
4806+
4807+
if (t_state & kMCPlatformControlStateMouseFocus
4808+
&& MCbuttonstate & 1)
4809+
t_state |= kMCPlatformControlStatePressed;
4810+
4811+
return MCPlatformControlState(t_state);
4812+
}

engine/src/button.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,12 @@ class MCButton : public MCControl
179179

180180
virtual uint2 gettransient() const;
181181
virtual void setrect(const MCRectangle &nrect);
182+
182183
#ifdef LEGACY_EXEC
183-
virtual Exec_stat getprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
184+
virtual Exec_stat getprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective, bool recursive = false);
184185
virtual Exec_stat setprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
185186
#endif
187+
186188
virtual void closemenu(Boolean kfocus, Boolean disarm);
187189

188190
// MW-2011-09-20: [[ Collision ]] Compute shape of button - will use mask of icon if possible.
@@ -472,5 +474,12 @@ class MCButton : public MCControl
472474
void trytochangetonative(void);
473475

474476
friend class ButtonMenuCallback;
477+
478+
protected:
479+
480+
// FG-2014-11-11: [[ Better theming ]] Fetch the control type/state for theming purposes
481+
virtual MCPlatformControlType getcontroltype();
482+
virtual MCPlatformControlPart getcontrolsubpart();
483+
virtual MCPlatformControlState getcontrolstate();
475484
};
476485
#endif

engine/src/buttondraw.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,17 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
138138
MCcurtheme -> drawmenuheaderbackground(dc, dirty, this))
139139
{
140140
t_themed_menu = true;
141-
dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
141+
//dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
142+
setforeground(dc, DI_PSEUDO_BUTTON_TEXT, False);
142143
}
143144
else if (menucontrol != MENUCONTROL_NONE && MCcurtheme != NULL &&
144145
MCcurtheme -> drawmenuitembackground(dc, dirty, this))
145146
{
146147
t_themed_menu = true;
147148
indicator = False;
148-
dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
149-
}
149+
//dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
150+
setforeground(dc, DI_PSEUDO_BUTTON_TEXT, False);
151+
}
150152
else
151153
{
152154
if (flags & F_OPAQUE && (MCcurtheme == NULL || !noback
@@ -342,6 +344,7 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
342344
}
343345

344346
if (flags & F_DISABLED)
347+
{
345348
if (MClook == LF_MOTIF)
346349
{
347350
setforeground(dc, DI_FORE, False);
@@ -354,15 +357,18 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
354357
}
355358
else
356359
setforeground(dc, DI_TOP, False);
360+
}
357361
else
358-
if (white && state & CS_KFOCUSED && !(state & CS_SUBMENU) ||
359-
isstdbtn && noback && (MCcurtheme == NULL || MCcurtheme->getthemeid() != LF_NATIVEWIN && MCcurtheme->getthemeid() != LF_NATIVEGTK) && state & CS_HILITED && !MCaqua ||
360-
MClook != LF_MOTIF && style == F_MENU && flags & F_OPAQUE && state & CS_ARMED && !(flags & F_SHOW_BORDER))
361-
setforeground(dc, DI_BACK, False, True);
362+
{
363+
if ((white && state & CS_KFOCUSED && !(state & CS_SUBMENU)) ||
364+
(isstdbtn && noback && (MCcurtheme == NULL || (MCcurtheme->getthemeid() != LF_NATIVEWIN && MCcurtheme->getthemeid() != LF_NATIVEGTK)) && state & CS_HILITED && !MCaqua) ||
365+
(MClook != LF_MOTIF && style == F_MENU && flags & F_OPAQUE && state & CS_ARMED && !(flags & F_SHOW_BORDER)))
366+
setforeground(dc, DI_PSEUDO_BUTTON_TEXT_SEL, False, True);
362367
else
363368
setforeground(dc, DI_FORE, (state & CS_HILITED && flags & F_HILITE_FILL
364-
|| state & CS_ARMED && flags & F_ARM_FILL) && flags & F_OPAQUE && (MClook != LF_WIN95 && !MCaqua
369+
|| state & CS_ARMED && flags & F_ARM_FILL) && flags & F_OPAQUE && ((MClook != LF_WIN95 && !MCaqua)
365370
|| style != F_STANDARD), False);
371+
}
366372
}
367373

368374
// MW-2009-06-14: We will assume (perhaps unwisely) that is 'opaque' is set

0 commit comments

Comments
 (0)