Fresh IDE . Check-in [b55198191b]
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 the TButton proper rendering.
Timelines: family | ancestors | descendants | both | NoCanvasGUI
Files: files | file ages | folders
SHA1:b55198191b63ab7e89c389f5d285f9bb8c622917
User & Date: johnfound 2017-08-26 14:58:33
Context
2017-08-27
18:45
Minor fix in TButton and adapting TProgress to the new API. check-in: c5df17b099 user: johnfound tags: NoCanvasGUI
2017-08-26
14:58
Work on the TButton proper rendering. check-in: b55198191b user: johnfound tags: NoCanvasGUI
2017-08-21
02:51
The next code refactoring for the GUI library. The idea is to not refresh the controls all the time, but only when needed. In addition, the drawing methods are now not fixed, but can vary for the different classes, using only common interface: TWindow:SelfPaint method; check-in: 215e9a11c6 user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/graphics/images.asm.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
...
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614

struct TImage
  .width     dd ?  ; width in pixels.
  .height    dd ?  ; height in pixels.
  .pPixels   dd ?  ; pointer to the pixel memory.

  .WrapRect   RECT
  .xWrapBeg   dd ?
  .yWrapBeg   dd ?
  .xWrapEnd   dd ?
  .yWrapEnd   dd ?

  .lock      TMutex
ends



; Creates memory image with parameters specified.
................................................................................
  end if
..ok:
}


proc BlendImageTileWrap, .pDstImage, .xDst, .yDst, .wDst, .hDst, .pSrcImage, .xSrc, .ySrc, .wSrc, .hSrc


.startYSrc dd ?
.endYSrc   dd ?

.startYDst dd ?
.endYDst   dd ?

.stepYSrc dd ?
................................................................................
.finish:
        popad
        return
endp



call ImageSetWrap

proc ImageSetWrap, .pImage, .x, .y, .width, .height
.srect RECT
begin
        pushad

        mov     esi, [.pImage]
        stdcall LockImg, esi
................................................................................

.ySrcWrap0 dd ?
.ySrcWrap1 dd ?


.srect RECT
.drect RECT




.startYSrc dd ?
.endYSrc   dd ?

.startYDst dd ?
.endYDst   dd ?







|
|
|
|







 







<







 







<
<







 







<
<







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
267
268
269
270
271
272
273

274
275
276
277
278
279
280
...
508
509
510
511
512
513
514


515
516
517
518
519
520
521
...
596
597
598
599
600
601
602


603
604
605
606
607
608
609

struct TImage
  .width     dd ?  ; width in pixels.
  .height    dd ?  ; height in pixels.
  .pPixels   dd ?  ; pointer to the pixel memory.

  .WrapRect   RECT
  .xWrapBeg   dd ?   ; byte offset relative to the line start.
  .yWrapBeg   dd ?   ; byte offset relative to the image start.
  .xWrapEnd   dd ?   ; byte offset relative to the line start.
  .yWrapEnd   dd ?   ; byte offset relative to the image start.

  .lock      TMutex
ends



; Creates memory image with parameters specified.
................................................................................
  end if
..ok:
}


proc BlendImageTileWrap, .pDstImage, .xDst, .yDst, .wDst, .hDst, .pSrcImage, .xSrc, .ySrc, .wSrc, .hSrc


.startYSrc dd ?
.endYSrc   dd ?

.startYDst dd ?
.endYDst   dd ?

.stepYSrc dd ?
................................................................................
.finish:
        popad
        return
endp





proc ImageSetWrap, .pImage, .x, .y, .width, .height
.srect RECT
begin
        pushad

        mov     esi, [.pImage]
        stdcall LockImg, esi
................................................................................

.ySrcWrap0 dd ?
.ySrcWrap1 dd ?


.srect RECT
.drect RECT




.startYSrc dd ?
.endYSrc   dd ?

.startYDst dd ?
.endYDst   dd ?

Changes to freshlib/gui/TButton.asm.

51
52
53
54
55
56
57


58
59
60
61
62
63


64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
178
179
180
181
182
183
184

















185
186
187
188
189
190
191
...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
...
408
409
410
411
412
413
414

415
416
417
418
419
420
421
; parameters

  param .OnClick, ._OnClick, ._OnClick

  param .TextAlign,    ._textalign,  .SimpleSetParam:3
  param .Icon,         ._icon,       .SetIcon
  param .IconPosition, ._iconpos,    .SimpleSetParam:3



  param .ModalResult, ._ModalResult, ._ModalResult

; methods

  ; parameters handling methods



  method .SetIcon, .value
  method .SimpleSetParam, .param, .get, .value

  ; system events methods

  method .Create, .Parent

  method ._RenderView

  method .SelfPaint, .Operation, .pDstImage, .xDst, .yDst, .xSrc, .ySrc, .width, .height
  method .Resize, .newWidth, .newHeight
  method .SetCaption, .value

  method .EventFocusIn
  method .EventFocusOut

................................................................................
endobj


interface TButton.OnClick, .self, .button


; new


method TButton.Create
begin
        inherited [.Parent]

        mov     eax, [.self]
        mov     [eax+TButton._cursor], mcHand
................................................................................
        jne     @f
        exec    esi, TButton:_RenderView
@@:
        mov     ebx, [esi+TButton._canvas]
        test    ebx, ebx
        jz      .finish

        mov     edx, [esi+TButton._state]
        imul    edx, [esi+TButton._height]
        add     edx, [.ySrc]

        mov     ecx, CopyImageRect
        cmp     [.Operation], spCopy
        je      .doit
        mov     ecx, BlendImage
................................................................................

.size_ok:
        and     [esi+TButton._canvas_valid], 0
        exec    esi, TButton:RectChanged2, 0
        popad
        return
endp



















method TButton.SetCaption       ;, .value
begin
        inherited [.value]

        push    eax
................................................................................
        xor     ebx, ebx        ; 0 == bsNeutral

.loop_y:

; draw the border and the background

        lea     eax, [.client]
        mov     ecx, [GUI.btnBorder+4*ebx]
        cmp     ebx, bsDisabled
        jne     @f
        or      ecx, bxDisabled
@@:
        stdcall DrawBoxDefault, [.canvas], eax, [GUI.clBtnBk+4*ebx], ecx, [GUI.boxBorderWidth]

; draw the icon

        mov     edi, [.icon]
        test    edi, edi
        jz      .draw_text

................................................................................
        mov     ecx, [.bounds.y]

        cmp     ebx, bsPressed
        jne     @f
        add     eax, [GUI.btnPressedOfsX]
        add     ecx, [GUI.btnPressedOfsY]
@@:

        stdcall DrawTextBox, [.canvas], [.caption], eax, ecx, [.bounds.width], [.bounds.height], 2, edi, [GUI.DefaultFont], [GUI.clBtnTxt+4*ebx]

.textok:
        cmp     esi, [__FocusedWindow]
        jne     .focus_ok

        mov     eax, [.client.y]







>
>






>
>









>







 







<







 







|







 







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







 







<
<
<
<
<
|







 







>







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
..
94
95
96
97
98
99
100

101
102
103
104
105
106
107
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
388
389
390
391
392
393
394





395
396
397
398
399
400
401
402
...
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
; parameters

  param .OnClick, ._OnClick, ._OnClick

  param .TextAlign,    ._textalign,  .SimpleSetParam:3
  param .Icon,         ._icon,       .SetIcon
  param .IconPosition, ._iconpos,    .SimpleSetParam:3

  param .State,        .GetState,    ._state

  param .ModalResult, ._ModalResult, ._ModalResult

; methods

  ; parameters handling methods

  method .GetState

  method .SetIcon, .value
  method .SimpleSetParam, .param, .get, .value

  ; system events methods

  method .Create, .Parent

  method ._RenderView

  method .SelfPaint, .Operation, .pDstImage, .xDst, .yDst, .xSrc, .ySrc, .width, .height
  method .Resize, .newWidth, .newHeight
  method .SetCaption, .value

  method .EventFocusIn
  method .EventFocusOut

................................................................................
endobj


interface TButton.OnClick, .self, .button


; new


method TButton.Create
begin
        inherited [.Parent]

        mov     eax, [.self]
        mov     [eax+TButton._cursor], mcHand
................................................................................
        jne     @f
        exec    esi, TButton:_RenderView
@@:
        mov     ebx, [esi+TButton._canvas]
        test    ebx, ebx
        jz      .finish

        get     edx, esi, TButton:State
        imul    edx, [esi+TButton._height]
        add     edx, [.ySrc]

        mov     ecx, CopyImageRect
        cmp     [.Operation], spCopy
        je      .doit
        mov     ecx, BlendImage
................................................................................

.size_ok:
        and     [esi+TButton._canvas_valid], 0
        exec    esi, TButton:RectChanged2, 0
        popad
        return
endp




method TButton.GetState
begin
        mov     eax, [.self]
        cmp     [eax+TButton._enabled], 0
        je      .disabled
        mov     eax, [eax+TButton._state]
        return

.disabled:
        mov     eax, bsDisabled
        return
endp



method TButton.SetCaption       ;, .value
begin
        inherited [.value]

        push    eax
................................................................................
        xor     ebx, ebx        ; 0 == bsNeutral

.loop_y:

; draw the border and the background

        lea     eax, [.client]





        stdcall DrawBoxDefault, [.canvas], eax, [GUI.clBtnBk+4*ebx], [GUI.btnBorder+4*ebx], [GUI.boxBorderWidth]

; draw the icon

        mov     edi, [.icon]
        test    edi, edi
        jz      .draw_text

................................................................................
        mov     ecx, [.bounds.y]

        cmp     ebx, bsPressed
        jne     @f
        add     eax, [GUI.btnPressedOfsX]
        add     ecx, [GUI.btnPressedOfsY]
@@:

        stdcall DrawTextBox, [.canvas], [.caption], eax, ecx, [.bounds.width], [.bounds.height], 2, edi, [GUI.DefaultFont], [GUI.clBtnTxt+4*ebx]

.textok:
        cmp     esi, [__FocusedWindow]
        jne     .focus_ok

        mov     eax, [.client.y]

Changes to freshlib/gui/themes/flat_gui.asm.

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
\
                boxBorderWidth,  NUM, 2,                             \
\
\ ; TButton colors and styles. The multivalue fields are for Neutral, Hovered and Pressed states.
\
               clBtnBk,         HEX, <clTurquoise, $ff48c9b0, clGreenSea, $807b7b7b>,   \
               clBtnTxt,        HEX, <clWhite, clWhite, clSilver, $80ffffff>,           \
               btnBorder,       NUM, <bxNone, bxNone, bxNone, bxNone>,                  \
               btnPressedOfsX,  NUM, 0,                                      \
               btnPressedOfsY,  NUM, 0,                                      \
               btnMarginX,      NUM, 8,                                      \
               btnMarginY,      NUM, 8,                                      \
\
\ ; TEdit colors and styles.
\







|







81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
\
                boxBorderWidth,  NUM, 2,                             \
\
\ ; TButton colors and styles. The multivalue fields are for Neutral, Hovered and Pressed states.
\
               clBtnBk,         HEX, <clTurquoise, $ff48c9b0, clGreenSea, $807b7b7b>,   \
               clBtnTxt,        HEX, <clWhite, clWhite, clSilver, $80ffffff>,           \
               btnBorder,       NUM, <bxNone, bxNone, bxNone, bxNone or bxDisabled>,    \
               btnPressedOfsX,  NUM, 0,                                      \
               btnPressedOfsY,  NUM, 0,                                      \
               btnMarginX,      NUM, 8,                                      \
               btnMarginY,      NUM, 8,                                      \
\
\ ; TEdit colors and styles.
\

Changes to freshlib/gui/themes/win_gui.asm.

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
\
                boxBorderWidth,  NUM, 1,                             \
\
\ ; TButton colors and styles. The multivalue fields are for Neutral, Hovered and Pressed states.
\
               clBtnBk,         HEX, <$ffd4d0c8, $ffe0e0e0, $ffa0a0a0, $80d4d0c8>,      \
               clBtnTxt,        HEX, <$ff000000, $ff000000, $ff000000, $ff606060>,           \
               btnBorder,       NUM, <bxRaised, bxRaised, bxSunken>,               \
               btnPressedOfsX,  NUM, 1,                                      \
               btnPressedOfsY,  NUM, 1,                                      \
               btnMarginX,      NUM, 8,                                      \
               btnMarginY,      NUM, 8,                                      \
\
\ ; TEdit colors and styles.
\







|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
\
                boxBorderWidth,  NUM, 1,                             \
\
\ ; TButton colors and styles. The multivalue fields are for Neutral, Hovered and Pressed states.
\
               clBtnBk,         HEX, <$ffd4d0c8, $ffe0e0e0, $ffa0a0a0, $80d4d0c8>,      \
               clBtnTxt,        HEX, <$ff000000, $ff000000, $ff000000, $ff606060>,           \
               btnBorder,       NUM, <bxRaised, bxRaised, bxSunken, bxRaised or bxDisabled>,               \
               btnPressedOfsX,  NUM, 1,                                      \
               btnPressedOfsY,  NUM, 1,                                      \
               btnMarginX,      NUM, 8,                                      \
               btnMarginY,      NUM, 8,                                      \
\
\ ; TEdit colors and styles.
\

Changes to freshlib/test_code0/TestNewGUI.fpr.

cannot compute difference between binary files