[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / table-view / table-view-impl.cpp
index f5c3cc4..686c1ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
 #include <sstream>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 
 using namespace Dali;
 
@@ -51,7 +51,7 @@ bool FitToChild(Actor actor, Dimension::Type dimension)
 // currently not called from code so compiler will optimize these away, kept here for future debugging
 
 #define TABLEVIEW_TAG "DALI Toolkit::TableView "
-#define TV_LOG(fmt, args, ...) Debug::LogMessage(Debug::DebugInfo, TABLEVIEW_TAG fmt, ##args)
+#define TV_LOG(fmt, args, ...) Debug::LogMessageWithFunctionLine(Debug::INFO, TABLEVIEW_TAG fmt, ##args)
 //#define TABLEVIEW_DEBUG 1
 
 #if defined(TABLEVIEW_DEBUG)
@@ -1119,10 +1119,7 @@ void TableView::OnInitialize()
   self.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
   SetAsKeyboardFocusGroup(true);
 
-  DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new Control::Impl::AccessibleImpl(actor, Dali::Accessibility::Role::TABLE));
-  });
+  self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::TABLE);
 }
 
 void TableView::ResizeContainers(unsigned int rows, unsigned int columns)
@@ -1227,31 +1224,50 @@ void TableView::SetHeightOrWidthProperty(TableView& tableViewImpl,
       std::istringstream(map->GetKey(i)) >> index;
       if(childMap)
       {
-        Property::Value* policy        = childMap->Find("policy");
-        Property::Value* childMapValue = childMap->Find("value");
-        if(policy && childMapValue)
+        Property::Value* policy = childMap->Find("policy");
+        if(policy)
         {
           std::string policyValue;
-          policy->Get(policyValue);
-          Toolkit::TableView::LayoutPolicy policy;
-          if(Scripting::GetEnumeration<Toolkit::TableView::LayoutPolicy>(policyValue.c_str(),
-                                                                         LAYOUT_POLICY_STRING_TABLE,
-                                                                         LAYOUT_POLICY_STRING_TABLE_COUNT,
-                                                                         policy))
+          if(DALI_LIKELY(policy->Get(policyValue)))
           {
-            if(policy == Toolkit::TableView::FIXED)
+            Toolkit::TableView::LayoutPolicy policy;
+            if(Scripting::GetEnumeration<Toolkit::TableView::LayoutPolicy>(policyValue.c_str(),
+                                                                           LAYOUT_POLICY_STRING_TABLE,
+                                                                           LAYOUT_POLICY_STRING_TABLE_COUNT,
+                                                                           policy))
             {
-              (tableViewImpl.*funcFixed)(index, childMapValue->Get<float>());
-            }
-            else if(policy == Toolkit::TableView::RELATIVE)
-            {
-              (tableViewImpl.*funcRelative)(index, childMapValue->Get<float>());
-            }
-            else if(policy == Toolkit::TableView::FIT)
-            {
-              (tableViewImpl.*funcFit)(index);
+              switch(policy)
+              {
+                case Toolkit::TableView::FIXED:
+                case Toolkit::TableView::RELATIVE:
+                {
+                  Property::Value* childMapValue = childMap->Find("value");
+                  float            childValue    = 0.0f;
+                  if(DALI_LIKELY(childMapValue && childMapValue->Get(childValue)))
+                  {
+                    if(policy == Toolkit::TableView::FIXED)
+                    {
+                      (tableViewImpl.*funcFixed)(index, childValue);
+                    }
+                    else // if(policy == Toolkit::TableView::RELATIVE)
+                    {
+                      (tableViewImpl.*funcRelative)(index, childValue);
+                    }
+                  }
+                  break;
+                }
+                case Toolkit::TableView::FIT:
+                {
+                  (tableViewImpl.*funcFit)(index);
+                  break;
+                }
+                default:
+                {
+                  // do nothing for FILL policy
+                  break;
+                }
+              }
             }
-            // do nothing for FILL policy
           }
         }
       }