Tk Source Code

Check-in [569afaba]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Made PushButtons display correctly in pressed state.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | bug-0d63621b6c
Files: files | file ages | folders
SHA3-256: 569afaba3ec9f5d63e33b82822829ca803176fb594501d40167d075f316cb82a
User & Date: culler 2019-03-17 03:20:41.101
Context
2019-03-17
14:13
Fixed error in height computation for BevelButtons. check-in: a8b91a2d user: culler tags: bug-0d63621b6c
03:20
Made PushButtons display correctly in pressed state. check-in: 569afaba user: culler tags: bug-0d63621b6c
2019-03-16
03:55
Fixed a logic error with selected disabled CheckBoxes and RadioButtons. check-in: 5aa31716 user: culler tags: bug-0d63621b6c
Changes
Unified Diff Ignore Whitespace Patch
Changes to macosx/ttkMacOSXTheme.c.
383
384
385
386
387
388
389




390
391
392
393
394
395
396
397
398
399
400

401
402
403
404
405
406
407
    FillButtonBackground(context, bounds, 5);

    /*
     * Fill the button face with the appropriate color.
     */

    bounds = CGRectInset(bounds, 1, 1);




    if (state & TTK_STATE_DISABLED) {
	faceColor = [NSColor colorWithColorSpace: deviceRGB
			     components: darkDisabledButtonFace
				  count: 4];
    } else {
	faceColor = [NSColor colorWithColorSpace: deviceRGB
				 components: darkButtonFace
				      count: 4];
    }
    SolidFillButtonFace(context, bounds, 4, faceColor);


    /*
     * If this is a popup, draw the arrow button.
     */

    if (kind == kThemePopupButton) {
	CGFloat x, y;
	CGRect arrowBounds = bounds;







>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
>







383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
    FillButtonBackground(context, bounds, 5);

    /*
     * Fill the button face with the appropriate color.
     */

    bounds = CGRectInset(bounds, 1, 1);
    if (kind == kThemePushButton && (state & TTK_STATE_PRESSED)) {
	GradientFillButtonFace(context, bounds, 4,
				   darkSelectedGradient, 2);
    } else {
	if (state & TTK_STATE_DISABLED) {
	    faceColor = [NSColor colorWithColorSpace: deviceRGB
					  components: darkDisabledButtonFace
					       count: 4];
	} else {
	    faceColor = [NSColor colorWithColorSpace: deviceRGB
					  components: darkButtonFace
					       count: 4];
	}
	SolidFillButtonFace(context, bounds, 4, faceColor);
    }
	
    /*
     * If this is a popup, draw the arrow button.
     */

    if (kind == kThemePopupButton) {
	CGFloat x, y;
	CGRect arrowBounds = bounds;
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
    { kThemeButtonMixed, TTK_STATE_ALTERNATE, 0 },
    { kThemeButtonOn, TTK_STATE_SELECTED, 0 },
    { kThemeButtonOff, 0, 0 }
/* Others: kThemeDisclosureRight, kThemeDisclosureDown, kThemeDisclosureLeft */
};

static Ttk_StateTable ButtonAdornmentTable[] = {
    { kThemeAdornmentDefault| kThemeAdornmentFocus,
	TTK_STATE_ALTERNATE| TTK_STATE_FOCUS, 0 },
    { kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0 },
    { kThemeAdornmentFocus, TTK_STATE_FOCUS, 0 },
    { kThemeAdornmentNone, 0, 0 }
};

/*
 * computeButtonDrawInfo --
 *    Fill in an appearance manager HIThemeButtonDrawInfo record.
 */

static inline HIThemeButtonDrawInfo computeButtonDrawInfo(
    ThemeButtonParams *params,
    Ttk_State state,
    Tk_Window tkwin)
{
    /*
     *  See ButtonElementDraw for the explanation of why we always draw
     *  PushButtons in the active state.  The deprecated BezelButton can be
     *  faked to at least be usable in Dark Mode if it is always drawn as
     *  inactive.
     */

    SInt32 HIThemeState;
    switch (params->kind) {
    case kThemePushButton:
	HIThemeState = kThemeStateActive;
	break;
    case kThemeBevelButton:
	if (TkMacOSXInDarkMode(tkwin)) {
	    HIThemeState = kThemeStateInactive;
	    break;
	}
    default:
	HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state);
	break;
    }
	
    const HIThemeButtonDrawInfo info = {
	.version = 0,







|
|


|
<













|
<
<







<
<
<
<
<







690
691
692
693
694
695
696
697
698
699
700
701

702
703
704
705
706
707
708
709
710
711
712
713
714
715


716
717
718
719
720
721
722





723
724
725
726
727
728
729
    { kThemeButtonMixed, TTK_STATE_ALTERNATE, 0 },
    { kThemeButtonOn, TTK_STATE_SELECTED, 0 },
    { kThemeButtonOff, 0, 0 }
/* Others: kThemeDisclosureRight, kThemeDisclosureDown, kThemeDisclosureLeft */
};

static Ttk_StateTable ButtonAdornmentTable[] = {
    { kThemeAdornmentDefault | kThemeAdornmentFocus,
	TTK_STATE_ALTERNATE | TTK_STATE_FOCUS, 0 },
    { kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0 },
    { kThemeAdornmentFocus, TTK_STATE_FOCUS, 0 },
    { kThemeAdornmentNone, 0, 0 }};


/*
 * computeButtonDrawInfo --
 *    Fill in an appearance manager HIThemeButtonDrawInfo record.
 */

static inline HIThemeButtonDrawInfo computeButtonDrawInfo(
    ThemeButtonParams *params,
    Ttk_State state,
    Tk_Window tkwin)
{
    /*
     *  See ButtonElementDraw for the explanation of why we always draw
     *  PushButtons in the active state.


     */

    SInt32 HIThemeState;
    switch (params->kind) {
    case kThemePushButton:
	HIThemeState = kThemeStateActive;
	break;





    default:
	HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state);
	break;
    }
	
    const HIThemeButtonDrawInfo info = {
	.version = 0,