Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

pasteboard% generates artifacts when snips are dragged behind each other

Đang mở
#216 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Lĩnh vực
desktop

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản tái hiện Racket 8.0 Windows được cung cấp và kiểm tra việc vẽ cũng như xử lý thao tác kéo của pasteboard%, đặc biệt là cách các snip chồng lấp quản lý ngữ cảnh vẽ. Được xem là hoàn tất khi việc kéo nút màu xanh lam phía sau qua nút màu xanh lục không tạo ra hiện tượng bất thường về hình ảnh, kể cả khi các nút đang chồng lên nhau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I am using Racket 8.0 on Windows 10. Run the following code.

#lang racket/gui

(struct dc-state (smoothing pen brush font))

(define (capture-dc-state dc)
  (dc-state (send dc get-smoothing)
            (send dc get-pen)
            (send dc get-brush)
            (send dc get-font)))

(define (restore-dc-state dc dc-state)
  (send dc set-smoothing (dc-state-smoothing dc-state))
  (send dc set-pen (dc-state-pen dc-state))
  (send dc set-brush (dc-state-brush dc-state))
  (send dc set-font (dc-state-font dc-state)))

(define node-snip-class
  (make-object
      (class snip-class%
        (super-new)
        (send this set-classname "node-snip"))))

(send (get-the-snip-class-list) add node-snip-class)

(define (set-extent-others others)
  (for/list ([other others])
    (when other (set-box! other 0.0))))

(define node%
  (class snip%
    (init-field size color)
    (super-new)
    (send this set-snipclass node-snip-class)

    (define/override (get-extent dc x y width height . others)
      (when width (set-box! width size))
      (when height (set-box! height size))
      (set-extent-others others))

    (define/override (draw dc x y . other)
      (let ([dc-state (capture-dc-state dc)])
        (send dc set-smoothing 'smoothed)
        (send dc set-pen "Black" 3 'solid)
        (send dc set-brush color 'solid)
        (send dc draw-rounded-rectangle x y size size 7)
        (restore-dc-state dc dc-state)))
    ))

(define diagram (new pasteboard%))

(define frame (new frame%
                   [label "Diagram"]
                   [width 500]
                   [height 500]))

(define canvas (new editor-canvas%
                    [parent frame]
                    [style '(no-hscroll no-vscroll)]
                    [horizontal-inset 0]
                    [vertical-inset 0]
                    [editor diagram]))

(send diagram insert (new node% [size 50] [color "Pale Green"]) 100 100)

(send diagram insert (new node% [size 50] [color "Pale Turquoise"]) 200 200)

(send frame show #t)

Note that the dc state is captured and restored in the draw override. Drag the green node over the blue one and note that no artifacts occur.

image

Now drag the blue node, which is behind the green node, and note that artifacts appear, potentially from the smoothing property not being correctly handled by the pasteboard%. Although, I'm not sure where exactly the artifacts are coming from at the moment. Notice that the artifacts only occur while the blue node is being dragged behind the green node and that they stop after the blue node "clears" the green node.

image

Ngôn ngữ chính
Racket
Star
68
Fork
83
Merge trung bình
9 ngày 8 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của racket/gui

Tất cả issue của racket/gui

Issue tương tự

Thêm issue về Desktop Dev

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.