ui: update in-call actions

- use new button theme for call controls buttons.
- add an icon for recording
- gide buttons when available instead of disabling them

Issue: #79400
Change-Id: I712467b8f7b7fe16317f4283ae9d4f91bc8b9203
diff --git a/src/CurrentCallVC.mm b/src/CurrentCallVC.mm
index 5b157ba..586b3f0 100644
--- a/src/CurrentCallVC.mm
+++ b/src/CurrentCallVC.mm
@@ -61,6 +61,7 @@
 @property (unsafe_unretained) IBOutlet NSButton *muteVideoButton;
 @property (unsafe_unretained) IBOutlet NSButton *addContactButton;
 @property (unsafe_unretained) IBOutlet NSView *headerContainer;
+@property (unsafe_unretained) IBOutlet NSButton *qualityButton;
 
 @property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator;
 
@@ -109,18 +110,9 @@
     const QModelIndex& idx = CallModel::instance()->userActionModel()->index(row,0);
     UserActionModel::Action action = qvariant_cast<UserActionModel::Action>(idx.data(UserActionModel::Role::ACTION));
     NSButton* a = actionHash[(int) action];
-    if (a != nil) {
-        [a setEnabled:(idx.flags() & Qt::ItemIsEnabled)];
+    if (a) {
+        [a setHidden:!(idx.flags() & Qt::ItemIsEnabled)];
         [a setState:(idx.data(Qt::CheckStateRole) == Qt::Checked) ? NSOnState : NSOffState];
-
-        if(action == UserActionModel::Action::HOLD) {
-            NSString* imgName = (a.state == NSOnState ? @"ic_action_holdoff" : @"ic_action_hold");
-            [a setImage:[NSImage imageNamed:imgName]];
-
-        }
-        if(action == UserActionModel::Action::RECORD) {
-            [a setTitle:(a.state == NSOnState ? @"Record off" : @"Record")];
-        }
     }
 }
 
@@ -138,7 +130,14 @@
     [self.addContactButton setHidden:!shouldShow];
 
     Call::State state = callIdx.data((int)Call::Role::State).value<Call::State>();
+
+    // Default values for this views
     [loadingIndicator setHidden:YES];
+    [self.qualityButton setHidden:YES];
+    [self.chatButton setHidden:YES];
+    [videoView setShouldAcceptInteractions:NO];
+
+
     [stateLabel setStringValue:callIdx.data((int)Call::Role::HumanStateName).toString().toNSString()];
     switch (state) {
         case Call::State::DIALING:
@@ -147,33 +146,27 @@
         case Call::State::NEW:
             break;
         case Call::State::INITIALIZATION:
-            [videoView setShouldAcceptInteractions:NO];
             [loadingIndicator setHidden:NO];
             break;
         case Call::State::CONNECTED:
-            [videoView setShouldAcceptInteractions:NO];
             [loadingIndicator setHidden:NO];
             break;
         case Call::State::RINGING:
-            [videoView setShouldAcceptInteractions:NO];
             break;
         case Call::State::CURRENT:
             [videoView setShouldAcceptInteractions:YES];
+            [self.chatButton setHidden:NO];
+            [self.qualityButton setHidden:NO];
             break;
         case Call::State::HOLD:
-            [videoView setShouldAcceptInteractions:NO];
             break;
         case Call::State::BUSY:
-            [videoView setShouldAcceptInteractions:NO];
             break;
         case Call::State::OVER:
-            [videoView setShouldAcceptInteractions:NO];
+        case Call::State::FAILURE:
             if(self.splitView.isInFullScreenMode)
                 [self.splitView exitFullScreenModeWithOptions:nil];
             break;
-        case Call::State::FAILURE:
-            [videoView setShouldAcceptInteractions:NO];
-            break;
     }
 
 }
@@ -224,6 +217,7 @@
     [loadingIndicator setLengthOfLine:2];
     [loadingIndicator setInnerMargin:30];
 
+    [self.qualityPopOver setDelegate:self];
     [self.videoView setCallDelegate:self];
 
     [self connect];
@@ -541,6 +535,8 @@
     if (self.addToContactPopover != nullptr) {
         [self.addToContactPopover performClose:self];
         self.addToContactPopover = NULL;
+        [self.addContactButton setState:NSOffState];
+
     } else if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) {
         auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
         [editorVC setMethodToLink:contactmethod];
@@ -596,11 +592,18 @@
     uam << UserActionModel::Action::MUTE_VIDEO;
 }
 - (IBAction)displayQualityPopUp:(id)sender {
+
     [self.qualityPopOver showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge];
 }
 
 #pragma mark - NSPopOverDelegate
 
+- (void)popoverWillClose:(NSNotification *)notification
+{
+    [self.qualityButton setState:NSOffState];
+    [self.addContactButton setState:NSOffState];
+}
+
 - (void)popoverDidClose:(NSNotification *)notification
 {
     if (self.addToContactPopover != nullptr) {
diff --git a/src/views/IconButton.h b/src/views/IconButton.h
index b20d16b..ae22b35 100644
--- a/src/views/IconButton.h
+++ b/src/views/IconButton.h
@@ -16,21 +16,40 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
  */
-
 #import <Cocoa/Cocoa.h>
 
-
 @interface IconButton : NSButton
 
 @property (nonatomic) BOOL mouseDown;
 
 /*
  * This properties can be overriden in IB in User Defined Runtime Attributes
- * By default this values will be initialized in awakeFromNib with:
- * bgColor -> [NSColor ringBlue]
- * cornerRadius to view frame width / 2 (circle)
+ * By default this values will be initialized in awakeFromNib
+ */
+
+/*
+ * Background color of the button
+ * default value : [NSColor ringBlue]
  */
 @property (nonatomic, strong) NSColor* bgColor;
+
+/*
+ * Background color of the button when highlighted
+ * default value : view frame width / 2 (circle)
+ */
+@property (nonatomic, strong) NSColor* highlightColor;
+
+/*
+ * Background color of the button when highlighted
+ * default value : view frame width / 2 (circle)
+ */
 @property (nonatomic, strong) NSNumber* cornerRadius;
 
+/*
+ * Padding
+ * default value : 5.0
+ */
+@property CGFloat imageInsets;
+
+
 @end
diff --git a/src/views/IconButton.mm b/src/views/IconButton.mm
index f50a53a..93c0e29 100644
--- a/src/views/IconButton.mm
+++ b/src/views/IconButton.mm
@@ -21,7 +21,6 @@
 
 #import "NSColor+RingTheme.h"
 
-
 @implementation IconButton
 
 -(void) awakeFromNib {
@@ -32,6 +31,9 @@
     if (!self.cornerRadius) {
         self.cornerRadius = @(NSWidth(self.frame) / 2);
     }
+
+    if (self.imageInsets == 0)
+        self.imageInsets = 5.0f;
 }
 
 - (void)drawRect:(NSRect)dirtyRect
@@ -42,8 +44,14 @@
     NSColor* backgroundStrokeColor5;
 
     if (self.mouseDown || self.state == NSOnState) {
-        backgroundColor6 = [self.bgColor darkenColorByValue:0.3];
-        backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.4];
+        if (self.highlightColor) {
+            backgroundColor6 = self.highlightColor;
+            backgroundStrokeColor5 = [self.highlightColor darkenColorByValue:0.1];
+        } else {
+            backgroundColor6 = [self.bgColor darkenColorByValue:0.3];
+            backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.4];
+        }
+
     } else {
         backgroundColor6 = self.bgColor;
         backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.1];
@@ -52,13 +60,10 @@
     //// Subframes
     NSRect group = NSMakeRect(NSMinX(dirtyRect) + floor(NSWidth(dirtyRect) * 0.03333) + 0.5, NSMinY(dirtyRect) + floor(NSHeight(dirtyRect) * 0.03333) + 0.5, floor(NSWidth(dirtyRect) * 0.96667) - floor(NSWidth(dirtyRect) * 0.03333), floor(NSHeight(dirtyRect) * 0.96667) - floor(NSHeight(dirtyRect) * 0.03333));
 
-
     //// Group
     {
         //// Oval Drawing
-//        NSBezierPath* ovalPath = [NSBezierPath bezierPathWithOvalInRect: NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5))];
-
-NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5)) xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
+        NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5)) xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
 
         [backgroundColor6 setFill];
         [ovalPath fill];
@@ -72,7 +77,8 @@
         [path addClip];
 
         [self setImagePosition:NSImageOnly];
-        auto rect2 = NSInsetRect(dirtyRect, 5, 5);
+        auto rect2 = NSInsetRect(dirtyRect, self.imageInsets, self.imageInsets);
+
 
         [[NSColor image:self.image tintedWithColor:[NSColor whiteColor]]
                 drawInRect:rect2