* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-12 11:44:04
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-23 15:18:13
+ * @LastEditTime: 2024-09-29 19:48:52
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/include/CompassView.h
*/
~CompassView() override;
void DirectionSetText(const char *text, const char *angle);
+ void DirectionSetTextId(int textId, const char *angle);
static CompassView *GetInstance(void);
void CompassStartRotate(int16_t numb);
bool InitPage(void);
private:
bool LoadCompassImage(UIImageView *view, uint32_t resId);
void ClearAll(void);
- UILabel *directionLabel{nullptr}; //方向标签
+ UILabelExt *directionLabel{nullptr}; //方向标签
UILabel *angledLabel{nullptr}; //角度标签
UIImageView *backGround{nullptr}; //背景图片
UIImageView *PlaceMarkerImage{nullptr}; //放置标记图片
#include "compass/include/CompassModel.h"
#include "graphic_service.h"
#include "gfx_utils/mem_check.h"
+#include "ui_resource_string.h"
namespace OHOS {
static constexpr int16_t RIGHT_NORTH_DOWN_23 = 23;
static constexpr int16_t RIGHT_EASTNORTH_UP_68 = 68;
static constexpr const char *EASTSOUTH_DIRECTION = (char *)"东南";
static constexpr const char *EASTNORTH_DIRECTION = (char *)"东北";
+static constexpr const int NORTH_DIRECTION_TEXTID = STR_NORTH;//北
+static constexpr const int SOUTH_DIRECTION_TEXTID = STR_SOUTH;//南
+static constexpr const int WEST_DIRECTION_TEXTID = STR_WEST;//西
+static constexpr const int EAST_DIRECTION_TEXTID = STR_EAST;//东
+static constexpr const int WESTNORTH_DIRECTION_TEXTID = STR_NORTHWEST;//西北
+static constexpr const int WESTSOUTH_DIRECTION_TEXTID = STR_SOUTHWEST;//西南
+static constexpr const int EASTSOUTH_DIRECTION_TEXTID = STR_SOUTHEAST;//西南
+static constexpr const int EASTNORTH_DIRECTION_TEXTID = STR_NORTHEAST;//东北
+
const CompassItem g_compassList[] = {
- {RIGHT_NORTH_DOWN_23, RIGHT_EASTNORTH_UP_68, EASTNORTH_DIRECTION},
- {RIGHT_EASTNORTH_UP_68, RIGHT_EAST_UP_113, EAST_DIRECTION},
- {RIGHT_EAST_UP_113, RIGHT_EASTSOUTH_UP_158, EASTSOUTH_DIRECTION},
- {RIGHT_EASTSOUTH_UP_158, RIGHT_SOUTH_UP_203, SOUTH_DIRECTION},
- {RIGHT_SOUTH_UP_203, RIGHT_WESTSOUTH_UP_248, WESTSOUTH_DIRECTION},
- {RIGHT_WESTSOUTH_UP_248, RIGHT_WEST_UP_293, WEST_DIRECTION},
- {RIGHT_WEST_UP_293, RIGHT_WESTNORTH_UP_338, WESTNORTH_DIRECTION}
+ {RIGHT_NORTH_DOWN_23, RIGHT_EASTNORTH_UP_68, EASTNORTH_DIRECTION,EASTNORTH_DIRECTION_TEXTID},
+ {RIGHT_EASTNORTH_UP_68, RIGHT_EAST_UP_113, EAST_DIRECTION,EAST_DIRECTION_TEXTID},
+ {RIGHT_EAST_UP_113, RIGHT_EASTSOUTH_UP_158, EASTSOUTH_DIRECTION,EASTSOUTH_DIRECTION_TEXTID},
+ {RIGHT_EASTSOUTH_UP_158, RIGHT_SOUTH_UP_203, SOUTH_DIRECTION,SOUTH_DIRECTION_TEXTID},
+ {RIGHT_SOUTH_UP_203, RIGHT_WESTSOUTH_UP_248, WESTSOUTH_DIRECTION,WESTSOUTH_DIRECTION_TEXTID},
+ {RIGHT_WESTSOUTH_UP_248, RIGHT_WEST_UP_293, WEST_DIRECTION,WEST_DIRECTION_TEXTID},
+ {RIGHT_WEST_UP_293, RIGHT_WESTNORTH_UP_338, WESTNORTH_DIRECTION,WESTNORTH_DIRECTION_TEXTID}
};
static CompassPresenter *g_pMainView = nullptr;
{
if ((angle >= RIGHT_WESTNORTH_UP_338) || (angle >= 0 && angle < RIGHT_NORTH_DOWN_23)) {
//CompassView::GetInstance()->DirectionSetText(NORTH_DIRECTION, ("~" + std::to_string(angle) + "°").c_str());
- CompassView::GetInstance()->DirectionSetText(NORTH_DIRECTION, (std::to_string(angle) + "°").c_str());
+ // CompassView::GetInstance()->DirectionSetText(NORTH_DIRECTION, (std::to_string(angle) + "°").c_str());
+ CompassView::GetInstance()->DirectionSetTextId(NORTH_DIRECTION_TEXTID, (std::to_string(angle) + "°").c_str());
}
for (int i = 0; i < DIRECTION_COUNT; i++) {
if ((angle >= g_compassList[i].beginAngle) && (angle < g_compassList[i].endAngle)) {
- CompassView::GetInstance()->DirectionSetText(g_compassList[i].dir, ("~" + std::to_string(angle) + "°").c_str());
- CompassView::GetInstance()->DirectionSetText(g_compassList[i].dir, (std::to_string(angle) + "°").c_str());
+ // CompassView::GetInstance()->DirectionSetText(g_compassList[i].dir, ("~" + std::to_string(angle) + "°").c_str());
+ // CompassView::GetInstance()->DirectionSetText(g_compassList[i].dir, (std::to_string(angle) + "°").c_str());
+ CompassView::GetInstance()->DirectionSetTextId(g_compassList[i].dir_textId, (std::to_string(angle) + "°").c_str());
}
}
}
#include "compass/include/CompassView.h"
#include "compass/include/MainCompassView.h"
#include "compass/include/CompassPresenter.h"
+#include "ui_resource_string.h"
namespace OHOS {
static constexpr int16_t COMPASSVIEW_W = 466;
static constexpr int16_t COMPASSVIEW_H = 466;
directionLabel->SetText(text);
angledLabel->SetText(angle);
}
+void CompassView::DirectionSetTextId(int textId, const char *angle)
+{
+ if(directionLabel && angledLabel)
+ {
+ directionLabel->SetTextId(textId);
+ directionLabel->Invalidate();
+
+ angledLabel->SetText(angle);
+ angledLabel->Invalidate();
+ }
+}
//加载指南针图片
bool CompassView::LoadCompassImage(UIImageView *view, uint32_t resId)
{
return false;
}
- directionLabel = new UILabel();
+ directionLabel = new UILabelExt();
if (directionLabel == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "directionLabel new fail");
ClearAll();
}
directionLabel->SetPosition(DIRECTIONLABEL_X, DIRECTIONLABEL_Y);
directionLabel->Resize(DIRECTIONLABEL_TEXT_WIDTH, DIRECTIONLABEL_TEXT_HEIGH);
- directionLabel->SetText("北");
+ directionLabel->SetTextId(STR_NORTH);
directionLabel->SetStyle(STYLE_TEXT_FONT, DIRECTIONLABEL_FONT_TEXT_SIZE);
directionLabel->SetStyle(STYLE_LINE_HEIGHT, DIRECTIONLABEL_STYLE_LINE_HEIGHT);
directionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, DIRECTIONLABEL_FONT_TEXT_SIZE);
angledLabel->SetText("0°");
angledLabel->SetStyle(STYLE_TEXT_FONT, ANGLEDLABEL_FONT_TEXT_SIZE);
angledLabel->SetStyle(STYLE_LINE_HEIGHT, ANGLEDLABEL_STYLE_LINE_HEIGHT);
- angledLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, ANGLEDLABEL_FONT_TEXT_SIZE);
+ angledLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, ANGLEDLABEL_FONT_TEXT_SIZE);
angledLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
angledLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
angledLabel->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);