mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MacBook touch bar: cosmetic fixes
fixed IDEA-194896 MacBook touch bar: use close icon instead of close button fixed half of subissues from IDEA-194893 MacBook touch bar: improve Configurations popover
This commit is contained in:
Binary file not shown.
@@ -9,6 +9,7 @@ const NSSize g_defaultMinSize = {72, 30}; // empiric value
|
||||
@property (nonatomic) NSButtonType btype;
|
||||
@property (nonatomic) CGFloat bwidth;
|
||||
@property (nonatomic) execute jaction;
|
||||
@property (nonatomic) NSString * uid; // for debug only
|
||||
- (id)init;
|
||||
- (void)doAction;
|
||||
+ (Class)cellClass;
|
||||
@@ -29,7 +30,7 @@ const NSSize g_defaultMinSize = {72, 30}; // empiric value
|
||||
NSCell * cell = [self cell];
|
||||
[cell setLineBreakMode:NSLineBreakByTruncatingTail];
|
||||
[self setBezelStyle:NSRoundedBezelStyle];
|
||||
[self setMargins:2 border:8];
|
||||
[self setMargins:3 border:8];
|
||||
// NSLog(@"created button [%@]: cell-class=%@", self, [[self cell] className]);
|
||||
}
|
||||
return self;
|
||||
@@ -58,6 +59,22 @@ const NSSize g_defaultMinSize = {72, 30}; // empiric value
|
||||
} else
|
||||
nstrace(@"button [%@]: empty action, nothing to execute", self);
|
||||
}
|
||||
// Uncomment for visual debug
|
||||
//
|
||||
//- (void) drawRect:(NSRect)dirtyRect {
|
||||
// [[NSGraphicsContext currentContext] saveGraphicsState];
|
||||
//
|
||||
//// NSColor* backgroundColor = [NSColor clearColor];
|
||||
//// NSColor* backgroundColor = [NSColor yellowColor];
|
||||
//// [backgroundColor setFill];
|
||||
//// NSRectFill(dirtyRect);
|
||||
//
|
||||
// [NSGraphicsContext restoreGraphicsState];
|
||||
//
|
||||
// NSLog(@"drawRect [%@]: %@", self.uid, NSStringFromRect(dirtyRect));
|
||||
// [super drawRect:dirtyRect];
|
||||
//}
|
||||
|
||||
+ (Class)cellClass
|
||||
{
|
||||
return [NSButtonCellEx class];
|
||||
@@ -69,7 +86,7 @@ const NSSize g_defaultMinSize = {72, 30}; // empiric value
|
||||
//
|
||||
//-(void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView
|
||||
//{
|
||||
// NSLog(@"drawBezelWithFrame: %@", NSStringFromRect(frame));
|
||||
// NSLog(@"\tdrawBezelWithFrame: %@", NSStringFromRect(frame));
|
||||
// [super drawBezelWithFrame:frame inView:controlView];
|
||||
//
|
||||
// [[NSGraphicsContext currentContext] saveGraphicsState];
|
||||
@@ -112,7 +129,7 @@ const NSSize g_defaultMinSize = {72, 30}; // empiric value
|
||||
return result;
|
||||
}
|
||||
- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
|
||||
// NSLog(@"drawInteriorWithFrame: %@", NSStringFromRect(frame));
|
||||
// NSLog(@"\tdrawInteriorWithFrame: %@", NSStringFromRect(frame));
|
||||
if (self.title == nil || self.title.length <= 0) {
|
||||
[super drawImage:self.image withFrame:frame inView:controlView];
|
||||
return;
|
||||
@@ -187,6 +204,7 @@ const int BUTTON_FLAG_DISABLED = 1;
|
||||
const int BUTTON_FLAG_SELECTED = 1 << 1;
|
||||
const int BUTTON_FLAG_COLORED = 1 << 2;
|
||||
const int BUTTON_FLAG_TOGGLE = 1 << 3;
|
||||
const int BUTTON_FLAG_TRANSPARENT_BG = 1 << 4;
|
||||
|
||||
const unsigned int LAYOUT_WIDTH_MASK = 0x0FFF;
|
||||
const unsigned int LAYOUT_FLAG_MIN_WIDTH = 1 << 15;
|
||||
@@ -304,6 +322,9 @@ static void _setButtonData(NSButtonJAction *button, int updateOptions, int layou
|
||||
if (enabled != button.enabled) {
|
||||
[button setEnabled:enabled];
|
||||
}
|
||||
|
||||
if (buttonFlags & BUTTON_FLAG_TRANSPARENT_BG)
|
||||
[button setBordered:NO];
|
||||
}
|
||||
|
||||
if (button.image != nil) {
|
||||
@@ -330,6 +351,7 @@ id createButton(
|
||||
|
||||
NSCustomTouchBarItem *customItemForButton = [[NSCustomTouchBarItem alloc] initWithIdentifier:nsUid]; // create non-autorelease object to be owned by java-wrapper
|
||||
NSButtonJAction *button = [[[NSButtonJAction alloc] init] autorelease];
|
||||
button.uid = nsUid;
|
||||
|
||||
NSImage *img = createImgFrom4ByteRGBA((const unsigned char *) raster4ByteRGBA, w, h);
|
||||
NSString *nstext = createStringFromUTF8(text);
|
||||
|
||||
@@ -132,6 +132,7 @@ public abstract class DiffRequestProcessor implements Disposable {
|
||||
myToolbarGroup = new DefaultActionGroup();
|
||||
myPopupActionGroup = new DefaultActionGroup();
|
||||
myTouchbarActionGroup = new UpdatableDefaultActionGroup();
|
||||
TouchbarDataKeys.putActionDescriptor(myTouchbarActionGroup).setReplaceEsc(false);
|
||||
|
||||
// UI
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path fill="#AFB1B3" d="M10.2848209,8.8267205 C10.2690992,8.86435323 10.2504724,8.90131564 10.228869,8.93732137 L7.22886896,13.9373214 C6.98734303,14.3398646 6.46522184,14.4703949 6.06267863,14.228869 C5.66013542,13.987343 5.52960512,13.4652218 5.77113104,13.0626786 L8.77113104,8.06267863 C8.78414364,8.04099097 8.79797072,8.02009288 8.81254969,8 C8.79797072,7.97990712 8.78414364,7.95900903 8.77113104,7.93732137 L5.77113104,2.93732137 C5.52960512,2.53477816 5.66013542,2.01265697 6.06267863,1.77113104 C6.46522184,1.52960512 6.98734303,1.66013542 7.22886896,2.06267863 L10.228869,7.06267863 C10.2504724,7.09868436 10.2690992,7.13564677 10.2848209,7.1732795 L10.7372112,8 L10.2848209,8.8267205 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 794 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path fill="#AFB1B3" fill-rule="evenodd" d="M16.1715,14.607 C16.6065,15.042 16.6095,15.7395 16.1745,16.176 C15.744,16.6065 15.0435,16.6095 14.607,16.173 L11.9985,13.566 L9.3915,16.173 C8.955,16.6065 8.259,16.6095 7.824,16.176 C7.392,15.7425 7.3905,15.045 7.827,14.607 L10.434,12 L7.827,9.393 C7.395,8.9595 7.3905,8.262 7.824,7.8255 C8.256,7.392 8.9535,7.3905 9.3915,7.8255 L11.9985,10.4325 L14.607,7.8255 C15.0405,7.3935 15.741,7.3905 16.1745,7.8255 C16.6065,8.2575 16.6095,8.9535 16.1715,9.393 L13.566,12 L16.1715,14.607 Z M12,1.5 C6.2025,1.5 1.5,6.2025 1.5,12 C1.5,17.7975 6.2025,22.5 12,22.5 C17.799,22.5 22.5,17.7975 22.5,12 C22.5,6.2025 17.799,1.5 12,1.5 L12,1.5 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 766 B |
@@ -430,8 +430,8 @@ class BuildUtils {
|
||||
butt.setHiddenWhenDisabled(true);
|
||||
|
||||
if (isRunConfigPopover) {
|
||||
butt.setWidth(ourRunConfigurationPopoverWidth);
|
||||
butt.setHasArrowIcon(true);
|
||||
butt.setLayout(ourRunConfigurationPopoverWidth, 0, 5, 8);
|
||||
} else if (butt.getAnAction() instanceof WelcomePopupAction)
|
||||
butt.setHasArrowIcon(true);
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ public class NST {
|
||||
// Maximum icon size 44px × 44px (22pt × 22pt @2x)
|
||||
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
final float fMulX = app != null && UISettings.getInstance().getPresentationMode() ? 40/icon.getIconHeight() : 40/16.f;
|
||||
final float fMulX = app != null && UISettings.getInstance().getPresentationMode() ? 40.f/icon.getIconHeight() : (icon.getIconHeight() < 24 ? 40.f/16 : 44.f/icon.getIconHeight());
|
||||
return _getImg4ByteRGBA(icon, fMulX);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public interface NSTLibrary extends Library {
|
||||
int BUTTON_FLAG_SELECTED = 1 << 1;
|
||||
int BUTTON_FLAG_COLORED = 1 << 2;
|
||||
int BUTTON_FLAG_TOGGLE = 1 << 3;
|
||||
int BUTTON_FLAG_TRANSPARENT_BG = 1 << 4;
|
||||
|
||||
int LAYOUT_WIDTH_MASK = 0x0FFF;
|
||||
int LAYOUT_FLAG_MIN_WIDTH = 1 << 15;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ui.mac.touchbar;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -157,6 +156,19 @@ class TBItemButton extends TBItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
TBItemButton setTransparentBg(boolean isTransparentBg) {
|
||||
final int flags = _applyFlag(myFlags, isTransparentBg, NSTLibrary.BUTTON_FLAG_TRANSPARENT_BG);
|
||||
if (flags != myFlags) {
|
||||
myFlags = flags;
|
||||
if (myNativePeer != ID.NIL) {
|
||||
myUpdateOptions |= NSTLibrary.BUTTON_UPDATE_FLAGS;
|
||||
_updateNativePeer();
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void update(Icon icon, String text, boolean isSelected, boolean isDisabled) {
|
||||
if (icon != null) icon = IconLoader.getDarkIcon(icon, true);
|
||||
|
||||
@@ -208,8 +220,10 @@ class TBItemButton extends TBItem {
|
||||
synchronized protected ID _createNativePeer() {
|
||||
// System.out.printf("_createNativePeer, button [%s]\n", myUid);
|
||||
final ID result = NST.createButton(myUid, myLayoutBits, _validateFlags(), myText, myIcon, myNativeCallback);
|
||||
if (myHasArrowIcon)
|
||||
NST.setArrowImage(result, AllIcons.General.ComboArrow);
|
||||
if (myHasArrowIcon) {
|
||||
final Icon ic = IconLoader.getIcon("/mac/touchbar/popoverArrow_dark.svg");
|
||||
NST.setArrowImage(result, ic);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ui.mac.touchbar;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.mac.TouchbarDataKeys;
|
||||
import com.intellij.ui.mac.foundation.ID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -52,8 +52,9 @@ class TouchBar implements NSTLibrary.ItemCreator {
|
||||
myItemListener = null;
|
||||
|
||||
myItems = new ItemsContainer(touchbarName, myItemListener);
|
||||
if (replaceEsc)
|
||||
myCustomEsc = new TBItemButton(touchbarName + "_custom_esc_button", myItemListener).setIcon(AllIcons.Actions.Cancel).setThreadSafeAction(()-> {
|
||||
if (replaceEsc) {
|
||||
final Icon ic = IconLoader.getIcon("/mac/touchbar/popoverClose_dark.svg");
|
||||
myCustomEsc = new TBItemButton(touchbarName + "_custom_esc_button", myItemListener).setIcon(ic).setWidth(64).setTransparentBg(true).setThreadSafeAction(()-> {
|
||||
_closeSelf();
|
||||
if (emulateESC) {
|
||||
try {
|
||||
@@ -69,7 +70,7 @@ class TouchBar implements NSTLibrary.ItemCreator {
|
||||
}
|
||||
}
|
||||
});
|
||||
else
|
||||
} else
|
||||
myCustomEsc = null;
|
||||
|
||||
myNativePeer = NST.createTouchBar(touchbarName, this, myCustomEsc != null ? myCustomEsc.myUid : null);
|
||||
|
||||
Reference in New Issue
Block a user