Refactor resize bar notch width to be a constant and private inside GSTheme, making it accessible through -[GSTheme resizebarNotchWidth].

This commit is contained in:
Riccardo Mottola 2022-03-31 23:43:52 +02:00
parent 96db5bf89c
commit e0012349f6
4 changed files with 31 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2022-03-31 Riccardo Mottola <rm@gnu.org>
* Headers/Additions/GNUstepGUI/GSTheme.h
* Source/GSStandardWindowDecorationView.m
* Source/GSThemeDrawing.m
Refactor resize bar notch width to be a constant and private inside
GSTheme, making it accessible through -[GSTheme resizebarNotchWidth].
2022-03-31 Riccardo Mottola <rm@gnu.org>
* Source/GSStandardWindowDecorationView.m:

View file

@ -1227,6 +1227,8 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
- (float) resizebarHeight;
- (float) resizebarNotchWidth;
- (float) titlebarButtonSize;
- (float) titlebarPaddingRight;

View file

@ -390,13 +390,14 @@ calc_new_frame(NSRect frame, NSPoint point, NSPoint firstPoint,
- (GSResizeEdgeMode) resizeModeForPoint:(NSPoint)point
{
GSResizeEdgeMode mode;
float resizebarNotchWidth = [[GSTheme theme] resizebarNotchWidth];
if (resizeBarRect.size.width < 30 * 2
if (resizeBarRect.size.width < resizebarNotchWidth * 2
&& point.x < resizeBarRect.size.width / 2)
mode = GSResizeEdgeBottomLeftMode;
else if (point.x > resizeBarRect.size.width - 29)
else if (point.x > resizeBarRect.size.width - resizebarNotchWidth - 1)
mode = GSResizeEdgeBottomRightMode;
else if (point.x < 29)
else if (point.x < resizebarNotchWidth - 1)
mode = GSResizeEdgeBottomLeftMode;
else
mode = GSResizeEdgeBottomMode;

View file

@ -1718,6 +1718,7 @@ static NSImage *spinningImages[MaxCount];
/* These include the black border. */
#define TITLE_HEIGHT 23.0
#define RESIZE_HEIGHT 9.0
#define RESIZE_NOTCH_WIDTH 30.0
#define TITLEBAR_BUTTON_SIZE 15.0
#define TITLEBAR_PADDING_TOP 4.0
#define TITLEBAR_PADDING_RIGHT 4.0
@ -1733,6 +1734,11 @@ static NSImage *spinningImages[MaxCount];
return RESIZE_HEIGHT;
}
- (float) resizebarNotchWidth
{
return RESIZE_NOTCH_WIDTH;
}
- (float) titlebarButtonSize
{
return TITLEBAR_BUTTON_SIZE;
@ -1910,6 +1916,8 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
- (void) drawResizeBarRect: (NSRect)resizeBarRect
{
GSDrawTiles *tiles;
float resizebarNotchWidth = [self resizebarNotchWidth];
tiles = [self tilesNamed: @"GSWindowResizeBar" state: GSThemeNormalState];
if (tiles == nil)
{
@ -1935,21 +1943,21 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
/* Only draw the notches if there's enough space. */
if (resizeBarRect.size.width < 30 * 2)
if (resizeBarRect.size.width < resizebarNotchWidth * 2)
return;
[[NSColor darkGrayColor] set];
PSmoveto(27.5, 1.0);
PSlineto(27.5, RESIZE_HEIGHT - 2.0);
PSmoveto(resizeBarRect.size.width - 28.5, 1.0);
PSlineto(resizeBarRect.size.width - 28.5, RESIZE_HEIGHT - 2.0);
PSmoveto(resizebarNotchWidth - 3 + 0.5, 1.0);
PSlineto(resizebarNotchWidth - 3 + 0.5, RESIZE_HEIGHT - 2.0);
PSmoveto(resizeBarRect.size.width - (resizebarNotchWidth - 2 + 0.5), 1.0);
PSlineto(resizeBarRect.size.width - (resizebarNotchWidth - 2 + 0.5), RESIZE_HEIGHT - 2.0);
PSstroke();
[[NSColor whiteColor] set];
PSmoveto(28.5, 1.0);
PSlineto(28.5, RESIZE_HEIGHT - 2.0);
PSmoveto(resizeBarRect.size.width - 27.5, 1.0);
PSlineto(resizeBarRect.size.width - 27.5, RESIZE_HEIGHT - 2.0);
PSmoveto(resizebarNotchWidth - 2 + 0.5, 1.0);
PSlineto(resizebarNotchWidth - 2 + 0.5, RESIZE_HEIGHT - 2.0);
PSmoveto(resizeBarRect.size.width - (resizebarNotchWidth - 3 + 0.5), 1.0);
PSlineto(resizeBarRect.size.width - (resizebarNotchWidth - 3 + 0.5), RESIZE_HEIGHT - 2.0);
PSstroke();
}
else