Fresh IDE . Check-in [d335cd1b07]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Work on TScrollable class. Now the scrollers can be dragged by the mouse;
Timelines: family | ancestors | descendants | both | FreshLibDev
Files: files | file ages | folders
SHA1:d335cd1b07f3bca22f1a9ca6bbfdf98c03841ec6
User & Date: johnfound 2017-04-16 16:45:25
Context
2017-04-16
23:27
Work on TScrollable; Fixed bug in _realobjects.inc; check-in: e4d69cd129 user: johnfound tags: FreshLibDev
16:45
Work on TScrollable class. Now the scrollers can be dragged by the mouse; check-in: d335cd1b07 user: johnfound tags: FreshLibDev
2017-04-14
08:05
Added missing KolibriOS file. check-in: 9e39486f06 user: johnfound tags: FreshLibDev
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/gui/TScrollable.asm.

17
18
19
20
21
22
23











24
25
26
27
28
29
30
...
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425

426
427
428
429
430
431
432
433
434
435
436
437
438

439
440
441
442
443
444



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472

473
474
475
476
477
478
479


















480
481
482
483
484
485
486
487
488
489
490


491
492
493
494
495
496
497
498
499

500
501
502
503
504
505
506
507
508
509
510
511
512
513
514


515
516
517
518
519
520
521
522
523
...
530
531
532
533
534
535
536
537
538



539

540
541



542
543
544
545
546
547
548
...
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
struct TScroller
  .pos   dd ?
  .page  dd ?
  .max   dd ?
  .state dd ?
ends













object TScrollable, TWindow

  ._scrX  TScroller
  ._scrY  TScroller

  ._drag_ofs dd ?
................................................................................
begin
        push    esi ecx edx

        mov     esi, [.self]

        xor     ecx, ecx
        xor     edx, edx

        xchg    ecx, [esi+TScrollable._scrX.state]
        xchg    edx, [esi+TScrollable._scrY.state]

        cmp     ecx, [esi+TScrollable._scrX.state]
        jne     .repaint

        cmp     edx, [esi+TScrollable._scrY.state]

        je      .finish

.repaint:
        exec    esi, TScrollable:DrawScrollbars

.finish:
        pop     edx ecx esi
        return
endp



method TScrollable.EventMouseMove

.stateH dd ?
.stateV dd ?
begin
        pushad

        mov     esi, [.self]




        xor     ecx, ecx
        mov     [.stateH], ecx
        mov     [.stateV], ecx

        stdcall TScrollable.FindScroller, esi, [.x], [.y]
        test    eax, eax
        js      .set_state

        inc     [.stateH+4*eax]

.set_state:
        xor     eax, eax
        mov     ebx, [.stateH]
        xchg    ebx, [esi+TScrollable._scrX.state]
        cmp     ebx, [esi+TScrollable._scrX.state]
        je      .xok
        inc     eax
.xok:

        mov     ebx, [.stateV]
        xchg    ebx, [esi+TScrollable._scrY.state]
        cmp     ebx, [esi+TScrollable._scrY.state]
        je      .yok
        inc     eax
.yok:
        test    eax, eax
        jz      .exit


        exec    esi, TScrollable:DrawScrollbars

.exit:
        inherited  [.x], [.y], [.kbdState]
        popad
        return


















endp



method TScrollable.EventButtonPress
begin
        pushad

        cmp     [.button], mbLeft
        jne     .finish



        stdcall TScrollable.FindScroller, [.self], [.x], [.y]
        test    eax, eax
        js      .finish





;        mov     esi, [.self]

;        mov     ebx, [esi+TScrollable._kind]
;
;        stdcall _SliderPixels2, esi, [esi+TScrollable._width + 4*ebx]
;
;        mov     edi, [.x+ 4*ebx]
;
;        sub     edi, eax
;        jl      .before
;
;        cmp     edi, edx
;        jg      .after
;
;; inside the slider - capture the mouse.
;
;        mov     [esi+TScrollable._drag_ofs], edi


;
;        stdcall SetMouseCapture, esi

.finish:
        inherited [.button], [.kbdState], [.x], [.y]

        popad
        return

................................................................................


method TScrollable.EventButtonRelease
begin
        pushad

        mov     esi, [.self]

        xor     eax, eax



        mov     [esi+TScrollable._drag_ofs], eax

        stdcall SetMouseCapture, eax




        popad
        return
endp




................................................................................
        return
endp





proc _SetSliderPos2, .pScrollbar, .x, .lengthpx
begin
        push    eax ecx edx

        mov     ecx, [.pScrollbar]
        stdcall _SliderPixels, [.pScrollbar], [.lengthpx]

        sub     [.lengthpx], edx
        jz      .zero

        mov     eax, [ecx+TScrollable._max]
        imul    [.x]
        idiv    [.lengthpx]

        cmp     eax, 0
        jge     .ok
        mov     eax, 0
.ok:
        cmp     eax, [ecx+TScrollable._max]
        jle     .ok2
        mov     eax, [ecx+TScrollable._max]
.ok2:
        cmp     [ecx+TScrollable._pos], eax
        stc
        je      @f
        clc
@@:
        mov     [ecx+TScrollable._pos], eax
        pop     edx ecx eax
        return

.zero:
        xor     eax, eax
        jmp     .ok2
endp



endmodule










>
>
>
>
>
>
>
>
>
>
>







 







<


<
<
<
<
<
>
|

<










>






>
>
>






<
<
<
|

<



|
<
|
<



|
<
<
<
|
<
>



|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
|



<
<
<
<
|
>
|
<
|
<
|
|
|
|
|
|
|
|
|
|
|
>
>
|
|







 







<

>
>
>

>


>
>
>







 







|



|
|




|



|
|
|
|
|
|
|
|
|
|
|
|
|
<





|








17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
422
423
424
425
426
427
428

429
430





431
432
433

434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459



460
461

462
463
464
465

466

467
468
469
470



471

472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514




515
516
517

518

519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
...
547
548
549
550
551
552
553

554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
...
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655

656
657
658
659
660
661
662
663
664
665
666
667
668
669
struct TScroller
  .pos   dd ?
  .page  dd ?
  .max   dd ?
  .state dd ?
ends

; Constants for TScroller.state - the state of the particular scrollbar.

sbsNormal = 0   ; when the mouse is outside the scrollbar
sbsActive = 1   ; when the mouse points on the scrollbar

; Constants for TScrollable._state - the state of the window as a whole.

scsReleased = 0           ; no scrollbar is in drag state.
scsDragHorizontal = 1     ; the horizontal scrollbar is in drag state.
scsDragVertical   = 2     ; the vertical scrollbar is in drag state.


object TScrollable, TWindow

  ._scrX  TScroller
  ._scrY  TScroller

  ._drag_ofs dd ?
................................................................................
begin
        push    esi ecx edx

        mov     esi, [.self]

        xor     ecx, ecx
        xor     edx, edx

        xchg    ecx, [esi+TScrollable._scrX.state]
        xchg    edx, [esi+TScrollable._scrY.state]





        or      ecx, edx
        jz      .finish


        exec    esi, TScrollable:DrawScrollbars

.finish:
        pop     edx ecx esi
        return
endp



method TScrollable.EventMouseMove
.dummy  dd ?
.stateH dd ?
.stateV dd ?
begin
        pushad

        mov     esi, [.self]
        mov     ebx, [esi+TScrollable._state]
        test    ebx, ebx
        jnz     .process_drag

        xor     ecx, ecx
        mov     [.stateH], ecx
        mov     [.stateV], ecx

        stdcall TScrollable.FindScroller, esi, [.x], [.y]



        inc     [.stateH+4*eax]         ; notice the .dummy variable for eax = -1


        xor     eax, eax
        mov     ebx, [.stateH]
        xchg    ebx, [esi+TScrollable._scrX.state]
        xor     ebx, [esi+TScrollable._scrX.state]

        or      eax, ebx


        mov     ebx, [.stateV]
        xchg    ebx, [esi+TScrollable._scrY.state]
        xor     ebx, [esi+TScrollable._scrY.state]



        or      eax, ebx

        jz      .state_ok   ; if the state has not be changed.

        exec    esi, TScrollable:DrawScrollbars

.state_ok:
        inherited  [.x], [.y], [.kbdState]
        popad
        return


.process_drag:
        dec     ebx
        lea     edi, [4*ebx]

        mov     eax, [.x + edi]
        mov     ecx, [esi+TScrollable._width + edi]

        sub     eax, [esi+TScrollable._drag_ofs]
        lea     edx, [esi+TScrollable._scrX + 4*edi]

        stdcall _SetSliderPos2, edx, eax, ecx

        exec    esi, TScrollable:DrawScrollbars
        exec    esi, TWindow:EventScroll, ebx, scTrack, [edx+TScroller.pos]
        jmp     .state_ok

endp



method TScrollable.EventButtonPress
begin
        pushad

        cmp     [.button], mbLeft
        jne     .finish

        mov     esi, [.self]

        stdcall TScrollable.FindScroller, esi, [.x], [.y]
        test    eax, eax
        js      .finish





        mov     ebx, eax
        shl     eax, 4
        lea     eax, [esi+TScrollable._scrX + eax]

        stdcall _SliderPixels2, eax, [esi+TScrollable._width + 4*ebx]

        mov     edi, [.x + 4*ebx]

        sub     edi, eax
        jl      .before

        cmp     edi, edx
        jg      .after

; inside the slider - capture the mouse.

        mov     [esi+TScrollable._drag_ofs], edi
        inc     ebx
        mov     [esi+TScrollable._state], ebx

        stdcall SetMouseCapture, esi

.finish:
        inherited [.button], [.kbdState], [.x], [.y]

        popad
        return

................................................................................


method TScrollable.EventButtonRelease
begin
        pushad

        mov     esi, [.self]

        xor     eax, eax
        cmp     [esi+TScrollable._state], eax
        je      .finish

        mov     [esi+TScrollable._drag_ofs], eax
        mov     [esi+TScrollable._state], eax
        stdcall SetMouseCapture, eax

        exec    esi, TScrollable:EventMouseMove, [.x], [.y], [.kbdState]

.finish:
        popad
        return
endp




................................................................................
        return
endp





proc _SetSliderPos2, .pScroller, .x, .lengthpx
begin
        push    eax ecx edx

        mov     ecx, [.pScroller]
        stdcall _SliderPixels2, ecx, [.lengthpx]

        sub     [.lengthpx], edx
        jz      .zero

        mov     eax, [ecx+TScroller.max]
        imul    [.x]
        idiv    [.lengthpx]

        xor     edx, edx

        cmp     eax, edx
        cmovl   eax, edx

        mov     edx, [ecx+TScroller.max]
        cmp     eax, edx
        cmovg   eax, edx

.ok:
        xchg    eax, [ecx+TScroller.pos]
        cmp     eax, [ecx+TScroller.pos]


        pop     edx ecx eax
        return

.zero:
        xor     eax, eax
        jmp     .ok
endp



endmodule



Changes to freshlib/test_code0/TestAsmEdit.asm.

72
73
74
75
76
77
78
79
80
81
82





83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
          ObjTemplate  tfChild, TButton, btnRedo,               \
                     SplitCell = SplitTest.cellRedo,            \
                     Caption = "R",                             \
                     Visible = TRUE, \
                     OnClick = DoRedo


;          ObjTemplate  tfChild or tfEnd, TScrollable, AsmEdit,     \
;                     x = 10, y = 40, width = 200, height = 200, \
;                     MaxX = 1000, PosX = 500, PageX = 100,        \
;                     MaxY = 1000, PosY = 500, PageY = 100,        \





;                     SplitCell = SplitTest.cellAsmEdit,         \
;                     Visible = TRUE

          ObjTemplate  tfChild or tfEnd, TAsmEdit, AsmEdit,     \
                     x = 10, y = 40, width = 200, height = 200, \
                     SplitCell = SplitTest.cellAsmEdit,         \
                     Visible = TRUE


;utf8_long file "unicode_test.txt"
utf8_long file "test_utf8.asm"
          dd   0










|
|
|
|
>
>
>
>
>



<
<
<
<
<







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90





91
92
93
94
95
96
97
          ObjTemplate  tfChild, TButton, btnRedo,               \
                     SplitCell = SplitTest.cellRedo,            \
                     Caption = "R",                             \
                     Visible = TRUE, \
                     OnClick = DoRedo


          ObjTemplate  tfChild or tfEnd, TScrollable, AsmEdit,     \
                     x = 10, y = 40, width = 200, height = 200, \
                     MaxX = 1000, PosX = 500, PageX = 100,        \
                     MaxY = 1000, PosY = 500, PageY = 100,        \
                     SplitCell = SplitTest.cellAsmEdit,         \
                     Visible = TRUE

;          ObjTemplate  tfChild or tfEnd, TAsmEdit, AsmEdit,     \
;                     x = 10, y = 40, width = 200, height = 200, \
;                     SplitCell = SplitTest.cellAsmEdit,         \
;                     Visible = TRUE







;utf8_long file "unicode_test.txt"
utf8_long file "test_utf8.asm"
          dd   0



Changes to freshlib/test_code0/TestAsmEdit.fpr.

cannot compute difference between binary files