Subversion Repositories Kolibri OS

Rev

Rev 3463 | Rev 3473 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ; Color Dialog - for Kolibri OS
  3. ; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;          notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;          notice, this list of conditions and the following disclaimer in the
  12. ;          documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;          names of its contributors may be used to endorse or promote products
  15. ;          derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. ;---------------------------------------------------------------------
  29. ;Some documentation for memory
  30. ;
  31. ;area name db 'FFFFFFFF_color_dialog',0 ; FFFFFFFF = PID
  32. ;
  33. ; communication area data
  34. ; flag  ; +0
  35. ; dw 0   ; 0 - empty, 1 - OK, color selected
  36. ;          2 - use another method/not found program, 3 - cancel
  37. ;
  38. ; type of dialog:  0-Palette&Tone
  39. ; dw 0 ; +2
  40. ;
  41. ; window X size ; +4
  42. ; dw 0
  43. ;
  44. ; window X position ; +6
  45. ; dw 0
  46. ;
  47. ; window y size ; +8
  48. ; dw 0
  49. ;
  50. ; window Y position ; +10
  51. ; dw 0
  52. ;
  53. ; ColorDialog WINDOW SLOT ; +12
  54. ; dd 0
  55. ;
  56. ; Color type ; +16
  57. ; dd 0
  58. ;
  59. ; Color value ; +20
  60. ; dd 0
  61. ;---------------------------------------------------------------------
  62.   use32
  63.   org    0x0
  64.  
  65.   db     'MENUET01'
  66.   dd     0x01
  67.   dd     START
  68.   dd     IM_END
  69.   dd     I_END
  70.   dd     stacktop
  71.   dd     param
  72.   dd     path
  73. ;---------------------------------------------------------------------
  74. include '../../macros.inc'
  75. include '../../develop/libraries/box_lib/load_lib.mac'
  76. include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  77. ;include 'lang.inc'
  78. ;include '../../debug.inc'
  79. @use_library
  80. ;---------------------------------------------------------------------
  81. p_start_x = 10
  82. p_start_y = 10
  83.  
  84. p_size_x = 20
  85. p_size_y = 256
  86. ;--------------------------------------
  87. t_start_x = 40
  88. t_start_y = 10
  89. ;--------------------------------------
  90. w_start_x = 200
  91. w_start_y = 200
  92.  
  93. w_size_x = 400
  94. w_size_y = 350
  95. ;--------------------------------------
  96. c_start_x = t_start_x + p_size_y + 10
  97. c_start_y = 10
  98.  
  99. c_size_x = 40
  100. c_size_y = 20
  101. ;---------------------------------------------------------------------
  102. x_minimal_size equ 350
  103. y_minimal_size equ 250
  104. ;---------------------------------------------------------------------
  105. START:
  106.         mcall   68,11
  107.         mcall   66,1,1
  108.         mcall   40,0x27
  109. ;       mcall   40,0x7
  110.         call    get_communication_area
  111.        
  112.         call    get_active_pocess
  113.  
  114. load_libraries  l_libs_start,end_l_libs
  115.         test    eax,eax
  116.         jnz     button.exit_2
  117.        
  118.         xor     eax,eax
  119.         mov     al,p_size_x
  120.         mov     [palette_SIZE_X],eax
  121.         mov     ax,p_size_y
  122.         mov     [palette_SIZE_Y],eax
  123.         mov     [tone_SIZE_X],eax
  124.         mov     [tone_SIZE_Y],eax
  125.         mov     eax,0xff0000
  126.         mov     [tone_color],eax
  127.         mov     [selected_color],eax
  128.         call    prepare_scrollbars_position_from_color
  129. ;--------------------------------------
  130.         mov     ecx,[palette_SIZE_Y]
  131.         imul    ecx,[palette_SIZE_X]
  132.         lea     ecx,[ecx*3]
  133.         inc     ecx     ;reserve for stosd
  134.         mcall   68,12
  135.         mov     [palette_area],eax
  136. ;--------------------------------------
  137.         call    create_palette
  138. ;--------------------------------------
  139.         mov     ecx,[tone_SIZE_Y]
  140.         imul    ecx,[tone_SIZE_X]
  141.         lea     ecx,[ecx*3]
  142.         inc     ecx     ;reserve for stosd
  143.         mcall   68,12
  144.         mov     [tone_area],eax
  145. ;--------------------------------------
  146.         call    create_tone
  147. ;---------------------------------------------------------------------
  148. align 4
  149. red:
  150.         call    draw_window
  151. ;---------------------------------------------------------------------
  152. align 4
  153. still:
  154.         mcall   10
  155.  
  156.         cmp     eax,1
  157.         je      red
  158.  
  159.         cmp     eax,2
  160.         je      key
  161.  
  162.         cmp     eax,3
  163.         je      button
  164.        
  165.         cmp     eax,6
  166.         je      mouse
  167.        
  168.         jmp     still
  169. ;---------------------------------------------------------------------
  170. align 4
  171. button:
  172.         mcall   17
  173.  
  174.         cmp     ah, 2
  175.         je      palette_button
  176.        
  177.         cmp     ah, 3
  178.         je      tone_button
  179.  
  180.         cmp     ah, 4
  181.         je      color_button
  182.        
  183.         cmp     ah, 1
  184.         jne     still
  185.  
  186. .exit:
  187.         mov     eax,[communication_area]
  188.         mov     [eax],word 3
  189. ; dps "CD flag value: cancel "
  190.  
  191. .exit_1:
  192.  
  193.         mov     ax,[eax]
  194.         and     eax,0xffff
  195. ; dps "CD flag value: "
  196. ; dpd eax
  197. ; newline
  198.  
  199.         call    get_window_param
  200.         mov     ebx,[communication_area]
  201.         mov     ecx,procinfo
  202. ;       mov     eax,[window_x]
  203.         mov     eax,[ecx+34]
  204.         shl     eax,16
  205.         add     eax,[ecx+42]
  206.         mov     [ebx+4],eax
  207. ;       mov     eax,[window_y]
  208.         mov     eax,[ecx+38]
  209.         shl     eax,16
  210.         add     eax,[ecx+46]
  211.         mov     [ebx+8],eax
  212. .exit_2:
  213.         mcall   -1
  214. ;---------------------------------------------------------------------
  215. get_window_param:
  216.         mcall   9,procinfo,-1
  217.         mov     eax,[ebx+66]
  218.         inc     eax
  219. ;       mov     [window_high],eax
  220.         mov     eax,[ebx+62]
  221.         inc     eax
  222. ;       mov     [window_width],eax
  223.         mov     eax,[ebx+70]
  224. ;       mov     [window_status],eax
  225.         ret
  226. ;---------------------------------------------------------------------
  227. align 4
  228. get_communication_area:
  229.         xor     eax,eax
  230.         mov     al,[param]
  231.         test    eax,eax
  232.         jz      @f
  233.         mcall   68,22,param,,0x01
  234.         mov     [communication_area],eax
  235. ;       movzx   ebx,word [eax+2]
  236. ;       mov     [color_dialog_type],ebx
  237.  
  238.         mov     ebx,[eax+4]
  239. ;       cmp     bx,word x_minimal_size ;300
  240. ;       jb      @f
  241.         mov     bx,420
  242.         mov     [window_x],ebx
  243.         mov     ebx,[eax+8]
  244. ;       cmp     bx,word y_minimal_size ;200
  245. ;       jb      @f
  246.         mov     bx,320
  247.         mov     [window_y],ebx
  248. @@:
  249.         ret
  250. ;---------------------------------------------------------------------
  251. align 4
  252. get_active_pocess:
  253.         mcall   9,procinfo,-1
  254.         mov     ecx,[ebx+30]    ; PID
  255.         mcall   18,21
  256.         mov     [active_process],eax    ; WINDOW SLOT
  257.         mov     ebx,[communication_area]       
  258.         test    ebx,ebx
  259.         jz      .1
  260.         mov     [ebx+12],eax    ; WINDOW SLOT to com. area
  261. .1:
  262.         ret
  263. ;---------------------------------------------------------------------
  264. align 4
  265. palette_button:
  266.         mcall   37,1
  267.         and     eax,0xffff
  268.         sub     eax,p_start_y
  269.         imul    eax,p_size_x
  270.         lea     eax,[eax+eax*2]
  271.         add     eax,[palette_area]
  272.         mov     eax,[eax]
  273.         mov     [tone_color],eax
  274.         mov     [selected_color],eax
  275.         call    prepare_scrollbars_position_from_color
  276.         call    create_and_draw_tone
  277.         call    draw_selected_color
  278.         call    draw_scrollbars
  279.         jmp     still
  280. ;---------------------------------------------------------------------
  281. align 4
  282. tone_button:
  283.         mcall   37,1
  284.         mov     ebx,eax
  285.         and     eax,0xffff
  286.         shr     ebx,16
  287.         sub     eax,t_start_y
  288.         imul    eax,p_size_y
  289.         sub     ebx,t_start_x
  290.         add     eax,ebx
  291.         lea     eax,[eax+eax*2]
  292.         add     eax,[tone_area]
  293.         mov     eax,[eax]
  294.         mov     [selected_color],eax
  295.         call    prepare_scrollbars_position_from_color
  296.         call    draw_selected_color
  297.         call    draw_scrollbars
  298.         jmp     still
  299. ;---------------------------------------------------------------------
  300. align 4
  301. color_button:
  302.         mov     eax,[communication_area]
  303.         mov     [eax],word 1
  304.         mov     ebx,[selected_color]
  305.         and     ebx,0xffffff
  306.         mov     [eax+20],ebx
  307. ; dps "CD flag value: OK "
  308.         jmp     button.exit_1
  309. ;---------------------------------------------------------------------
  310. align 4
  311. prepare_scrollbars_position_from_color:
  312. ; in: eax = selected color
  313.         movzx   ebx,al
  314.         mov     [scroll_bar_data_blue.position],ebx
  315.         shr     eax,8
  316.         mov     bl,al
  317.         mov     [scroll_bar_data_green.position],ebx
  318.         shr     eax,8
  319.         mov     bl,al
  320.         mov     [scroll_bar_data_red.position],ebx
  321.         ret
  322. ;---------------------------------------------------------------------
  323. align 4
  324. prepare_color_from_scrollbars_position:
  325. ; out: ebx = selected color
  326.         mov     eax,[scroll_bar_data_red.position]
  327.         movzx   ebx,al
  328.         shl     ebx,8
  329.         mov     eax,[scroll_bar_data_green.position]
  330.         mov     bl,al
  331.         shl     ebx,8
  332.         mov     eax,[scroll_bar_data_blue.position]
  333.         mov     bl,al
  334.         ret
  335. ;--------------------------------------------------------------------- 
  336. align 4
  337. key:
  338.         mcall   2
  339.         jmp     still
  340. ;---------------------------------------------------------------------
  341. align 4
  342. mouse:
  343.         cmp     [scroll_bar_data_red.delta2],0
  344.         jne     .red
  345.         cmp     [scroll_bar_data_green.delta2],0
  346.         jne     .green
  347.         cmp     [scroll_bar_data_blue.delta2],0
  348.         jne     .blue  
  349. ;--------------------------------------
  350. align 4
  351. .red:
  352.         push    dword scroll_bar_data_red
  353.         call    [scrollbar_ver_mouse]
  354.         cmp     [scroll_bar_data_red.delta2],0
  355.         jne     @f
  356. ;--------------------------------------
  357. align 4
  358. .green:
  359.         push    dword scroll_bar_data_green
  360.         call    [scrollbar_ver_mouse]
  361.         cmp     [scroll_bar_data_green.delta2],0
  362.         jne     @f
  363. ;--------------------------------------
  364. align 4
  365. .blue:
  366.         push    dword scroll_bar_data_blue
  367.         call    [scrollbar_ver_mouse]
  368. ;       cmp     [scroll_bar_data_blue.delta2],0
  369. ;       jne     @f
  370. ;--------------------------------------
  371. align 4
  372. @@:
  373.         call    prepare_color_from_scrollbars_position
  374.         cmp     [selected_color],ebx
  375.         je      still
  376.         mov     [selected_color],ebx
  377.         call    draw_selected_color
  378.         jmp     still
  379. ;---------------------------------------------------------------------
  380. align 4
  381. draw_selected_color:
  382.         mcall   13,<c_start_x,c_size_x>,<c_start_y,c_size_y>,[selected_color]
  383.         mcall   13,<c_start_x+c_size_x+10,c_size_x>,<c_start_y,c_size_y>,0xffffff
  384.         mov     ecx,[selected_color]
  385.         and     ecx,0xffffff
  386.         mcall   47,0x00060100,,<c_start_x+c_size_x+13,c_start_y+(c_size_y-6)/2>,0
  387.         ret
  388. ;---------------------------------------------------------------------
  389. align 4
  390. create_and_draw_tone:
  391.         call    create_tone
  392.         call    draw_tone
  393.         ret
  394. ;---------------------------------------------------------------------
  395. align 4
  396. draw_tone:
  397.         mcall   65,[tone_area],<[tone_SIZE_X],[tone_SIZE_Y]>,<t_start_x,t_start_y>,24
  398.         ret
  399. ;---------------------------------------------------------------------
  400. draw_scrollbars:
  401.         push    dword scroll_bar_data_red
  402.         call    [scrollbar_ver_draw]
  403.         push    dword scroll_bar_data_green
  404.         call    [scrollbar_ver_draw]
  405.         push    dword scroll_bar_data_blue
  406.         call    [scrollbar_ver_draw]
  407.         ret
  408. ;---------------------------------------------------------------------
  409. align 4
  410. draw_window:
  411.         mcall   12,1
  412. ;       mcall   0, <w_start_x,w_size_x>, <w_start_y,w_size_y>, 0x33AABBCC,,title
  413.         xor     esi,esi
  414.         mcall   0,[window_x],[window_y], 0x34AABBCC,,title
  415.         mcall   8,<p_start_x,[palette_SIZE_X]>,<p_start_y,[palette_SIZE_Y]>,0x60000002
  416.         mcall   ,<t_start_x,[tone_SIZE_X]>,<t_start_y,[tone_SIZE_Y]>,0x60000003
  417.         mcall   ,<c_start_x,c_size_x>,<c_start_y,c_size_y>,0x60000004
  418.         xor     ebp,ebp
  419.         mcall   65,[palette_area],<[palette_SIZE_X],[palette_SIZE_Y]>,<p_start_x,p_start_y>,24
  420.         call    draw_tone
  421.         call    draw_selected_color
  422.         xor     eax,eax
  423.         inc     eax
  424.         mov     [scroll_bar_data_red.all_redraw],eax
  425.         mov     [scroll_bar_data_green.all_redraw],eax
  426.         mov     [scroll_bar_data_blue.all_redraw],eax
  427.         call    draw_scrollbars
  428.         mcall   12,2
  429.         ret
  430. ;---------------------------------------------------------------------
  431. include 'palette.inc'
  432. ;---------------------------------------------------------------------
  433. include 'tone.inc'
  434. ;---------------------------------------------------------------------
  435. include 'i_data.inc'
  436. ;---------------------------------------------------------------------
  437. IM_END:
  438. ;---------------------------------------------------------------------
  439. include 'u_data.inc'
  440. ;---------------------------------------------------------------------
  441. I_END:
  442. ;---------------------------------------------------------------------