Skip to content

Commit

Permalink
color picker
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHeitmann committed Nov 2, 2024
1 parent b205024 commit 3b881c6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.2'
flutter-version: '3.24.4'

- name: Get Packages
run: flutter pub get
Expand Down
48 changes: 25 additions & 23 deletions lib/widgets/filesView/types/effect/EstFileEditor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,30 +322,31 @@ class _EstEntryWidgetState extends ChangeNotifierState<_EstEntryWidget> {
child: Row(
children: [
const SizedBox(width: 15),
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 325),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text("${widget.entry.entry.header.id} / ${estTypeFullNames[widget.entry.entry.header.id]}"),
const SizedBox(width: 10),
if (widget.entry is EstMoveEntryWrapper)
RgbPropEditor(
prop: (widget.entry as EstMoveEntryWrapper).rgb,
showTextFields: false,
),
if (widget.entry is EstTexEntryWrapper) ...[
EstTexturePreview(
textureFileId: (widget.entry as EstTexEntryWrapper).textureFileId,
textureFileTextureIndex: (widget.entry as EstTexEntryWrapper).textureFileIndex,
),
Flexible(
child: ConstrainedBox(
constraints: const BoxConstraints.tightFor(width: 325),
child: Row(
children: [
Flexible(child: Text("${widget.entry.entry.header.id} / ${estTypeFullNames[widget.entry.entry.header.id]}", overflow: TextOverflow.ellipsis)),
const SizedBox(width: 10),
EstModelPreview(
modelId: (widget.entry as EstTexEntryWrapper).meshId,
),
]
],
)
if (widget.entry is EstMoveEntryWrapper)
RgbPropEditor(
prop: (widget.entry as EstMoveEntryWrapper).rgb,
showTextFields: false,
),
if (widget.entry is EstTexEntryWrapper) ...[
EstTexturePreview(
textureFileId: (widget.entry as EstTexEntryWrapper).textureFileId,
textureFileTextureIndex: (widget.entry as EstTexEntryWrapper).textureFileIndex,
),
const SizedBox(width: 10),
EstModelPreview(
modelId: (widget.entry as EstTexEntryWrapper).meshId,
),
],
],
),
),
),
const SizedBox(width: 10),
_EntryIconButton(
Expand All @@ -362,6 +363,7 @@ class _EstEntryWidgetState extends ChangeNotifierState<_EstEntryWidget> {
icon: Icons.delete,
iconSize: 15,
),
const SizedBox(width: 15),
],
),
),
Expand Down
90 changes: 57 additions & 33 deletions lib/widgets/filesView/types/effect/RgbPropEditor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RgbPropEditor extends StatefulWidget {

class _RgbPropEditorState extends State<RgbPropEditor> {
OverlayEntry? overlayEntry;
Rect? overlayRect;
final List<Rect> overlayRectangles = [];
bool hasClickedOutside = false;

@override
Expand Down Expand Up @@ -99,41 +99,65 @@ class _RgbPropEditorState extends State<RgbPropEditor> {
? selfPos.dx
: windowSize.width - width - 25;
var selfRect = Rect.fromLTWH(selfPos.dx, selfPos.dy, selfSize.width, selfSize.height);
overlayRect = Rect.fromLTWH(left, top, width, height).expandToInclude(selfRect);
overlayRectangles.clear();
// main rectangle
overlayRectangles.add(Rect.fromLTWH(left, top, width, height));
overlayRectangles.add(selfRect);
// drop down
overlayRectangles.add(Rect.fromLTWH(
selfRect.left + (widget.showTextFields ? 18 : 4),
(widget.showTextFields ? selfRect.bottom : top + height) - 8,
60,
85
));
overlayEntry = OverlayEntry(
builder: (context) => Listener(
onPointerDown: (event) {
if (!overlayRect!.contains(event.position)) {
hasClickedOutside = true;
}
},
onPointerUp: (event) {
if (hasClickedOutside && !overlayRect!.contains(event.position)) {
overlayEntry?.remove();
overlayEntry = null;
setState(() {});
}
hasClickedOutside = false;
},
behavior: HitTestBehavior.translucent,
child: Stack(
children: [
Positioned(
top: top,
left: left,
width: width,
height: height,
child: Material(
color: getTheme(context).sidebarBackgroundColor,
elevation: 8,
child: ColorPicker(
rgb: widget.prop,
showTextFields: !widget.showTextFields,
),
builder: (context) => Stack(
children: [
Positioned.fill(
child: Listener(
onPointerDown: (event) {
if (overlayRectangles.every((rect) => !rect.contains(event.position))) {
hasClickedOutside = true;
}
},
onPointerUp: (event) {
if (hasClickedOutside && overlayRectangles.every((rect) => !rect.contains(event.position))) {
overlayEntry?.remove();
overlayEntry = null;
setState(() {});
}
},
behavior: HitTestBehavior.translucent,
),
),
Positioned(
top: top,
left: left,
width: width,
height: height,
child: Material(
color: getTheme(context).sidebarBackgroundColor,
elevation: 8,
child: ColorPicker(
rgb: widget.prop,
showTextFields: !widget.showTextFields,
),
),
],
),
),
// debug visualize rectangles
// for (var (i, rect) in overlayRectangles.indexed)
// Positioned(
// top: rect.top,
// left: rect.left,
// width: rect.width,
// height: rect.height,
// child: Container(
// decoration: BoxDecoration(
// border: Border.all(color: Colors.red),
// ),
// ),
// ),
],
)
);
Overlay.of(context).insert(overlayEntry!);
Expand Down
20 changes: 10 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: cli_util
sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
url: "https://pub.dev"
source: hosted
version: "0.4.1"
version: "0.4.2"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -436,18 +436,18 @@ packages:
dependency: transitive
description:
name: path_parsing
sha256: "45f7d6bba1128761de5540f39d5ca000ea8a1f22f06b76b61094a60a2997bd0e"
sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.1.0"
path_provider:
dependency: transitive
description:
name: path_provider
sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.1.5"
path_provider_android:
dependency: transitive
description:
Expand Down Expand Up @@ -753,10 +753,10 @@ packages:
dependency: transitive
description:
name: url_launcher_android
sha256: "0dea215895a4d254401730ca0ba8204b29109a34a99fb06ae559a2b60988d2de"
sha256: "6fc2f56536ee873eeb867ad176ae15f304ccccc357848b351f6f0d8d4a40d193"
url: "https://pub.dev"
source: hosted
version: "6.3.13"
version: "6.3.14"
url_launcher_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -850,10 +850,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: e1d0cc62e65dc2561f5071fcbccecf58ff20c344f8f3dc7d4922df372a11df1f
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2"
url: "https://pub.dev"
source: hosted
version: "5.7.1"
version: "5.8.0"
window_manager:
dependency: "direct main"
description:
Expand Down

0 comments on commit 3b881c6

Please sign in to comment.