Browse Source

Expanded the GUI atlas for more components.

David Piuva 3 years ago
parent
commit
e596afebe7

+ 2 - 2
Source/DFPSR/gui/components/ListBox.cpp

@@ -59,7 +59,7 @@ bool ListBox::isContainer() const {
 static const int textBorderLeft = 6;
 static const int textBorderTop = 4;
 static const int scrollWidth = 16; // The width of the scroll bar
-static const int scrollEndHeight = 14; // The height of upper and lower scroll buttons
+static const int scrollEndHeight = 16; // The height of upper and lower scroll buttons
 
 void ListBox::generateGraphics() {
 	int width = this->location.width();
@@ -342,7 +342,7 @@ void ListBox::limitScrolling(bool keepSelectedVisible) {
 	int64_t maxScroll;
 	int64_t minScroll;
 	// Big enough list to need scrolling but big enough list-box to fit two buttons inside
-	this->hasVerticalScroll = itemCount > visibleRange && this->location.width() >= scrollWidth * 2 && this->location.height() >= scrollEndHeight * 2;
+	this->hasVerticalScroll = itemCount > visibleRange && this->location.width() >= scrollWidth * 2 && this->location.height() >= scrollEndHeight * 3;
 	if (keepSelectedVisible) {
 		maxScroll = this->selectedIndex.value;
 		minScroll = maxScroll + 1 - visibleRange;

+ 110 - 28
Source/tools/wizard/media/Drawing.mmc

@@ -1,4 +1,5 @@
-BEGIN: Resize3x3
+# Helper function that can't be used as a theme.
+BEGIN: Resize3x3
 	INPUT: FixedPoint, targetWidth
 	INPUT: FixedPoint, targetHeight
 	INPUT: FixedPoint, sourceBorder
@@ -53,19 +54,43 @@
 	COPY: targetImage, tbow, tboh, scaled
 END:
 
-BEGIN: Button
+BEGIN: Diffuse3x3
+	INPUT: FixedPoint, width
+	INPUT: FixedPoint, height
+	INPUT: FixedPoint, red
+	INPUT: FixedPoint, green
+	INPUT: FixedPoint, blue
+	INPUT: FixedPoint, sourceLeft
+	INPUT: FixedPoint, sourceTop
+	INPUT: FixedPoint, sourceWidth
+	INPUT: FixedPoint, sourceHeight
+	INPUT: FixedPoint, preserved
+	INPUT: ImageRgbaU8, atlas
+	OUTPUT: ImageRgbaU8, colorImage
+	# Scale by 1 / 255 so that 255 represents full intensity in atlas.
+	MUL: normRed<FixedPoint>, red, 0.00392156862745
+	MUL: normGreen<FixedPoint>, green, 0.00392156862745
+	MUL: normBlue<FixedPoint>, blue, 0.00392156862745
+	# Resize source region from the atlas.
+	CALL: Resize3x3, rescaledImage<ImageRgbaU8>, width, height, preserved, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
+	GET_RED: diffuseMap<ImageU8>, rescaledImage
+	GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
+	MUL: redImage<ImageU8>, diffuseMap, normRed
+	MUL: greenImage<ImageU8>, diffuseMap, normGreen
+	MUL: blueImage<ImageU8>, diffuseMap, normBlue
+	PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
+END:
+
+BEGIN: DiffuseSpecular3x3
 	INPUT: FixedPoint, width
 	INPUT: FixedPoint, height
 	INPUT: FixedPoint, red
 	INPUT: FixedPoint, green
 	INPUT: FixedPoint, blue
-	INPUT: FixedPoint, pressed
 	INPUT: FixedPoint, sourceLeft
 	INPUT: FixedPoint, sourceTop
 	INPUT: FixedPoint, sourceWidth
 	INPUT: FixedPoint, sourceHeight
-	INPUT: FixedPoint, pressOffsetX
-	INPUT: FixedPoint, pressOffsetY
 	INPUT: FixedPoint, preserved
 	INPUT: ImageRgbaU8, atlas
 	OUTPUT: ImageRgbaU8, colorImage
@@ -73,13 +98,61 @@ BEGIN: Button
 	MUL: normRed<FixedPoint>, red, 0.00392156862745
 	MUL: normGreen<FixedPoint>, green, 0.00392156862745
 	MUL: normBlue<FixedPoint>, blue, 0.00392156862745
-	# Calculate the final source location to read.
+	# Resize source region from the atlas.
+	CALL: Resize3x3, rescaledImage<ImageRgbaU8>, width, height, preserved, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
+	GET_RED: diffuseMap<ImageU8>, rescaledImage
+	GET_GREEN: specularMap<ImageU8>, rescaledImage
+	GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
+	MUL: redImage<ImageU8>, diffuseMap, normRed
+	MUL: greenImage<ImageU8>, diffuseMap, normGreen
+	MUL: blueImage<ImageU8>, diffuseMap, normBlue
+	ADD: redImage, redImage, specularMap
+	ADD: greenImage, greenImage, specularMap
+	ADD: blueImage, blueImage, specularMap
+	PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
+END:
+
+BEGIN: PressableDiffuseSpecular3x3
+	INPUT: FixedPoint, width
+	INPUT: FixedPoint, height
+	INPUT: FixedPoint, red
+	INPUT: FixedPoint, green
+	INPUT: FixedPoint, blue
+	INPUT: FixedPoint, pressed
+	INPUT: FixedPoint, sourceLeft
+	INPUT: FixedPoint, sourceTop
+	INPUT: FixedPoint, sourceWidth
+	INPUT: FixedPoint, sourceHeight
+	INPUT: FixedPoint, pressOffsetX
+	INPUT: FixedPoint, preserved
+	INPUT: ImageRgbaU8, atlas
+	OUTPUT: ImageRgbaU8, colorImage
+	# Select image using the pressed state.
 	MUL: sourceOffsetX<FixedPoint>, pressed, pressOffsetX
-	MUL: sourceOffsetY<FixedPoint>, pressed, pressOffsetY
 	ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
-	ADD: adjustedSourceTop<FixedPoint>, sourceTop, sourceOffsetY
+	# Rescale the source region to fit width and height, while applying the diffuse color and adding white shine.
+	CALL: DiffuseSpecular3x3, colorImage, width, height, red, green, blue, adjustedSourceLeft, sourceTop, sourceWidth, sourceHeight, preserved, atlas
+END:
+
+BEGIN: DiffuseSpecular1x1
+	INPUT: FixedPoint, width
+	INPUT: FixedPoint, height
+	INPUT: FixedPoint, red
+	INPUT: FixedPoint, green
+	INPUT: FixedPoint, blue
+	INPUT: FixedPoint, sourceLeft
+	INPUT: FixedPoint, sourceTop
+	INPUT: FixedPoint, sourceWidth
+	INPUT: FixedPoint, sourceHeight
+	INPUT: FixedPoint, preserved
+	INPUT: ImageRgbaU8, atlas
+	OUTPUT: ImageRgbaU8, colorImage
+	# Scale by 1 / 255 so that 255 represents full intensity in atlas.
+	MUL: normRed<FixedPoint>, red, 0.00392156862745
+	MUL: normGreen<FixedPoint>, green, 0.00392156862745
+	MUL: normBlue<FixedPoint>, blue, 0.00392156862745
 	# Resize source region from the atlas.
-	CALL: Resize3x3, rescaledImage<ImageRgbaU8>, width, height, preserved, atlas, adjustedSourceLeft, adjustedSourceTop, sourceWidth, sourceHeight
+	RESIZE_BILINEAR: rescaledImage<ImageRgbaU8>, width, height, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
 	GET_RED: diffuseMap<ImageU8>, rescaledImage
 	GET_GREEN: specularMap<ImageU8>, rescaledImage
 	GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
@@ -92,45 +165,54 @@ BEGIN: Button
 	PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
 END:
 
-BEGIN: ListBox
+BEGIN: PressableDiffuseSpecular1x1
 	INPUT: FixedPoint, width
 	INPUT: FixedPoint, height
 	INPUT: FixedPoint, red
 	INPUT: FixedPoint, green
 	INPUT: FixedPoint, blue
-	INPUT: FixedPoint, border
+	INPUT: FixedPoint, pressed
+	INPUT: FixedPoint, sourceLeft
+	INPUT: FixedPoint, sourceTop
+	INPUT: FixedPoint, sourceWidth
+	INPUT: FixedPoint, sourceHeight
+	INPUT: FixedPoint, pressOffsetX
+	INPUT: FixedPoint, preserved
+	INPUT: ImageRgbaU8, atlas
 	OUTPUT: ImageRgbaU8, colorImage
-	CREATE: colorImage, width, height
-	ADD: b2<FixedPoint>, border, border
-	SUB: w2<FixedPoint>, width, b2
-	SUB: h2<FixedPoint>, height, b2
-	RECTANGLE: colorImage, border, border, w2, h2, red, green, blue, 255
+	# Select image using the pressed state.
+	MUL: sourceOffsetX<FixedPoint>, pressed, pressOffsetX
+	ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
+	# Rescale the source region to fit width and height, while applying the diffuse color and adding white shine.
+	CALL: DiffuseSpecular1x1, colorImage, width, height, red, green, blue, adjustedSourceLeft, sourceTop, sourceWidth, sourceHeight, preserved, atlas
 END:
 
-BEGIN: VerticalScrollList
+BEGIN: ListBox
 	INPUT: FixedPoint, width
 	INPUT: FixedPoint, height
 	INPUT: FixedPoint, red
 	INPUT: FixedPoint, green
 	INPUT: FixedPoint, blue
+	INPUT: FixedPoint, sourceLeft
+	INPUT: FixedPoint, sourceTop
+	INPUT: FixedPoint, sourceWidth
+	INPUT: FixedPoint, sourceHeight
+	INPUT: FixedPoint, preserved
+	INPUT: ImageRgbaU8, atlas
 	OUTPUT: ImageRgbaU8, colorImage
-	CREATE: visImage<ImageU8>, width, height
-	CREATE: lumaImage<ImageU8>, width, height
-	FADE_LINEAR: visImage, 0, 0, 128, width, 0, 0
-	PACK_RGBA: colorImage, 0, 0, 0, visImage
+	# Rescale the source region to fit width and height, while applying the diffuse color.
+	CALL: Diffuse3x3, colorImage, width, height, red, green, blue, sourceLeft, sourceTop, sourceWidth, sourceHeight, preserved, atlas
 END:
 
-BEGIN: Panel
+BEGIN: VerticalScrollList
 	INPUT: FixedPoint, width
 	INPUT: FixedPoint, height
 	INPUT: FixedPoint, red
 	INPUT: FixedPoint, green
 	INPUT: FixedPoint, blue
-	INPUT: FixedPoint, border
 	OUTPUT: ImageRgbaU8, colorImage
-	CREATE: colorImage, width, height
-	ADD: b2<FixedPoint>, border, border
-	SUB: w2<FixedPoint>, width, b2
-	SUB: h2<FixedPoint>, height, b2
-	RECTANGLE: colorImage, border, border, w2, h2, red, green, blue, 255
+	CREATE: visImage<ImageU8>, width, height
+	CREATE: lumaImage<ImageU8>, width, height
+	FADE_LINEAR: visImage, 0, 0, 128, width, 0, 0
+	PACK_RGBA: colorImage, 0, 0, 0, visImage
 END:

BIN
Source/tools/wizard/media/Style.png


BIN
Source/tools/wizard/media/Style.xcf


+ 34 - 15
Source/tools/wizard/media/Theme.ini

@@ -1,35 +1,54 @@
-border = 2
-atlas = File:Style.png
+atlas = File:Style.png
 ; Image location in the atlas
+preserved = 7
+; Fall back on the Diffuse3x3 method if a component's class could not be recognized.
+;method = "DiffuseSpecular1x1"
+
+[Button]
+method = "PressableDiffuseSpecular3x3"
 sourceLeft = 0
 sourceTop = 0
 sourceWidth = 64
 sourceHeight = 64
-; How the image location moves when pressed increases
 pressOffsetX = 64
-pressOffsetY = 0
-; Fall back on the Button method if a component's class could not be recognized.
-method = "Button"
 preserved = 16
 
-[Button]
-rounding = 12
-
 [ListBox]
-method = "ListBox"
+method = "Diffuse3x3"
+sourceLeft = 0
+sourceTop = 64
+sourceWidth = 16
+sourceHeight = 16
 
 [VerticalScrollKnob]
-rounding = 8
+method = "DiffuseSpecular1x1"
+sourceLeft = 96
+sourceTop = 64
+sourceWidth = 16
+sourceHeight = 32
 
 [VerticalScrollList]
 method = "VerticalScrollList"
 
 [ScrollUp]
-rounding = 5
+method = "PressableDiffuseSpecular1x1"
+sourceLeft = 64
+sourceTop = 64
+sourceWidth = 16
+sourceHeight = 16
+pressOffsetX = 16
 
 [ScrollDown]
-rounding = 5
+method = "PressableDiffuseSpecular1x1"
+sourceLeft = 64
+sourceTop = 80
+sourceWidth = 16
+sourceHeight = 16
+pressOffsetX = 16
 
 [Panel]
-border = 1
-method = "Panel"
+method = "Diffuse3x3"
+sourceLeft = 0
+sourceTop = 64
+sourceWidth = 16
+sourceHeight = 16