Hex editor is a cat face

This commit is contained in:
Apelsin
2010-05-15 22:33:37 -07:00
parent dca142c64f
commit 65ef5ab6e3
16 changed files with 5814 additions and 5764 deletions

View File

@@ -24,7 +24,6 @@
#include "llappviewer.h" // gLocalInventoryRoot
#include "llfloaterperms.h" //get default perms
std::list<DOFloaterHex*> DOFloaterHex::sInstances;
S32 DOFloaterHex::sUploadAmount = 10;
@@ -66,25 +65,14 @@ BOOL DOFloaterHex::postBuild(void)
{
DOHexEditor* editor = getChild<DOHexEditor>("hex");
mEditor = editor;
#ifndef COLUMN_SPAN
// Set number of columns
U8 columns = U8(gSavedSettings.getU32("HexEditorColumns"));
editor->setColumns(columns);
// Reflect clamped U8ness in settings
gSavedSettings.setU32("HexEditorColumns", U32(columns));
// Reshape a little based on columns
S32 min_width = S32(editor->getSuggestedWidth()) + 20;
setResizeLimits(min_width, getMinHeight());
if(getRect().getWidth() < min_width)
{
//LLRect rect = getRect();
//rect.setOriginAndSize(rect.mLeft, rect.mBottom, min_width, rect.getHeight());
//setRect(rect);
reshape(min_width, getRect().getHeight(), FALSE);
editor->reshape(editor->getRect().getWidth(), editor->getRect().getHeight(), TRUE);
}
#endif
handleSizing();
childSetEnabled("upload_btn", false);
childSetLabelArg("upload_btn", "[UPLOAD]", std::string("Upload"));
@@ -412,4 +400,32 @@ void DOFloaterHex::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32
}
}
void DOFloaterHex::onCommitColumnCount(LLUICtrl *control, void *user_data)
{
if(control && user_data)
{
DOFloaterHex *instance = (DOFloaterHex *)user_data;
U8 columns = llclamp<U8>((U8)llfloor(control->getValue().asReal()), 0x00, 0xFF);
instance->mEditor->setColumns(columns);
gSavedSettings.setU32("HexEditorColumns", (U32)instance->mEditor->getColumns());
instance->handleSizing();
}
}
void DOFloaterHex::handleSizing()
{
// Reshape a little based on columns
S32 min_width = S32(mEditor->getSuggestedWidth(MIN_COLS)) + 20;
setResizeLimits(min_width, getMinHeight());
if(getRect().getWidth() < min_width)
{
//LLRect rect = getRect();
//rect.setOriginAndSize(rect.mLeft, rect.mBottom, min_width, rect.getHeight());
//setRect(rect);
reshape(min_width, getRect().getHeight(), FALSE);
mEditor->reshape(mEditor->getRect().getWidth(), mEditor->getRect().getHeight(), TRUE);
}
}
// </edit>

View File

@@ -31,6 +31,8 @@ public:
static void onClickSave(void* user_data);
static void onClickUpload(void* user_data);
static void onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
static void onCommitColumnCount(LLUICtrl *control, void *user_data);
void handleSizing();
LLInventoryItem* mItem;
DOHexEditor* mEditor;
static std::list<DOFloaterHex*> sInstances;

View File

@@ -114,7 +114,8 @@ LLSD DOHexEditor::getValue() const
void DOHexEditor::setColumns(U8 columns)
{
mColumns = columns;
//mColumns = columns;
mColumns = llclamp<U8>(llfloor(columns), 8, 64); //clamp this ffs
changedLength();
}
@@ -245,14 +246,15 @@ void DOHexEditor::setFocus(BOOL b)
LLUICtrl::setFocus(b);
}
F32 DOHexEditor::getSuggestedWidth()
F32 DOHexEditor::getSuggestedWidth(U8 cols)
{
cols = cols>1?cols:mColumns;
F32 char_width = mGLFont->getWidthF32(".");
F32 data_column_width = char_width * 3; // " 00";
F32 text_x = mTextRect.mLeft;
F32 text_x_data = text_x + (char_width * 10.1f); // "00000000 ", dunno why it's a fraction off
F32 text_x_ascii = text_x_data + (data_column_width * mColumns) + (char_width * 2);
F32 suggested_width = text_x_ascii + (char_width * mColumns);
F32 text_x_ascii = text_x_data + (data_column_width * cols) + (char_width * 2);
F32 suggested_width = text_x_ascii + (char_width * cols);
suggested_width += mScrollbar->getRect().getWidth();
suggested_width += 10.0f;
return suggested_width;
@@ -572,12 +574,14 @@ void DOHexEditor::draw()
BOOL has_focus = gFocusMgr.getKeyboardFocus() == this;
F32 line_height = mGLFont->getLineHeight();
F32 char_width = mGLFont->getWidthF32(".");
F32 data_column_width = char_width * 3; // " 00";
F32 text_x = mTextRect.mLeft;
F32 text_x_data = text_x + (char_width * 10.1f); // "00000000 ", dunno why it's a fraction off
#ifdef COLUMN_SPAN
mColumns = (right - char_width * 2 - text_x_data - mScrollbar->getRect().getWidth()) / (char_width * 4); // touch this if you dare...
#endif
F32 text_x_ascii = text_x_data + (data_column_width * mColumns) + (char_width * 2);
F32 text_y = (F32)(mTextRect.mTop - line_height);

View File

@@ -11,6 +11,13 @@
#ifndef DO_DOHEXEDITOR_H
#define DO_DOHEXEDITOR_H
#define MIN_COLS 8
#define MAX_COLS 48
#ifndef COLUMN_SPAN
#define COLUMN_SPAN
#endif
#include "lluictrl.h"
#include "llscrollbar.h"
#include "llviewborder.h"
@@ -26,9 +33,9 @@ public:
void setValue(const LLSD& value);
LLSD getValue() const;
void setColumns(U8 columns);
U8 getColumns(U8 columns) { return mColumns; };
U8 getColumns() { return mColumns; };
U32 getLineCount();
F32 getSuggestedWidth();
F32 getSuggestedWidth(U8 cols = -1);
U32 getProperSelectionStart();
U32 getProperSelectionEnd();
void reshape(S32 width, S32 height, BOOL called_from_parent);

View File

@@ -2,7 +2,12 @@
<floater can_close="true" can_drag_on_left="false" can_minimize="true"
can_resize="true" height="200" width="580" min_width="580" min_height="128"
name="floater_hex" title="Hex Editor" rect_control="FloaterHexRect">
<text name="status_text" follows="left|top" left="10" top="-25" height="20">Loading...</text>
<text name="status_text" follows="left|top" left="120" top="-25" height="20">Loading...</text>
<slider can_edit_text="false" top="-25" control_name="column_count"
decimal_digits="3" follows="left|top" height="16" increment="1"
initial_val="16" label="Columns" left="10" max_val="48" min_val="8"
mouse_opaque="true" name="column_count" show_text="false" value="16"
width="100" />
<button name="upload_btn" follows="right|top" top="-25" right="-120" width="100" bottom="155" label="[UPLOAD]" enabled="false"/>
<button name="save_btn" follows="right|top" top="-25" right="-10" width="100" bottom="155" label="Save" enabled="false"/>
<hex_editor name="hex" follows="left|top|right|bottom" left="10" top="-50" right="-10" bottom="10" visible="false"/>

View File

@@ -45,7 +45,7 @@
<name_editor bevel_style="in" border_style="line"
border_thickness="1" bottom="-24" enabled="false" follows="left|top"
font="SansSerifSmall" height="16" is_unicode="false" left_delta="75"
max_length="254" mouse_opaque="false" name="avatar_key"
max_length="254" mouse_opaque="false" name="key_"
width="256" />
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
bottom="-48" drop_shadow_visible="true" follows="left|top"
@@ -110,6 +110,14 @@
width="121">
[FIRST] [LAST]
</line_editor>
<button bottom_delta="0" follows="left|top" font="SansSerif" halign="center"
height="23" label="" left="40" bottom="-42" width="24"
image_selected="icon_avatar_expand.png"
image_unselected="icon_avatar_expand.png"
image_hover_selected="icon_avatar_expand.png"
image_hover_unselected="icon_avatar_expand.png"
mouse_opaque="true"
name="bigimg"/>
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
bottom="-68" drop_shadow_visible="true" follows="left|top"
font="SansSerifSmall" h_pad="0" halign="right" height="16" left="4"
@@ -371,6 +379,14 @@
default_image_name="None" follows="left|top" height="151" label=""
left="70" mouse_opaque="true" name="img"
tool_tip="Click to choose a picture" width="135" />
<button bottom_delta="0" follows="left|top" font="SansSerif" halign="center"
height="23" label="" left="30" bottom="-42" width="24"
image_selected="icon_avatar_expand.png"
image_unselected="icon_avatar_expand.png"
image_hover_selected="icon_avatar_expand.png"
image_hover_unselected="icon_avatar_expand.png"
mouse_opaque="true"
name="flbigimg"/>
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
bottom="-203" drop_shadow_visible="true" follows="left|top"
font="SansSerifSmall" h_pad="0" halign="right" height="16" left="4"