summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--library/ttk/aquaTheme.tcl6
-rw-r--r--macosx/tkMacOSXButton.c48
-rw-r--r--macosx/tkMacOSXDefault.h4
-rw-r--r--macosx/ttkMacOSXTheme.c20
4 files changed, 58 insertions, 20 deletions
diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl
index 92689d8..83fa16f 100644
--- a/library/ttk/aquaTheme.tcl
+++ b/library/ttk/aquaTheme.tcl
@@ -26,8 +26,12 @@ namespace eval ttk::theme::aqua {
!focus systemSelectedTextColor}
# Button
- ttk::style configure TButton -anchor center -width -6\
+ ttk::style configure TButton -anchor center -width -6 \
-foreground systemControlTextColor
+ ttk::style map TButton \
+ -foreground {
+ pressed white
+ {alternate !pressed !background} white}
ttk::style configure TMenubutton -anchor center -padding {2 0 0 2}
ttk::style configure Toolbutton -anchor center
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index 00c7c9b..c514d4b 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -457,12 +457,13 @@ DrawButtonImageAndText(
int textXOffset = 0, textYOffset = 0;
int width = 0, height = 0;
int fullWidth = 0, fullHeight = 0;
+ DrawParams *dpPtr = &mbPtr->drawParams;
+ GC textGC = dpPtr->gc;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
}
- DrawParams *dpPtr = &mbPtr->drawParams;
pixmap = (Pixmap) Tk_WindowId(tkwin);
if (butPtr->image != None) {
@@ -477,11 +478,20 @@ DrawButtonImageAndText(
imageHeight = height;
if (mbPtr->drawinfo.state == kThemeStatePressed) {
- /*
- * Offset bitmaps by a bit when the button is pressed.
+ pressed = 1;
+
+ /*
+ * Unlike NSButton, HIToolbox does not change the color of a "-default
+ * active" button when it is pressed, so there is no visual
+ * acknowledgement. As a workaround we revert to the inactive (black)
+ * text while the button is pressed. This does not match native
+ * behavior, but it does give the user some feedback.
*/
- pressed = 1;
+ if (mbPtr->drawinfo.adornment & kThemeAdornmentDefault) {
+ // !TkMacOSXInDarkMode(butPtr->tkwin)) {
+ textGC = butPtr->normalTextGC;
+ }
}
haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
@@ -578,12 +588,10 @@ DrawButtonImageAndText(
imageXOffset, imageYOffset, 1);
XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
}
-
y += 1; /* Tweak to match native buttons. */
- Tk_DrawTextLayout(butPtr->display, pixmap,
- dpPtr->gc, butPtr->textLayout,
- x + textXOffset, y + textYOffset, 0, -1);
- Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc,
+ Tk_DrawTextLayout(butPtr->display, pixmap, textGC, butPtr->textLayout,
+ x + textXOffset, y + textYOffset, 0, -1);
+ Tk_UnderlineTextLayout(butPtr->display, pixmap, textGC,
butPtr->textLayout,
x + textXOffset, y + textYOffset,
butPtr->underline);
@@ -630,8 +638,8 @@ DrawButtonImageAndText(
butPtr->textHeight, &x, &y);
x += butPtr->indicatorSpace;
y += 1; /* Tweak to match native buttons */
- Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc,
- butPtr->textLayout, x, y, 0, -1);
+ Tk_DrawTextLayout(butPtr->display, pixmap, textGC butPtr->textLayout,
+ x, y, 0, -1);
}
/*
@@ -772,12 +780,15 @@ TkMacOSXDrawButton(
}
/*
- * To avoid buttons with white text on a white background, we always
- * set the state to inactive in Dark Mode. It isn't perfect but it is
- * usable. Using a ttk::button would be a better choice, however.
+ * To avoid buttons with white text on a white background, we set the
+ * state to inactive in Dark Mode unless the button is pressed or is a
+ * -default active button. This isn't perfect but it is mostly usable.
+ * Using a ttk::button would be a much better choice, however.
*/
- if (TkMacOSXInDarkMode(butPtr->tkwin)) {
+ if (TkMacOSXInDarkMode(butPtr->tkwin) &&
+ mbPtr->drawinfo.state != kThemeStatePressed &&
+ !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) {
hiinfo.state = kThemeStateInactive;
}
HIThemeDrawButton(&cntrRect, &hiinfo, dc.context,
@@ -1109,6 +1120,13 @@ TkMacOSXComputeButtonDrawParams(
} else if (butPtr->type == TYPE_BUTTON && butPtr->state == STATE_ACTIVE) {
dpPtr->gc = butPtr->activeTextGC;
dpPtr->border = butPtr->activeBorder;
+ } else if ((mbPtr->drawinfo.adornment & kThemeAdornmentDefault) &&
+ mbPtr->drawinfo.state == kThemeStateActive) {
+ /*
+ * This is a "-default active" button in the front window.
+ */
+
+ dpPtr->gc = butPtr->activeTextGC;
} else {
dpPtr->gc = butPtr->normalTextGC;
}
diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h
index 9c3654a..d55ddcb 100644
--- a/macosx/tkMacOSXDefault.h
+++ b/macosx/tkMacOSXDefault.h
@@ -54,8 +54,8 @@
#define DEF_BUTTON_ANCHOR "center"
#define DEF_BUTTON_ACTIVE_BG_COLOR ACTIVE_BG
#define DEF_BUTTON_ACTIVE_BG_MONO BLACK
-#define DEF_BUTTON_ACTIVE_FG_COLOR ACTIVE_FG
-#define DEF_CHKRAD_ACTIVE_FG_COLOR DEF_BUTTON_ACTIVE_FG_COLOR
+#define DEF_BUTTON_ACTIVE_FG_COLOR TEXT_BG
+#define DEF_CHKRAD_ACTIVE_FG_COLOR ACTIVE_FG
#define DEF_BUTTON_ACTIVE_FG_MONO WHITE
#define DEF_BUTTON_BG_COLOR NORMAL_BG
#define DEF_BUTTON_BG_MONO WHITE
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 0052b14..9e032a3 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -105,6 +105,10 @@ static CGFloat darkSelectedGradient[8] = {
23.0 / 255, 111.0 / 255, 232.0 / 255, 1.0,
20.0 / 255, 94.0 / 255, 206.0 / 255, 1.0
};
+static CGFloat pressedPushButtonGradient[8] = {
+ 35.0 / 255, 123.0 / 255, 244.0 / 255, 1.0,
+ 30.0 / 255, 114.0 / 255, 235.0 / 255, 1.0
+};
/*
* When building on systems earlier than 10.8 there is no reasonable way to
@@ -152,6 +156,7 @@ static inline CGRect BoxToRect(
*/
static Ttk_StateTable ThemeStateTable[] = {
+ {kThemeStateActive, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND},
{kThemeStateUnavailable, TTK_STATE_DISABLED, 0},
{kThemeStatePressed, TTK_STATE_PRESSED, 0},
{kThemeStateInactive, TTK_STATE_BACKGROUND, 0},
@@ -647,6 +652,11 @@ static void DrawDarkButton(
bounds = CGRectInset(bounds, 1, 1);
if (kind == kThemePushButton && (state & TTK_STATE_PRESSED)) {
GradientFillRoundedRectangle(context, bounds, 4,
+ pressedPushButtonGradient, 2);
+ } else if (kind == kThemePushButton &&
+ (state & TTK_STATE_ALTERNATE) &&
+ !(state & TTK_STATE_BACKGROUND)) {
+ GradientFillRoundedRectangle(context, bounds, 4,
darkSelectedGradient, 2);
} else {
if (state & TTK_STATE_DISABLED) {
@@ -1198,6 +1208,7 @@ static ThemeButtonParams
ListHeaderParams =
{kThemeListHeaderButton, kThemeMetricListHeaderHeight};
static Ttk_StateTable ButtonValueTable[] = {
+ {kThemeButtonOff, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND},
{kThemeButtonMixed, TTK_STATE_ALTERNATE, 0},
{kThemeButtonOn, TTK_STATE_SELECTED, 0},
{kThemeButtonOff, 0, 0}
@@ -1209,11 +1220,11 @@ static Ttk_StateTable ButtonValueTable[] = {
};
static Ttk_StateTable ButtonAdornmentTable[] = {
+ {kThemeAdornmentNone, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
{kThemeAdornmentDefault | kThemeAdornmentFocus,
TTK_STATE_ALTERNATE | TTK_STATE_FOCUS, 0},
- {kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0},
- {kThemeAdornmentNone, TTK_STATE_ALTERNATE, 0},
{kThemeAdornmentFocus, TTK_STATE_FOCUS, 0},
+ {kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0},
{kThemeAdornmentNone, 0, 0}
};
@@ -1372,6 +1383,11 @@ static void ButtonElementDraw(
ChkErr(HIThemeDrawButton, &bounds, &info, dc.context,
HIOrientation, NULL);
}
+ } else if (info.kind == kThemePushButton &&
+ (state & TTK_STATE_PRESSED)) {
+ bounds.size.height += 2;
+ GradientFillRoundedRectangle(dc.context, bounds, 4,
+ pressedPushButtonGradient, 2);
} else {
/*