function varargout = paleta(varargin)
% paleta MATLAB code for paleta.fig
%      paleta, by itself, creates a new paleta or raises the existing
%      singleton*.
%
%      H = paleta returns the handle to a new paleta or the handle to
%      the existing singleton*.
%
%      paleta('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in paleta.M with the given input arguments.
%
%      paleta('Property','Value',...) creates a new paleta or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before paleta_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to paleta_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help paleta

% Last Modified by GUIDE v2.5 31-Dec-2018 12:50:00

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @paleta_OpeningFcn, ...
                   'gui_OutputFcn',  @paleta_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before paleta is made visible.
function paleta_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to paleta (see VARARGIN)

% Choose default command line output for paleta
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes paleta wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = paleta_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function Red_Callback(hObject, eventdata, handles)
% hObject    handle to Red (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Red as text
%        str2double(get(hObject,'String')) returns contents of Red as a double

input_r = str2num(get(handles.Red,'String'));
if (isempty(input_r))
    set(handles.Michej,'Enable','off');
    disp('set');
    disp('if');
else 
    set(handles.Michej,'Enable','on');
    o = 1;
    m = 2;
    l = 3;
    c = 18; 
end
% --- Executes during object creation, after setting all properties.
function Red_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Red (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white'); 
    disp('set');
end



function Green_Callback(hObject, eventdata, handles)
% hObject    handle to Green (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Green as text
%        str2double(get(hObject,'String')) returns contents of Green as a double
input_g = str2num(get(handles.Green,'String'));
if (isempty(input_g))
    set(handles.Michej,'Enable','off');
else 
    set(handles.Michej,'Enable','on');
end

% --- Executes during object creation, after setting all properties.
function Green_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Green (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Blue_Callback(hObject, eventdata, handles)
% hObject    handle to Blue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Blue as text
%        str2double(get(hObject,'String')) returns contents of Blue as a double

input_b = str2num(get(handles.Blue,'String'));
if (isempty(input_b))
    set(handles.Michej,'Enable','off');
else 
    set(handles.Michej,'Enable','on');
end

% --- Executes during object creation, after setting all properties.
function Blue_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Blue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in Michej.
function Michej_Callback(hObject, eventdata, handles)
% hObject    handle to Michej (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
R = str2double(get(handles.Red, 'String'));
G = str2double(get(handles.Green, 'String'));
B = str2double(get(handles.Blue, 'String'));
if R<0 
    set(handles.Red,'String','0.0');
elseif R>1
    set(handles.Red,'String','1.0');
end
if B<0 
    set(handles.Blue,'String','0.0');
elseif B>1
    set(handles.Blue,'String','1.0');
end
if G<0 
    set(handles.Green,'String','0.0');
elseif G>1
    set(handles.Green,'String','1.0');
end
    
R = str2double(get(handles.Red, 'String'));
G = str2double(get(handles.Green, 'String'));
B = str2double(get(handles.Blue, 'String'));
set(handles.zobrazeni, 'BackgroundColor', [R G B]);

% --- Executes on slider movement.
function red_posun_Callback(hObject, eventdata, handles)
% hObject    handle to red_posun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

hodnota_r=get(hObject,'Value');
set(handles.Red,'String',hodnota_r);
set(handles.Green,'String',get(handles.green_posun,'Value'));
set(handles.Blue,'String',get(handles.blue_posun,'Value'));
set(handles.zobrazeni, 'BackgroundColor', [hodnota_r get(handles.green_posun,'Value') get(handles.blue_posun,'Value')]);

% --- Executes during object creation, after setting all properties.
function red_posun_CreateFcn(hObject, eventdata, handles)
% hObject    handle to red_posun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function green_posun_Callback(hObject, eventdata, handles)
% hObject    handle to green_posun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

hodnota_g=get(hObject,'Value');
set(handles.zobrazeni, 'BackgroundColor', [get(handles.red_posun,'Value') hodnota_g get(handles.blue_posun,'Value')]);
set(handles.Red,'String',get(handles.red_posun,'Value'));
set(handles.Green,'String',hodnota_g);
set(handles.Blue,'String',get(handles.blue_posun,'Value'));

% --- Executes during object creation, after setting all properties.
function green_posun_CreateFcn(hObject, eventdata, handles)
% hObject    handle to green_posun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function blue_posun_Callback(hObject, eventdata, handles)
% hObject    handle to blue_posun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

hodnota_b=get(hObject,'Value');
set(handles.zobrazeni, 'BackgroundColor', [get(handles.red_posun,'Value') get(handles.green_posun,'Value') hodnota_b]);
set(handles.Red,'String',get(handles.red_posun,'Value'));
set(handles.Green,'String',get(handles.green_posun,'Value'));
set(handles.Blue,'String',hodnota_b);

% --- Executes during object creation, after setting all properties.
function blue_posun_CreateFcn(hObject, eventdata, handles)
% hObject    handle to blue_posun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end
